in reply to Re: Re: Re: 'my' buggy...
in thread 'my' buggy...

As for the original post, perhaps you're testing for the wrong phenomenon.

#!/usr/bin/perl use strict; sub foo { my($bar) = @_; print "foo: $bar\n"; ++$bar; } foo(1); foo(); foo(); foo(); foo(1); foo(); foo(); foo();

Produces:

foo: 1 foo: foo: foo: foo: 1 foo: foo: foo:

So the empty @_ does reset the var, which was I think your original assertion.

Matt

Update: Elian is right. That's what I get for posting pre-coffee. His original point involved a conditional assignment. I suppose if there's a moral to this mini-thread it is to make your parameter assignments mandatory unless you really are intending to keep old values around. :-(

Replies are listed 'Best First'.
Re: Re: Re: Re: Re: 'my' buggy...
by Elian (Parson) on Apr 30, 2002 at 16:54 UTC
    Nope, not quite. You're missing the conditional on the my, which was the important part of my original point. (Though, granted, in this case the problem the code's exhibiting is likely due to symbolic references) Add it back in and you'll see rather different behaviour.