in reply to Using arguements and defaults
-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"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Using arguements and defaults
by holo (Monk) on Nov 24, 2003 at 06:30 UTC |