[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl-Modules] File::find problem



At 11:55 PM +0100 10/30/99, Rory C-L wrote:
>I'm trying to open a set of files in various directories and print 
>out anything
>that looks like an email address after the full address of the file.
>
>I've been trying:
>
>    #!perl -w
>    use File::Find;
>    find(sub {
>            my $file = Find::File::name;

This should be $File::Find::name.  A simple test shows what's happening:

my $file = Find::File::name;
print "$file";
print " is not a directory" unless -d $file;
print "\n";

gives

Find::File::name is not a directory



>            unless (-d $file) {
>                open (IN, $file) or warn "Can't open $file";
>                while (<IN>) {
>                    while ( s/([^\s]+@[^\s]+)// ) {print "$file $1 \n"}
>                }
>            close IN;
>            }
>    }, @ARGV);
>
>wich works if I drop a set of files on the saved droplet, but I get 
>the following
>error if I drop a folder on it:
>
>    # Use of uninitialized value.
>    File 'Workshop HD:etc:MacPerl Ÿ:lib:File:Find.pm'; Line 151
>    # Use of uninitialized value.
>    File 'Workshop HD:etc:MacPerl Ÿ:lib:File:Find.pm'; Line 158
>
>The -d test doesn't seem to be working for directories. Is it 
>confusing the way
>File::Find does its traversal of the directories? The -d test works 
>below works.
>
>    #!perl -w
>    use File::Find;
>    find(sub {
>        my $file = $File::Find::name;
>        print $file, "\n" if -d;
>    }, @ARGV);
>
>I'd be grateful for any suggestions or help.
>
>Rory
>
>--
>		  Rory Campbell-Lange   +   The Campbell-Lange Workshop
> 			                  London

--
Paul Schinder
schinder@pobox.com

==== Want to unsubscribe from this list?
==== Send mail with body "unsubscribe" to macperl-modules-request@macperl.org