[Edinburgh-pm] a Perl surprise

Jeff Parsons bynari at gmail.com
Wed Jul 18 11:45:46 PDT 2012

On 18/07/2012 16:06, Aaron Crane wrote:
> You can use Devel::Peek to see the difference:
> use Devel::Peek 'Dump';
> my @q = qw(6 7 8);
> my @s = ('6', '7', '8');
> my @n = (6, 7, 8);
> Dump(\@q);
> Dump(\@s);
> Dump(\@n);

Oh and yeah.. I see even when you quote the number it's still just 
stored as an IV until it's used as a string and then it creates the PV 
so you're left with both an IV and PV.. That makes sense. Cool. :-) It 
would be inefficient to immediately create an extra pointer and assign 
memory on the off-chance the programmer intends to use the number as a 
string. Best to wait until he actually *does* use it as a string. Thanks!

You seem extremely knowledgeable beyond the usual geek-level knowledge! 
Nice to have a super-geek locally in Scotland! :-)

More information about the Edinburgh-pm mailing list