> -----Original Message-----
> From: Nikola Janceski [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, January 23, 2002 2:48 PM
> To: 'Jonathan E. Paton'; [EMAIL PROTECTED]
> Subject: RE: silly unlink question..
>
>
> okay so this works:
>
> @files = </home/*/*.txt>;
> print "@files\n";
>
> but this doesn't:
>
> $search = "/home/*/*.txt";
> @files = <$search>;
> print "@files\n";
>
> 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.
The perlop manpage contains the following explanation:
...
If angle brackets contain is a simple scalar variable (e.g., <$foo>),
then that variable contains the name of the filehandle to input from,
or its typeglob, or a reference to the same. For example:
$fh = \*STDIN;
$line = <$fh>;
If what's within the angle brackets is neither a filehandle nor a
simple scalar variable containing a filehandle name, typeglob, or
typeglob reference, it is interpreted as a filename pattern to be
globbed, and either a list of filenames or the next filename in the
list is returned, depending on context. This distinction is
determined on syntactic grounds alone. That means "<$x>" is always a
readline() from an indirect handle, but "<$hash{key}>" is always a
glob(). That's because $x is a simple scalar variable, but
"$hash{key}" is not--it's a hash element.
If you want to glob based on a pattern in $search, you should use the
glob function:
@files = glob($search);
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]