in reply to modify variable on pass by value
But now that you've asked for this, and I've answered it, let me give you some advice. Don't write subroutines like this. Perl works much better in a flow model, not a do-this-to-that model. For example, early versions of HTML::Entities::encode_entities worked that way, and after Gisle found enough places where it was a real bear to use, he changed it to be a return-value operator (with a backwards-compatibility mode).sub remove_caps { $_[0] =~ tr/A-Z//d; }
So, save yourself the trouble. Use the return value. Don't alter the arguments.
-- Randal L. Schwartz, Perl hacker
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
(Ovid) RE(2): modify variable on pass by value
by Ovid (Cardinal) on Sep 11, 2000 at 20:28 UTC | |
by merlyn (Sage) on Sep 11, 2000 at 20:36 UTC | |
by cwest (Friar) on Sep 11, 2000 at 20:45 UTC | |
by merlyn (Sage) on Sep 11, 2000 at 20:47 UTC | |
by chromatic (Archbishop) on Sep 11, 2000 at 21:13 UTC | |
by Ovid (Cardinal) on Sep 11, 2000 at 22:55 UTC | |
by merlyn (Sage) on Sep 12, 2000 at 21:12 UTC |