[Melbourne-pm] Perl chop behaviour
Becky Alcorn
becky at unisolve.com.au
Thu Aug 11 21:48:12 PDT 2005
Hi everyone,
I have a bit of a strange question. Can anyone shed some light on the
behaviour of chop() when you pass it an array that contains an array.
Example code is:
#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;
my @array = (
'fred',
'bob',
['aa', 'bb'],
);
my $chr = chop(@array);
print Dumper(\@array) . "\n";
print "Char: $chr\n";
And the output from that is:
$VAR1 = [
'fre',
'bo',
'ARRAY(0x812bfc0'
];
Char: )
I can see that it is taking the ')' from the array reference. Is it a bug
in my version of Perl (5.8.3), or does that actually make sense at some
level? I understand that it is a little bit difficult for Perl to decide
what to do in this case, but I didn't expect it to do that!
Cheers
Becky
More information about the Melbourne-pm
mailing list