< Perl Programming < Keywords
![](../../../I/Crystal_Clear_action_apply.png.webp)
The code
The glob keyword
glob returns in list context a (probably empty) list of filename extensions on the value of EXPRESSION. Called in scalar context, it iterates through such filename expansions and returns undef when the list is exhausted. If EXPRESSION is omitted, $_ is used instead.
glob splits its arguments on whitespace and treats each segment as a separate pattern.
Syntax
glob EXPRESSION
glob
Examples
![](../../../I/Crystal_Clear_action_apply.png.webp)
@array = glob("*.pl *.txt");
foreach (@array) {
print "$_\n";
}
returns all Perl files in the directory:
arrays.pl assign.pl control.pl first.pl glob.pl hash.pl hex.pl join.pl […] subroutines.pl time.pl trigonometry.pl variables.pl
This article is issued from Wikibooks. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.