Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Searching for Patterns in CSV

by roboticus (Chancellor)
on Jun 28, 2015 at 14:18 UTC ( [id://1132377]=note: print w/replies, xml ) Need Help??


in reply to Searching for Patterns in CSV

Fischer:

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:

while (my $line=<$file>) { for my $i (1..3) { ... stuff you want to do ... } }

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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1132377]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (5)
As of 2024-04-23 20:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found