in reply to Re: Globbing drives me nuts - some things seem counterintuitive
in thread Globbing drives me nuts - some things seem counterintuitive

Sorry Abigail

If you look at all of the stuff, in between I made a file  dir >x.txt just to prove (to myself) that it actually worked when there was a file.

What drives me nuts is it returns "xx.txt" if "xx.txt" was passed to the "glob" even if "xx.txt" does not exist.

  • Comment on Re: Re: Globbing drives me nuts - some things seem counterintuitive
  • Download Code

Replies are listed 'Best First'.
Re: Re: Re: Globbing drives me nuts - some things seem counterintuitive
by QM (Parson) on Apr 01, 2004 at 23:15 UTC
    What drives me nuts is it returns "xx.txt" if "xx.txt" was passed to the "glob" even if "xx.txt" does not exist.
    While that can be frustrating if it doesn't DWIM, I can think of a use for it.
    foreach my $file_spec ( @ARGV ) { my @files = glob( $file_spec ); foreach my $file ( @files ) { if ( not(-e $file) and ( $file =~ /[.*]/ ) ) # change as appropriate { warn "Error: file $f doesn't exist," . " or wildcard didn't match, " unless -e $file; } } }
    You might want to know which wildcard didn't match.

    -QM
    --
    Quantum Mechanics: The dreams stuff is made of