tachyon has asked for the wisdom of the Perl Monks concerning the following question:
At this node Anarion noticed some odd perl behaviour. The essence of the problem is summarised in the snippet below:
use Data::Dumper; my @matrix = (); $matrix[2]->[3]= "What's goin on?"; print "Before grep:\n", Dumper(\@matrix); grep{ /Huh?/ }@$_ for @matrix; print "\nAfter grep:\n", Dumper(\@matrix); __DATA__ Before grep: $VAR1 = [ undef, ${\$VAR1->[0]}, [ ${\$VAR1->[0]}, ${\$VAR1->[0]}, ${\$VAR1->[0]}, 'What\'s goin on?' ] ]; After grep: $VAR1 = [ [], [], [ undef, ${\$VAR1->[2][0]}, ${\$VAR1->[2][0]}, 'What\'s goin on?' ] ];
So the questions are: 1) why does the matrix get its original self referencing structure and 2) why does simply grepping through it change that structure?
cheers
tachyon
s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: A new perl {cough} feature?
by premchai21 (Curate) on Feb 17, 2002 at 16:20 UTC | |
by Anarion (Hermit) on Feb 17, 2002 at 16:32 UTC | |
by belg4mit (Prior) on Feb 17, 2002 at 17:28 UTC | |
by tye (Sage) on Feb 18, 2002 at 14:16 UTC | |
|
Re: A new perl {cough} feature?
by chipmunk (Parson) on Feb 18, 2002 at 05:17 UTC | |
by Anarion (Hermit) on Feb 18, 2002 at 17:30 UTC | |
|
Re: A new perl {cough} feature?
by jlongino (Parson) on Feb 17, 2002 at 18:31 UTC | |
by tachyon (Chancellor) on Feb 17, 2002 at 20:19 UTC | |
by demerphq (Chancellor) on Feb 18, 2002 at 09:51 UTC | |
|
Re: A new perl {cough} feature?
by demerphq (Chancellor) on Feb 18, 2002 at 09:56 UTC | |
|
Re: A new perl {cough} feature?
by BeernuT (Pilgrim) on Feb 17, 2002 at 16:30 UTC | |
by tachyon (Chancellor) on Feb 17, 2002 at 16:52 UTC | |
|
Re (tilly) 1: A new perl {cough} feature?
by tilly (Archbishop) on Feb 18, 2002 at 01:35 UTC |