in reply to Re: Re: Re: 'my' buggy...
in thread 'my' buggy...
#!/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 |