in reply to How do I move array contents into a directory?
This performs all s// actions in the hash on each file name. The output from the above snippit is:my @the_files = ('apple', 'pear', 'food'); my %image_hash = ('a'=>'z', 'o'=>'u', ); foreach my $file (@the_files) { my $newFile = $file; foreach my $key (keys %image_hash) { my $replaceVal = %image_hash->{$key}; $newFile =~ s/$key/$replaceVal/g; } print "move $file, $newFile or die 'Bummer!' \n"; }
move apple, zpple or die 'Bummer!' move pear, pezr or die 'Bummer!' move food, fuud or die 'Bummer!'
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How do I move array contents into a directory?
by kyle (Abbot) on Aug 29, 2008 at 17:45 UTC |