In a foreach loop, is there a way to find out the loop index number?
E.g.:
foreach (@myarray)
{
...
push(@newarray[??loopindex??], somevalue);
...
}
Currently, I have to resort to the following:
for (my $i= 0; $i = $#myarray, $i++)
{ ... push(@newarray[$i], somevalue); ...}
... which is more
Forgot to add: The second alternative is also wordy:
foreach (0 .. $#myarray)
{
...
push(@newarray[$_], somevalue);
...
}
And just like the for-loop, I longer have the array element in $_, which
makes all implicit $_ operations (regex's, chomp's, ...) wordier ...
-Nilanjan
On Mon, Sep 18, 2006 at 07:30:40AM -0700, Palit, Nilanjan wrote:
In a foreach loop, is there a way to find out the loop index number?
E.g.:
foreach (@myarray)
{
...
push(@newarray[??loopindex??], somevalue);
...
}
Currently, I have to resort to the following:
for (my $i= 0; $i =
That works too ( I have used it as well), but I guess what I'm really
asking (hoping?) for is a Perl special variable, kinda like $., which
Perl auto-magically initializes increments ...
-Nilanjan
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On
Behalf Of Dan
On Mon, 2006-09-18 at 08:28 -0700, Palit, Nilanjan wrote:
That works too ( I have used it as well), but I guess what I'm really
asking (hoping?) for is a Perl special variable, kinda like $., which
Perl auto-magically initializes increments ...
Perl6 will have a way of iterating over indices
PN == Palit, Nilanjan [EMAIL PROTECTED] writes:
PN That works too ( I have used it as well), but I guess what I'm
PN really asking (hoping?) for is a Perl special variable, kinda like
PN $., which Perl auto-magically initializes increments ...
in my experience classic loop indexes are
On Mon, Sep 18, 2006 at 08:28:33AM -0700, Palit, Nilanjan wrote:
That works too ( I have used it as well), but I guess what I'm really
asking (hoping?) for is a Perl special variable, kinda like $.,
which Perl auto-magically initializes increments ...
I doubt it does - considering that
On Tue, Sep 12, 2006 at 09:56:56PM -0400, Jeremy Muhlich wrote:
http://duplicity.nongnu.org/
From the site:
Duplicity backs directories by producing encrypted tar-format volumes
and uploading them to a remote or local file server. Because duplicity
uses librsync, the incremental archives
On Monday 18 September 2006 18:43, Kenneth A Graves wrote:
On Mon, 2006-09-18 at 08:28 -0700, Palit, Nilanjan wrote:
That works too ( I have used it as well), but I guess what I'm really
asking (hoping?) for is a Perl special variable, kinda like $., which
Perl auto-magically initializes
On Sep 18, 2006, at 3:53 PM, Shlomi Fish wrote:
Well, here is my attempt at writing such an iterator. Using it one
gets the
following program:
which only demonstrates so clearly that it's far far better to
simply
my $n = 0;
for ( @array ) {
++$n;
}
Flyswatter vs.
hi all,
i will be facilitating this meeting as ronald will be out of town. so
please rsvp to me (offlist) so we can figure out how much pizza and soda
to get.
thanx,
uri
Special Tech Meeting Monday, Sept 25, at MIT, with Damian Conway
Boston.pm will have a special tech meeting, Monday,
hi all,
given the likely size of this meeting (i will guess 50 or so) we can use
a little help with some of the logistics. we may be ordering 15-20
pizzas and the associated amount of drinks. the pizza will be delivered
to the building (possibly up to the classroom) but will need to be
brought
12 matches
Mail list logo