Re: sort and keep the latest version
- From: "Dr.Ruud" <rvtol+news@xxxxxxxxxxxx>
- Date: Fri, 31 Mar 2006 12:31:22 +0200
Dave Weaver schreef:
Jim Gibson:
Katie:
for ( $i = 0; $i < $#sortedList; $i++ ) {
for my $i ( 0 .. $#sortedList ) {
You have an off-by-one error.
for my $i ( 0 .. $#sortedList - 1 ) {
Your "You" is Katie?
$#ary is the index of the last element of @ary.
(normally equal to 1 less than the number of elements)
See perldsc, perlop.
perl -e '@_=(4,5,6); print $#_, "\n"'
perl -e '{local $[=1; @_=(4,5,6); print $#_, "\n"}'
Context-free coding: for my $i ( $[ .. $#sortedList ) {}
But see perlvar: the use of $[ is discouraged.
--
Affijn, Ruud
"Gewoon is een tijger."
.
- Follow-Ups:
- Re: sort and keep the latest version
- From: Dr.Ruud
- Re: sort and keep the latest version
- References:
- sort and keep the latest version
- From: Katie
- Re: sort and keep the latest version
- From: Jim Gibson
- Re: sort and keep the latest version
- From: Dave Weaver
- sort and keep the latest version
- Prev by Date: Re: Reloading perl file dynamically
- Next by Date: Re: Converting codepages to UTF8
- Previous by thread: Re: sort and keep the latest version
- Next by thread: Re: sort and keep the latest version
- Index(es):
Relevant Pages
|