in reply to substitution in a string
If I understand your problem correctly the line of code you want is @newArray = (map {tr/_/./; $_} @array):
my @newArray = ( map {my ($lhs, $rhs) = /(.*?)=(.*)/; $lhs =~ tr/_/./; "$lhs=$rhs"} @array );
use strict; use warnings; my @array = qw( oracle_hst_sid=hsta oracle_sid=sdpa oracle_home=/oracle/product_1/10.2.0 sdp_home=/oracle/oracle8 ); my @newArray = ( map {my ($lhs, $rhs) = /(.*?)=(.*)/; $lhs =~ tr/_/./; "$lhs=$rhs"} @array ); print join "\n", @newArray;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: substitution in a string
by pjf (Curate) on Sep 28, 2005 at 09:03 UTC |