P is for Practical | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
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:
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: 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: 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: Autark In reply to RE: Subtle Quirks
by autark
|
|