in reply to Glob Misbehavin'

Even if you know there's only one .txt file in the directory, you still need to call glob in an array context
my @txt = glob("$dir/*.txt");
... or a loop
while ( defined(my $txt = glob("$dir/*.txt")) ) { }
When you call glob in a scalar context, it returns the file the first time, then returns nothing the next time to let you know there are no more files.

Replies are listed 'Best First'.
Re: Re: Glob Misbehavin'
by Hofmator (Curate) on Jun 14, 2001 at 17:15 UTC
    or - to be able to use the scalar variable and not having to change the rest of the program

    my ($txt) = glob("$dir/*.txt");

    -- Hofmator