develooper Front page | perl.perl6.language | Postings from September 2001

Re: LangSpec: Statements and Blocks [first,last]

Thread Previous | Thread Next
From:
raptor
Date:
September 2, 2001 12:47
Subject:
Re: LangSpec: Statements and Blocks [first,last]
Message ID:
007301c133d7$5467ab70$0500a8c0@xxx
hi,

As we read in Damian Conway- Perl6-notes, there will by a var-iterator that
can be used to see how many times the cycle has been "traversed" i.e.

foreach my $el (@ary) {
   .. do something ....
     print $#;  <--- print the index (or print $i )
}

shall we have :

foreach my $el (@ary) {
     print $# if $#.first();  <--- print the index on the first iteration
i.e. 1
   .. do something ....
     print $# if $#.last();  <--- print the index on the first iteration
i.e. $#ary
};

note : we can iterate on something else not only array
OR :

foreach my $el (@ary) {
     print $# if first;
   .. do something ....
     print $# if latest;
};


=====
iVAN
raptor@unacs.bg
=====
PS. One place where TT is before Perl :")



Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About