L
lerameur
hello,
below is part of my working program. No errors but the problem I am
facing is that the line: print $out_file $items[86],",";
seems to be activating twice. The purpose of this program is to take a
log file, ( array) and add data in an empty section of that array. Now
it is doing it, but twice. can someone tell how to correct this?
thanks
sub MainProg {
while (my $filename = glob("$year2$month2$day2$hours2*") ){
$temp_file_seq_n=substr($filename,-5,1); #first step to figure out the
logname to reproduce the original traffic log file
print $temp_file_seq_n, "\n";
if ($temp_file_seq_n ==1){
$logname=$logtime."$temp_file_seq_n"."_TLG";
&Parsing;
}
elsif ($temp_file_seq_n ==3){
$logname=$logtime."$temp_file_seq_n"."_TLG";
&Parsing;
}
elsif ($temp_file_seq_n ==5){
$logname=$logtime."$temp_file_seq_n"."_TLG";
&Parsing;
}
else{}
sub Parsing{
my $Oper_directory = '/aaa/Working/output';
chdir($Oper_directory) || die "Fail to change directory: $!\n";
open my $out_file, '>>', $logname."TEST" or die "Can't open
$logname: $!";
print "logname: $logname \n";
my $Oper_D = '/aaa/Working';
chdir($Oper_D) || die "Fail to change directory: $!\n";
open($wordlisting1, '<', $logname) or die "Could not open wordlisting:
$!";
while (my $line = <$wordlisting1> ) {
if ($line =~ m/Beth:8/ ) {
my @items = (split(/,/,$line))[0..85];
$items[86]="696c6c65";
my @items_extra = (split(/,/,$line))[87..88]; #86 is user data
print $out_file join(',', @items),",";
print $out_file $items[86],",";
print $out_file join(',', @items_extra);
}
k
below is part of my working program. No errors but the problem I am
facing is that the line: print $out_file $items[86],",";
seems to be activating twice. The purpose of this program is to take a
log file, ( array) and add data in an empty section of that array. Now
it is doing it, but twice. can someone tell how to correct this?
thanks
sub MainProg {
while (my $filename = glob("$year2$month2$day2$hours2*") ){
$temp_file_seq_n=substr($filename,-5,1); #first step to figure out the
logname to reproduce the original traffic log file
print $temp_file_seq_n, "\n";
if ($temp_file_seq_n ==1){
$logname=$logtime."$temp_file_seq_n"."_TLG";
&Parsing;
}
elsif ($temp_file_seq_n ==3){
$logname=$logtime."$temp_file_seq_n"."_TLG";
&Parsing;
}
elsif ($temp_file_seq_n ==5){
$logname=$logtime."$temp_file_seq_n"."_TLG";
&Parsing;
}
else{}
sub Parsing{
my $Oper_directory = '/aaa/Working/output';
chdir($Oper_directory) || die "Fail to change directory: $!\n";
open my $out_file, '>>', $logname."TEST" or die "Can't open
$logname: $!";
print "logname: $logname \n";
my $Oper_D = '/aaa/Working';
chdir($Oper_D) || die "Fail to change directory: $!\n";
open($wordlisting1, '<', $logname) or die "Could not open wordlisting:
$!";
while (my $line = <$wordlisting1> ) {
if ($line =~ m/Beth:8/ ) {
my @items = (split(/,/,$line))[0..85];
$items[86]="696c6c65";
my @items_extra = (split(/,/,$line))[87..88]; #86 is user data
print $out_file join(',', @items),",";
print $out_file $items[86],",";
print $out_file join(',', @items_extra);
}
k