[Israel.pm] A $_ gotme

Gaal Yahas gaal at forum2.org
Tue Mar 2 08:32:09 PST 2004

I'd like to thank the two people in YAPC (regrettably, I don't remember
who you are!) who pointed out an error in one of my slides. Where I had

     ; $tmp

I should, of course, have had

     && ($_ = $tmp)

Because we don't want to just override the return value of the grep test
expression, but instead restore the ruined aliased value.[1] The restoration
only takes place when the previous sub-expression (a function call)
was true, but this is acceptable in this case because failed values get
thrown away anyhow.

The fixed slides are at:


While we're at it, the slides to the other talk are at:


And while we're at *that*, allow me to congratulate Gabor and the rest
of the organizers for a very enjoyable YAPC indeed. Perl in Israel has
truly gone a long way. There's already been lots of feedback so I'll just
say I hope next time we can find a nicer place to go to after the talks,
without overloud background singing about "all those bugs"![2]

[1] loop expressions such as for, map, and grep *alias* the iterator to
    each list element, so modifying it inside the loop changes the
	original data. This aliasing effect takes place *even in foreach
	where the iterator is a my() variable*, as demonstrated by the
	following one liner:

	% perl -le 'my @a = (1..3);for my $x (@a) {$x +=3}; print @a'

[2] Ran, they weren't really singing "all that Jazz"!

Gaal Yahas <gaal at forum2.org>

More information about the Perl mailing list