[Omaha.pm] evolution

Andy Lester andy at petdance.com
Tue Apr 24 16:32:51 PDT 2007


> $x = $x + 1;
>
> $x += 1;
>
> $x++;
>
>
> Those all do the same thing. I ran into the 2nd version today and was
> surprised it wasn't the 3rd.  :)

They're not all the same.

$ cat foo.pl
$a = 'x'; $a = $a + 1;
$b = 'x'; $b += 1;
$c = 'x'; $c++;

print join ", ", ( $a, $b, $c );

$ perl -l foo.pl
1, 1, y

Didn't know Perl could increment strings, didja? :-)

Lots of things like this are on our new site, perl101.org

xoxo,
Andy

--
Andy Lester => andy at petdance.com => www.petdance.com => AIM:petdance






More information about the Omaha-pm mailing list