Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
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 musing on the Monastery: (7)
As of 2015-07-02 05:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (29 votes), past polls