in reply to Non-destructive substitution?
A similar question was answered on c.l.p.misc in May. The solution is not mine, but I present it here.
Wanted: function composition using tr, s, etc. operators:
The answer:$var2 = s/123/456/g (tr/a-z/A-Z/ ($var));
or in this case: $string = apply {s/foo/blah/} $string;sub apply (&$) { local $_ = $_[1]; $_[0]->(); $_; } $var2 = apply {s/123/456/g; tr/a-z/A-Z/} $var;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Non-destructive substitution?
by bobione (Pilgrim) on Jul 03, 2001 at 15:32 UTC | |
by CharlesClarkson (Curate) on Jul 04, 2001 at 14:41 UTC |