-vladdrak#!/usr/bin/perl use strict; # @ARGV is = to @_ by default my $path=shift or die "Usage: $0 <directory|file>\n"; # Is it a directory or a file? if (-d $path) { opendir(DIR,$path) or die "could not open $path: $!\n"; for my $file (readdir(DIR)) { if ($file =~ /\_/) { nounder($file); } } closedir(DIR); } else { nounder($path); } sub nounder { my $file=shift; my $newfile=$file; $newfile=~s/\_/ /g; rename($file,$newfile) or die "couldn't rename $file: $!\n"; print "renamed $file to $newfile\n"; }
In reply to Re: Using arguements and defaults
by vladdrak
in thread Using arguements and defaults
by sock
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |