in reply to Check exist of anonymous subroutine before calling it within regexp substitute?
%d = ( foo => sub { "[@_]"; }, bar => sub { "(@_)"; }, ); # case 1 $_ = 'foo fooz bar'; s/(\w+)/$d{$1}?$d{$1}->($1):"$1"/ge; print "$_\n"; # case 2 $_ = 'foo fooz bar'; s/(\w+)(??{!$d{$1}})/$d{$1}->($1)/ge; print "$_\n"; __OUT__ [foo] fooz (bar) [foo] [foo]z (bar)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Check exist of anonymous subroutine before calling it within regexp substitute?
by ikegami (Patriarch) on Oct 29, 2009 at 18:15 UTC | |
by oha (Friar) on Oct 30, 2009 at 08:57 UTC | |
by ikegami (Patriarch) on Oct 30, 2009 at 14:53 UTC | |
|
Re^2: Check exist of anonymous subroutine before calling it within regexp substitute?
by jffry (Hermit) on Oct 29, 2009 at 18:32 UTC | |
by almut (Canon) on Oct 29, 2009 at 18:51 UTC |