Hello, I seem to be missing the proper use of push... I thought I could push an variable onto the end of an array (Right side of array) by using somthing like...
push(@array,$variable);
I am chomping from a log file an Error message and assigning it to the variable of $errout then I push the $errout into @array and print it to a file before the end of the script.
I seem to have the problem that only the last if statement that is chomping my error messages is populating the @array. I was wondering if someone could point out my mistakes from this small code sample.
the error messages that the script is reading is ascii text ie...
file/path - skipped
file/path - cannot verify
file/path - corrupt file
##### cannot verify error - and Populate Output file##### if (@txtfile[$i] =~ /\bcannot verify/) { chomp ($errout = @txtfile[$i]); push(@outfile,$errout); } ##### corrupt file error - and Populate Output file##### if (@txtfile[$i] =~ /\bcorrupt file/) { chomp ($errout = @txtfile[$i]); push(@outfile,$errout); } ##### skipped File error - and Populate Output file##### if (@txtfile[$i] =~ /\b- skipped/) { chomp ($errout = @txtfile[$i]); push(@outfile,$errout); }
Thank you... Darrick...
In reply to Example of push by dbrock
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |