On 3/11/06, Ben Tilly <[EMAIL PROTECTED]> wrote:
> On 3/11/06, Joel Gwynn <[EMAIL PROTECTED]> wrote:
> > > Correcting myself, I don't think it is a bug.  $1 is dynamically
> > > scoped.  In your construct above, that means that when grep ends, $1
> > > is cleaned up.
> > >
> > > > while(grep(/--debug=(\d+)/, @ARGV)){
> > > >     $debug = $1;
> > > >     print "debug: $debug\n";
> > > >     last;
> > > > }
> > >
> > > And I think this works because the inner part of the while loop
> > > executes while the grep is still executing.  Which is a Perl
> > > optimization to avoid generating a long temporary list in this
> > > situation.
> > >
> > > Cheers,
> > > Ben
> > >
> >
> > Did you test this?  I get the same error with this construct.
> >
> Nope. :-(
>
> I thought I had, but I was testing something slightly different.  So
> disregard that bit of idiocy.
>
> However I did test this:
>
> for (@ARGV) {
>     if (/--debug=(\d+)/) {
>         $debug = $1;
>         print "debug: $1\n";
>     }
> }
>
> and it works because you're looking at $1 in the right scope.
>
> Cheers,
> Ben
>

No problem, dude.  Thanks for the help!
 
_______________________________________________
Boston-pm mailing list
[email protected]
http://mail.pm.org/mailman/listinfo/boston-pm

Reply via email to