[Chicago-talk] Sharing my pain

Randal L. Schwartz merlyn at stonehenge.com
Fri Oct 13 14:52:14 PDT 2006

>>>>> "Andy" == Andy Bach <Andy_Bach at wiwb.uscourts.gov> writes:

Andy> One thing - this syntax:
Andy>      my $sp;
Andy>      foreach $sp (@tmp) {

Andy> is subtly wrong - got this from Damian Conway at YAPC but - even 
Andy> strict/warnings won't help you; the $sp inside the foreach is *not* the 
Andy> 'my'-ed $sp from the line before.  It gets silently localized w/i the 
Andy> loop:

But having said that, it was the *only* way to get a "local" var to work once
"use strict" was turned on, before the "foreach my $foo" syntax was introduced
in, I think, 5.004.  Maybe even 5.005.

Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn at stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

More information about the Chicago-talk mailing list