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} :
'NOTFOUN
Hi, Ramprasad
use ( ) not { } in regexp.
$x=~s/^(.*?) (\d+)/ $2 . ( defined $hash{$2} ? $hash{$2} : 'NOTFOUND' ) /e;
在 2005-02-15 12:30:00 您写道:
>Hi
>
> I want to so a substititue a string Say
>
> my %hash = ( 1130, "a" , 2100, "b");
>
>$x = 'SOMEJUNK 1130';
>
># I want $x to be
Hi
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