Re: search and replace on an array
- From: "Xicheng Jia" <xicheng@xxxxxxxxx>
- Date: 30 Jun 2006 09:09:36 -0700
ebm wrote:
I'm looking for a quick way to do a search and replace on an array oftry this:
values.
for instance I can do it this way, but is there a better way?
my @files = ("File1","File2");
my $path = ("c:\\path\\to\\");
@PathFile = map { [ $path . $_ ] } @files;
$newPath = "D:\\new\\place";
# now I have my path and file names combined and
#I can do some stuff with this. after I've done my work
# with it, is there an easy way to change my path name in
# my @newPath array?
# I can do it this way but is there a better way?
foreach(@newPath){
$_ =~ s/C:\\/D:\\/;
push ( @newArray, $_ );
}
# I want to do something like
# this @newPath =~ s/\Q$path\E/\Q$newPath\E/;
@newPath = map { s/\Q$path\E/\Q$newPath\E/; $_ } @newPath;
(untested)
Xicheng
.
- References:
- search and replace on an array
- From: ebm
- search and replace on an array
- Prev by Date: Re: A question of speed
- Next by Date: Re: search and replace on an array
- Previous by thread: Re: search and replace on an array
- Next by thread: Re: search and replace on an array
- Index(es):