in reply to Perl Rename set of files
You should consider using @ARGV to pass arguments into your program. see perlvar.#/usr/bin/perl use strict; use warnings; my $code = 'ITEM_1 ,ITEM_2 ,ITEM_3 ,ITEM_4 ,ITEM_5 ,ITEM_6'; my $dir = '/local/usr/prod/'; my $exp = 'PRODUCTS'; for my $c (split /[\s,]+/, $code){ my @filelist =glob "$dir*$c*$exp*failed*"; foreach my $oldname (@filelist){ next if -d $oldname; # Update - corrected this - was missing $ +oldname! (my $newname = $oldname) =~ s/sold/ordered/; rename $oldname,$newname or warn "can't rename $oldname to $newname: $!" } }
...it is unhealthy to remain near things that are in the process of blowing up. man page for WARP, by Larry Wall
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Perl Rename set of files
by Magnolia25 (Sexton) on Oct 19, 2016 at 14:35 UTC |