develooper Front page | perl.perl5.porters | Postings from February 2012

Re: [perl #109408] Documentation that refers to Perl 5 as new

Thread Previous | Thread Next
From:
Ronald J Kimball
Date:
February 1, 2012 17:35
Subject:
Re: [perl #109408] Documentation that refers to Perl 5 as new
Message ID:
20120202013504.GA67889@penkwe.pair.com
More JavaScript to Perl traps:

=item *

In Perl, binary C<+> is always addition.  C<$string1 + $string2> converts
both strings to numbers and then adds them.  To concatenate two strings,
use the C<.> operator.

=item *

To iterate over the indices of an array, use C<foreach my $i (0 .. $#array)
{}>.  C<foreach my $v (@array) {}> iterates over the values.

=item *

To iterate over the keys of a hash, use C<foreach my $k (keys %hash) {}>.
C<foreach my $kv (%hash) {}> iterates over the keys and values, and is
generally not useful ($kv would be a key, then a value, and so on).

=item *

Perl requires braces following C<if>, C<while>, C<foreach>, etc.

=item *

In Perl, "else if" is spelled "elsif".


Ronald

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About