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, August 01, 2002 3:57 PM >To: [EMAIL PROTECTED] >Subject: Re: Regexp to match by hash key and replace with hash value? > > >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 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]