Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
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"; }

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://634545]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (4)
As of 2017-02-24 22:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?






    Results (363 votes). Check out past polls.