You said: "I want to replace the text 'SID' in each value of the hash with the 
text '12345'".

 

English to perl translation:

 

s/SID/12345/ for values %foo;

 

Cheers,

-Jan

 

From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of
[EMAIL PROTECTED]
Sent: December 4, 2007 11:56 AM
To: [email protected]
Subject: another doggone newbie question about hash fiddling...

 


Gurus, 

I'm embarrassed to have to ask this, but my books don't mention it, and neither 
does perldoc.  I'm looking for a way to do a
substitution to all values of a hash in one line, something using, oh, grep, or 
map...  What I want to do is change the values of
this hash: 

my %foo = ( '01' => 'abc/SID/def', 
                        '02' =>  'bcd/SID/fgh', 
                        '03' => 'hjk/SID/opq' ); 

to 

$foo{'01'} = 'abc/12345/def'; 
$foo{'02'} = 'bcd/12345/fgh'; 
$foo{'03'} = 'hjk/12345/opq'; 

In other words, I want to replace the text 'SID' in each value of the hash with 
the text '12345' using one line of code.  Can this
be done? 

Thanks, 

Deane Rothenmaier
Programmer/Analyst
Walgreens Corp.
847-914-5150

Let us permit nature to have her way; she understands her business better than 
we do. -- Michel de Montaigne

_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to