in reply to using shift and $_ in loop
I'm not sure that what you want to do is sane, but that might be because I don't know your purpose. The following works but leaves @_ unmodified until after your loop:
sub scribble { for (@_) { ... }; @_ = (); };
Alternatively, with the assignment:
sub scribble { while ($_ = shift) { ... }; };
My second approach and your while(...) approach suffer from the same problem that they will end the loop if a false value is contained in @_
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: using shift and $_ in loop
by leocharre (Priest) on Oct 21, 2009 at 15:50 UTC | |
by moritz (Cardinal) on Oct 21, 2009 at 16:09 UTC | |
by leocharre (Priest) on Oct 21, 2009 at 21:01 UTC | |
by moritz (Cardinal) on Oct 21, 2009 at 21:51 UTC | |
by ikegami (Patriarch) on Oct 21, 2009 at 21:10 UTC | |
by leocharre (Priest) on Oct 21, 2009 at 21:16 UTC | |
by ikegami (Patriarch) on Oct 21, 2009 at 16:28 UTC | |
by keszler (Priest) on Oct 21, 2009 at 16:06 UTC | |
by moritz (Cardinal) on Oct 21, 2009 at 16:13 UTC | |
by keszler (Priest) on Oct 21, 2009 at 17:57 UTC | |
by leocharre (Priest) on Oct 21, 2009 at 20:20 UTC |