On Wednesday, October 15, 2003, at 01:04 PM, Dan Anderson wrote:

Thanks for your help, but I still have a few questions:

If we drop the my `ls` trick above, we can use Perl's directory
handling calls:
use Cwd;
opendir DIR, getcwd() or die "Directory error:  $!\n";

The code you gave me gives me errors when run:

Yes it does. Sorry about that! I'll have myself beaten later. :D


readline() on unopened filehandle DIR at ./rename.pl line 12.
        (Are you trying to call readline() on dirhandle DIR?)

Do you happen to know what that means?

Yes, replace the junk while loop I gave with:


while ($_ = readdir DIR) {
        # ...
}

I forgot directory handles read a little differently. My bad.

First, $_ =~ /rename.pl/ is not a pattern match.  To test equality use
$_ eq 'rename.pl'.

Actually I want it to pattern match. Emacs creates all sorts of files like rename.pl~ and #rename.pl#.

Then escape the . with \. so it's actually matching what you think it is. ;) Period is a metacharacter in regexes.


Good luck.

James


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



Reply via email to