> okay so this works:
> 
> @files = </home/*/*.txt>;
> print "@files\n";
>

</home/*.*.txt> is obviously not a filehandle, or a
variable containing one.  Hence it's a glob.

> but this doesn't:
> 
> $search = "/home/*/*.txt";
> @files = <$search>;
> print "@files\n";
> 

<$search> is treated as a named filehandle, since that is
what has precedence over use as a glob.

Using <GLOB_PATTERN> is basically an underloading of the
filehandle input syntax.  Usually it looks different enough
for Perl to do what you mean.  If it doesn't, you can use:

@files = glob($search);

> Why? I need to know the workings.. (I am a bit of guru
> in Perl but still missing some of the finer details). I
> have used opendir/readdir/closedir to do this, but I
> wanted to know why the second example doesn't work.

Search for:

"filehandle nor a simple scalar variable containing"

in:

perldoc perlop

it's about 90% of the way through the page... page 37 of
perlop of Perl 5.6.1

Jonathan Paton

__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com

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

Reply via email to