in reply to reading file into an array
Array indexes in Perl begin with zero, so that's actually going to start at line 15.for(my $x=14; $x<@fileContents; $x++)
Also, a more perlish way of initiating that loop would be:
However, a much better way to process a file line by line is with a while loop. Something like this:for (13 .. $#fileContents) { print "$fileContents[$_]\n"; # Or whatever }
my $lines_to_skip = 14; while (my $line = <$file>) { # $. will give you the current line number of the file next if ($. <= $lines_to_skip); chomp($line); # Do stuff with $line }
Hope this helps,
Darren :)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: reading file into an array
by johngg (Canon) on Dec 05, 2008 at 22:16 UTC | |
|
Re^2: reading file into an array
by JadeNB (Chaplain) on Dec 05, 2008 at 23:59 UTC | |
|
Re^2: reading file into an array
by vassago (Novice) on Dec 05, 2008 at 21:26 UTC | |
by McDarren (Abbot) on Dec 05, 2008 at 21:52 UTC | |
by gwadej (Chaplain) on Dec 05, 2008 at 21:41 UTC |