RE: Regexp to match by hash key and replace with hash value?

2002-08-01 Thread Bob Showalter
-Original Message- From: chris [mailto:[EMAIL PROTECTED]] Sent: Thursday, August 01, 2002 12:58 PM To: [EMAIL PROTECTED] Subject: Regexp to match by hash key and replace with hash value? Can I do the following with a single replace? my %hash = (1,abc, 2,xyz); my $line =

RE: Regexp to match by hash key and replace with hash value?

2002-08-01 Thread Bob Showalter
-Original Message- From: Bob Showalter [mailto:[EMAIL PROTECTED]] Sent: Thursday, August 01, 2002 1:02 PM To: 'chris'; [EMAIL PROTECTED] Subject: RE: Regexp to match by hash key and replace with hash value? -Original Message- From: chris [mailto:[EMAIL PROTECTED]]

Re: Regexp to match by hash key and replace with hash value?

2002-08-01 Thread chris
I need something like this to work my %hash = (1=abc, 2=xyz); my $line = '1324'; $line =~ s/[12]/$hash{$1}/g; print $line . \n; #expected result abc3xyz4 #actual result 34 On Thu, 1 Aug 2002 13:01:41 -0400 , [EMAIL PROTECTED] (Bob Showalter) wrote: -Original Message- From: chris

Re: Regexp to match by hash key and replace with hash value?

2002-08-01 Thread chris
ok now how to build this on the fly using %hash ([12]) On Thu, 1 Aug 2002 16:01:24 -0400, [EMAIL PROTECTED] (Shishir K. Singh) wrote: You forgot to put the brackets () around [12] $line =~ s/([12])/$hash{$1}/g; -Original Message- From: chris [mailto:[EMAIL PROTECTED]] Sent: Thursday,

RE: Regexp to match by hash key and replace with hash value?

2002-08-01 Thread Shishir K. Singh
my %hash = (1=abc, 2=xyz); my $line = '1324'; my @keys = keys %hash; $line =~ s/([@keys])/$hash{$1}/g; print $line . \n; -Original Message- From: chris [mailto:[EMAIL PROTECTED]] Sent: Thursday, August 01, 2002 4:14 PM To: [EMAIL PROTECTED] Subject: Re: Regexp to match by hash key and

Re: Regexp to match by hash key and replace with hash value?

2002-08-01 Thread chris
Thank you for your help. On Thu, 1 Aug 2002 16:25:26 -0400, [EMAIL PROTECTED] (Shishir K. Singh) wrote: my %hash = (1=abc, 2=xyz); my $line = '1324'; my @keys = keys %hash; $line =~ s/([@keys])/$hash{$1}/g; print $line . \n; -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional