Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Keeping a Count in iforeach/i

by neilwatson (Priest)
on Jun 17, 2002 at 15:26 UTC ( [id://175102]=note: print w/replies, xml ) Need Help??


in reply to Keeping a Count in foreach

You could use a counter:

my $count=0; foreach $e (@s) { $count ++; print "$e is the $count"."th element\n"; }

Neil Watson
watson-wilson.ca

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (3)
As of 2024-04-24 02:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found