> -----邮件原件----- > 发件人: JupiterHost.Net [mailto:[EMAIL PROTECTED] > 发送时间: 2006年2月28日 21:54 > 收件人: beginners@perl.org > 主题: Re: the way to get current index of an array > > > > [EMAIL PROTECTED] wrote: > > hi, perlers, > > Howdy, Thanks or your and others reply
> > > Is there a simple way to get the current index of an array in loop > > yes > > > statement? the procondition is you cannot get this information from > > array element. For example > > > > #!usr/bin/perl > > my @arr = qw/a b c d e/; > > for(@arr) > > { > > print "The No.?? element is $_\n"; } > > for my $idx (0 .. $#arr) { > print "The no $idx element is $arr{$_}\n"; } > > my $idx = 0; > for my $item(@arr) { > print "The no $idx element is $item\n"; > $idx++; > } That's great! but in another you cannot touched context, what can we do? these is no $ prefixed magic indicated this, but maybe some other corners keep this info? > > There are other more magical ways but those will probably be > best for you :) > > The first way not only has less code but is faster. > > HTH :) > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] For > additional commands, e-mail: [EMAIL PROTECTED] > <http://learn.perl.org/> <http://learn.perl.org/first-response> > > >
smime.p7s
Description: S/MIME cryptographic signature