Bugzilla:Languages: Difference between revisions

wtf?? removed trolling..
(wtf?? removed trolling..)
Line 65: Line 65:


* 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 new users:
* Some more complaints from people who don't know the language (removed)
** 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.
** 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 ==
21

edits