Welcome to the Monastery | |
PerlMonks |
Re: Searching for Patterns in CSVby roboticus (Chancellor) |
on Jun 28, 2015 at 14:18 UTC ( [id://1132377]=note: print w/replies, xml ) | Need Help?? |
Assuming that 'file' is a file handle and you're iterating over a file, then you'd use while (my $line=<$file>) { ... }. The range(1,4) function call translates to 1..3. So the first couple lines translates to:
That ought to get you started. Read some basic docs like perlintro to start coming up to speed. Note: You *could* translate the first line to for my $line (<$file>) { ... } but you don't want to do that--for the for loop version, perl would read the entire file into memory before giving your code the first line. The while loop version reads a line at a time from the file, which is nearly always what you want to do. ...roboticus When your only tool is a hammer, all problems look like your thumb.
In Section
Seekers of Perl Wisdom
|
|