[Melbourne-pm] Perl chop behaviour

leif.eriksen@hpa.com.au leif.eriksen at hpa.com.au
Thu Aug 11 22:09:21 PDT 2005


If you open up your PC, you'll notice your memory DIMM's are a little 
shorter too - chop() does that to references to memory address'...

L ;-}

becky at unisolve.com.au wrote:

>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
>
>_______________________________________________
>Melbourne-pm mailing list
>Melbourne-pm at pm.org
>http://mail.pm.org/mailman/listinfo/melbourne-pm
>
>  
>

-- 
Leif Eriksen
Snr Developer
http://www.hpa.com.au/
phone: +61 3 9217 5545
email: leif.eriksen at hpa.com.au
**********************************************************************
IMPORTANT
The contents of this e-mail and its attachments are confidential and intended solely for the use of the individual or entity to whom they are addressed.  If you received this e-mail in error, please notify the HPA Postmaster, postmaster at hpa.com.au, then delete  the e-mail.
This footnote also confirms that this e-mail message has been swept for the presence of computer viruses by MimeSweeper.  Before opening or using any attachments, check them for viruses and defects.
Our liability is limited to resupplying any affected attachments.
HPA collects personal information to provide and market our services. For more information about use, disclosure and access see our Privacy Policy at www.hpa.com.au
**********************************************************************


More information about the Melbourne-pm mailing list