Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^3: Hmmm: while(), file handle and $_ gotcha

by ikegami (Patriarch)
on Mar 06, 2009 at 13:55 UTC ( #748859=note: print w/replies, xml ) Need Help??


in reply to Re^2: Hmmm: while(), file handle and $_ gotcha
in thread Hmmm: while(), file handle and $_ gotcha

or
for my $cnt (0 .. 3) { print scalar(<DATA>); }

Replies are listed 'Best First'.
Re^4: Hmmm: while(), file handle and $_ gotcha
by hbm (Hermit) on Mar 06, 2009 at 14:12 UTC

    Cool! And then perhaps:

    while (<DATA>) { if ($. % 10 == 1) { print; print scalar(<DATA>) for(0..3); } }
      Since we want to print the first 5 lines of each group of 10,
      while (<DATA>) { print if ($. - 1) % 10 < 5; }

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (4)
As of 2022-01-27 13:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:












    Results (70 votes). Check out past polls.

    Notices?