------------------------------------------------
On Mon, 24 Mar 2003 08:58:40 -0500, "Rosenstein, Leon" <[EMAIL PROTECTED]> wrote:

>  
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Hi everyone,
> 
> I am having some problems with a script.  
> 
> Currently the script reads:
> opendir (DIR, "c:/temp") or die "Cant Open Temp Buddy Boy! \n";
> @filenames = readdir (DIR) or die "Can't Hold Filenames \n";
> foreach $name (@filenames) 
>       {if ($name eq "blah.dat") {rename ($name, "blah.old") or die "sorry
> couldnt complete task cause $!" } };
> 
> C:\scriptz>perl -w open4.pl
> sorry
> couldnt complete task cause No such file or directory at open4.pl line 7.
> 
> 
> Yet when I run this code:
> 
> opendir (DIR, "c:/temp") or die "Cant Open Temp Buddy Boy! \n";
> @filenames = readdir (DIR) or die "Can't Hold Filenames \n";
> foreach $name (@filenames) {
>       print "$name \n"; }
> 
> I get:
> 
> C:\scriptz>perl -w open3.pl
> .
> ..
> blah.dat
> FAD3.TXT
> osctalk.log
> sec_scan.html
> 
> Can anyone explain to me what I am doing wrong?
> 

perldoc -f rename

'rename' expects full file paths, or will default to the current working directory, 
your cwd is 'scriptz' while the file you need to move is in 'temp'. So 'rename' is 
looking for the 'blah.dat' file in 'scriptz' rather than 'temp', the 'opendir' does 
not automagically assign the cwd.

At least it appears that would be the problem.....

http://danconia.org

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to