Beefy Boxes and Bandwidth Generously Provided by pair Networks Russ
Perl: the Markov chain saw
 
PerlMonks  

Re: Automatic Loop Counter not in perl

by snoopy (Deacon)
on Aug 22, 2007 at 23:42 UTC ( #634545=note: print w/ replies, xml ) Need Help??


in reply to Automatic Loop Counter not in perl

Another approach is to use an in-memory open (Perl 5.8.0+) thus enabling $.:

#!/usr/bin/perl use warnings; use strict; open (my $loop_fh, '<', \"Apples\nOranges\nBannanas\nKiwis") or die "unable to open: $!"; while (<$loop_fh>) { chomp; print "item $. is $_\n"; }


Comment on Re: Automatic Loop Counter not in perl
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (16)
As of 2014-04-17 14:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (449 votes), past polls