in reply to Perl: how to insert words at the end of each line and open the file?
In this part of your code:
while (@arr2 = <CF>){ foreach $line (@arr2) {
you are doing two nested loops, whereas you really need only one. And the first loop is actually faulty. You either want to do this:
my @arr2 = <CF>; foreach $line (@arr2) { # ...
or that:
while (my $line = <CF>) { # ...
The second solution is simpler, slightly faster and, in my view, cleaner.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Perl: how to insert words at the end of each line and open the file?
by WWq (Novice) on Nov 01, 2013 at 02:42 UTC |