in reply to calling regular expressions returned by functions?
- Define a variable holding the regex you want to use.
- my $dot = qr/^[^\.{1,2}]/;
- This checks to see if the string begins with a period or two (.) or (..)
- Check out http://perldoc.perl.org/functions/our.html for more info... about 'our' and 'my' for defining variables. In your example - my will work fine.
- Use your defined variables in the grep, shown below.
my @list = qw(. .. test.xls file100.pl); my $dot = qr/^[^\.{1,2}]/; my @files = grep { /$dot/ } @list; foreach my $file(@files) { print "$item\n"; }
|
---|
In Section
Seekers of Perl Wisdom