[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:

use strict;
use warnings;
use Data::Dumper;

my @array = (
  ['aa', 'bb'],

my $chr = chop(@array);

print Dumper(\@array) . "\n";
print "Char: $chr\n";

And the output from that is:

$VAR1 = [

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!


More information about the Melbourne-pm mailing list