|
|
|
good chemistry is complicated, and a little bit messy -LW |
|
| PerlMonks |
Comment on |
| ( #3333=superdoc: print w/ replies, xml ) | Need Help?? |
|
In recent versions of Perl, you can do:
In pretty much any version of Perl, you can do:
Update: the second method is about 35% faster according to my benchmarking. The first one is sometimes more elegant - especially when the variable you're operating on (and don't want to be changed) is $_ such as this map block:
But in your original example, neither of the two solutions I presented above seems more elegant than the other, so I'd prefer the faster one.
perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'
In reply to Re: Replace In a Single Line
by tobyink
|
|