http://qs321.pair.com?node_id=24880


in reply to Subtle Quirks

Well, perl has many subtleties - if you dig long enough. The most irritating thing I have come over in perl is the difference between arrays and lists:
$_ = "ace"; my($a, $b, $c) = (/a/, /b/, /c/);
Intuitively one would expect the above code to be similar to my($a, $b, $c) = (1, undef, 1). But this is not the case. // returns the empty list when it fails - ouch. That means the result will be my($a, $b, $c) = (1, (), 1). Which in turn means that $a = 1, $b = 1 and $c = undef

I have learnt to avoid such situations in my own code, but often I find modules that suprises me still. I belivieve CGI's param method returns the empty list if it doesn't find a parameter:

my %foo = (BAR => $cgi->param('bar'), BAZ => $cgi->param('baz'), ZOT => $cgi->param('zot'), );
If the parameters 'bar' and 'baz' was missing, your %foo would look like:
%foo = (BAR => "BAZ",
        ZOT => "zots value");

Another thing which is kind of icky is the my $foo if 0 construct. It is if IIRC documented as something you shouldn't rely on, but I have actually found good use for this once :-)

A comment to your complaint about the builtins, if you want your own lc function, but still call the perl builtin lc:

use subs qw|lc|; sub lc { lc shift } print lc("BAR");
This will not work, because lc now is recursive. So how do you access the builtin lc now ? There is actually a package named CORE:: which provides access to all builtins functions:
use subs qw|lc|; sub lc { CORE::lc shift } print lc("BAR");
Autark