mPSlide6GlobbingPerl supports globbingJustputtheglobbing patternbetween anglebracketsorusetheglobfunction:@all=<*>;@b=<[a-m]*.cpp>;@c=glob("[a-m]*.cpp");# sameas@bIn alist context,theglob returnsa list of all names thatmatchthepattern(oranemptylistifnonematch)
Slide 6 Globbing Perl supports globbing. Just put the globbing pattern between angle brackets or use the glob function: @all = <*>; @b = <[a-m]*.cpp>; @c = glob("[a-m]*.cpp"); # same as @b In a list context, the glob returns a list of all names that match the pattern (or an empty list if none match)
mPiSlide7GlobbingExample$ lsletterladdresssortnames$cat globl#!/usr/local/bin/perl5-w@files=<[a-m]*>;foreach sfile(@files)print"sfileln";$globladdressletterl$
Slide 7 Globbing Example: $ ls address letter1 names sort $ cat glob1 #!/usr/local/bin/perl5 -w @files = <[a-m]*>; foreach $file (@files){ print "$file\n"; } $ glob1 address letter1 $