For some reason when I am grepping a list like this one, the regular
expression doesn't seem to be working.  The $year and $month seem to be
ignored.

The following code prints:
1999_12_stats_log_01.txt1998_07_stats_log_01a.txt

It should print only:
1998_07_stats_log_01a.txt

#--------------------------------
   @allFiles = qw(
      1998_07_stats_log_01a.txt
      1998_07_stats_log_01b.txt
      1998_07_stats_log_02a.txt
      1998_07_stats_log_02b.txt
      1998_07_stats_log_03a.txt
      1999_12_stats_log_05.txt
      1999_12_stats_log_04.txt
      1999_12_stats_log_03.txt
      1999_12_stats_log_02.txt
      1999_12_stats_log_01.txt
   );

   my $year = 1998;
   my $month = "07";
   my @list1 = grep(/$year_$month_.*01\.txt/,  @allFiles);
   my @list2 = grep(/$year_$month_.*01a\.txt/, @allFiles);

   print $list1[0];  # should be nothing
   print $list2[0];  # should be 1998_07_stats_log_01a.txt

#--------------------------------


Dying to learn what I am missing.

Tanks,
David

Reply via email to