in reply to Re^3: Moving files
in thread Moving files
into something more like:sub moving { print "Moving $_ to the K:/ATM \n"; move("$old$_","$new$_$date"); print "$_ has been moved to the K:/ATM\n"; print "---------------------------------------------\n"; } foreach (@files) { &moving; }
Personally I'd also use a named variable instead of $_, though, so I'd write something more like:foreach (@files) { print "Moving $_ to the K:/ATM \n"; move("$old$_","$new$_$date"); print "$_ has been moved to the K:/ATM\n"; print "---------------------------------------------\n"; }
But changing $_ to a named variable is not a functional change -- just makes the use of the loop variable a bit more clear.foreach my $file (@files) { print "Moving $file to the K:/ATM \n"; move("$old$file","$new$file$date"); print "$file has been moved to the K:/ATM\n"; print "---------------------------------------------\n"; }
|
|---|