Perl weirdness 2010#001

Perl keeps impressing me (negatively) with weird stuff such as implicit context and so on.... but that one is really out of the ordinary...
prompt~/ perl 
print "-------\n\n";
my $x = 'hostname1.foo.net';
$x->{'datacenter'} ||= '__';
use Data::Dumper; 
print Dumper $x;
print "x".$x->{'datacenter'}."x\n";
my $y = 'hostname1.foo.neT';
print "y".$y->{'datacenter'}."y\n";
my $z = 'hostname1.foo.net';
print "z".$z->{'datacenter'}."z\n";
-------

$VAR1 = 'hostname1.foo.net';
x__x
yy
z__z
prompt~/ 
first, I thought calling ->{} on a scalar/string would crash. to my surprise, my program passed. so I wrote this test only to learning something even crazier about perl. couldn't this be a security issue?

Posted in , , , , | Posted on 30 Mar 2010 14:11by somekool |

Subscribe

my last twitter posts

Personal Links

Tags

Categories

Archives

my Xbox 360 gamertag

Copyright © Mathieu Jobin's Life and Thoughts