Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Reading multiple lines?

by chromatic (Archbishop)
on Nov 28, 2000 at 09:52 UTC ( [id://43625]=note: print w/replies, xml ) Need Help??


in reply to Reading multiple lines?

We need more special variables here, especially $.:
local $.; # make sure you're in a restrictive block while ($. < 10) { push @lines, scalar <IN>; last if eof(IN); }
I tested this on a file of 11 lines and one of 9. Worked both ways. If you don't care about uninitialized value errors, you can leave out the local.

Replies are listed 'Best First'.
Re: Re: Reading multiple lines?
by repson (Chaplain) on Nov 28, 2000 at 17:20 UTC
    Unless I'm missing something this code would only get the first block of 10 lines then would stop. Maybe this would be better:
    local $.; while (<IN>) { push @lines , scalar <IN>; next if (($.%10 == 0) and (!eof(IN))); # process @lines @lines = (); # clear }

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (3)
As of 2024-04-24 21:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found