http://qs321.pair.com?node_id=962463


in reply to calling regular expressions returned by functions?

  1. 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 (..)
  2. Check out http://perldoc.perl.org/functions/our.html
  3. for more info... about 'our' and 'my' for defining variables. In your example - my will work fine.
  4. Use your defined variables in the grep, shown below.
Happy grepping, Dawn

my @list = qw(. .. test.xls file100.pl); my $dot = qr/^[^\.{1,2}]/; my @files = grep { /$dot/ } @list; foreach my $file(@files) { print "$item\n"; }