Ramprasad A Padmanabhan wrote:
Hi
Hello,
I want to so a substititue a string Say
my %hash = ( 1130, "a" , 2100, "b");
$x = 'SOMEJUNK 1130';
# I want $x to be '1130a'
# This regex does not work
$x=~s/^(.*?) (\d+)/ $2 . { defined $hash{$2} ? $hash{$2} :
'NOTFOUND' } /e;
Can someone fix the regex for me
$ perl -le'
my %hash = ( 1130, "a" , 2100, "b");
$x = q/SOMEJUNK 1130/;
$x =~ s/(?<= )(\b\d+\b)/ exists $hash{ $1 } ? "$1$hash{$1}" : $1 /e;
print $x;
'
SOMEJUNK 1130a
John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>