Thread glob("*.txt") vs. <*.txt> (21 answers)
Opened by Froschpopo at 2005-03-14 13:39

Dubu
 2005-03-14 15:52
#52649 #52649
User since
2003-08-04
2145 Artikel
ModeratorIn + EditorIn

user image
Ich bevorzuge glob(), weil es keine Verwechslungsgefahr mit dem Diamantoperator zum Einlesen aus einem Filehandle gibt.

Siehe auch perldoc perlop:
[quote=perldoc perlop,I/O Operators]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.

One level of double-quote interpretation is done first, but you can't say "<$foo>" because that's an indirect filehandle as explained in the previous paragraph.  (In older versions of Perl, programmers would insert curly brackets to force interpretation as a filename glob: "<${foo}>".  These days, it's considered cleaner to call the internal function directly as "glob($foo)", which is probably the right way to have done it in the first place.)
[/quote]

View full thread glob("*.txt") vs. <*.txt>