Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
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 the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (6)
As of 2016-06-25 09:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My preferred method of making French fries (chips) is in a ...











    Results (323 votes). Check out past polls.