M
Marc Girod
Hello,
I was surprised to see in my own code, a difference between
the two lines (out of context...):
$self->rmhlink($type, $_) for @pl;
and:
for my $p (@pl) { $self->rmhlink($type, $p) }
The former consumed the contents of @pl.
The latter did not.
The rmhlink (member) function reads its arguments from @_,
and returns a value, often undef.
I tried to reproduce the case naively, but failed:
$ perl -wle '@s=qw(a b c);sub f{return};f($_)for@s;map{print $_}@s'
a
b
c
Is there thus an interaction from the package?
I cannot get this either...
$ perl -wle 'package Foo;@s=qw(a b c);sub new{$t=shift;$s={};bless $s,
$t}sub foo{return};$f=new Foo;$f->foo($_)for@s;map{print $_}@s'
a
b
c
I am afraid this is a symptom that I missed something fundamental...
Who is eating my list?
Thanks,
Marc
I was surprised to see in my own code, a difference between
the two lines (out of context...):
$self->rmhlink($type, $_) for @pl;
and:
for my $p (@pl) { $self->rmhlink($type, $p) }
The former consumed the contents of @pl.
The latter did not.
The rmhlink (member) function reads its arguments from @_,
and returns a value, often undef.
I tried to reproduce the case naively, but failed:
$ perl -wle '@s=qw(a b c);sub f{return};f($_)for@s;map{print $_}@s'
a
b
c
Is there thus an interaction from the package?
I cannot get this either...
$ perl -wle 'package Foo;@s=qw(a b c);sub new{$t=shift;$s={};bless $s,
$t}sub foo{return};$f=new Foo;$f->foo($_)for@s;map{print $_}@s'
a
b
c
I am afraid this is a symptom that I missed something fundamental...
Who is eating my list?
Thanks,
Marc