search and replace on an array
- From: "ebm" <ebmarquez@xxxxxxxxx>
- Date: 30 Jun 2006 08:22:07 -0700
I'm looking for a quick way to do a search and replace on an array of
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/;
Can somebody give me a hand?
.
- Follow-Ups:
- Re: search and replace on an array
- From: Paul Lalli
- Re: search and replace on an array
- From: Xicheng Jia
- Re: search and replace on an array
- From: David Squire
- Re: search and replace on an array
- Prev by Date: Re: Question on printerhandling
- Next by Date: Re: search and replace on an array
- Previous by thread: A question of speed
- Next by thread: Re: search and replace on an array
- Index(es):