canmove, Confirmed users
345
edits
Aarontrevena (talk | contribs) (→Cons) |
(→Perl Cons: Don't remove this again for any reason, Aaron. You can discuss it in the Discussion page with me, if you want.) |
||
Line 66: | Line 66: | ||
* See [http://avatraxiom.livejournal.com/58084.html The Problems of Perl]. | * See [http://avatraxiom.livejournal.com/58084.html The Problems of Perl]. | ||
* In addition, certain syntax things are confusing for | * In addition, certain syntax things are confusing for new users (from mkanat): | ||
** The difference between () and []. | |||
** The fact that %var is a () (which is also the array notation) but {} is $var. | |||
** The fact that subroutine arguments aren't really subroutine arguments, they're just an array that gets passed to a function. (This also brings up confusion on the difference between using $_[1], my $var = shift, and my ($var) = @_.) | |||
** The fact that $hash{'key'} and $hash{key} are the same. | |||
** qq[] is a string (as is qq{}, etc.), q[] is a string, though qw() is an array. | |||
** &sub() is resolved at runtime but sub() is resolved at compile time, ''except'' for methods. | |||
** The conversions from one type to another can sometimes be horrendous to read. Eg: [keys %{ @{ $var } }]. | |||
** $$foo[1] and $foo->[1] mean the same thing. | |||
** That numbers are compared with "==" but strings are compared with "eq", even though in other places strings are interpreted as numbers if used numerically. | |||
** Figuring out what's $1, $2, $3, etc. from a regex result. And the fact that $1 and $2 don't get reset if there's no match. | |||
*** Perl 5.10 will have named captures. | |||
** That Perl errors are in $@ but system errors are in $!, and when to use which one. | |||
** That Perl doesn't really have a class system, it just has a package system with @ISA or "use base," "bless," and SUPER::. | |||
** That "my ($var) = @_" will get you the first item of the array, but "my $var = @_" will get you a number. | |||
** In a hash created with (), if you accidentally have invalid items, you have an invalid hash. That is, you can't really do %hash = (key1 => $cgi->param('unset_param'), key2 => 'something'), because then you'll actually just have an invalid hash. (key1 will equal "key2" and "something" won't even have a real value.) In general it's safer to always make hashrefs when in doubt. | |||
** In array context, $cgi->param('value') returns an ''empty list'' if "value" wasn't passed to the CGI. It doesn't return undef. This is why we have "scalar $cgi->param()" all over the code. | |||
== Perl6 == | == Perl6 == |