PERL : pattern matching a string stored in a variable

I have two variables,

 
my $filename = "abc_yyyy_mm_dd.txt";
my $filename1 = " abc_2011_11_07.txt";
 

I need to perform some operations after checking if $filename has $filename1 in it

i have used the below code,

 
if($filename =~ /^$filename1/)
{
----
--
}
 

but this doesnt work.

Can somebody help with this.
Thanks in advance.

if you want to compare the strings this may help you..

my $filename = "abc_yyyy_mm_dd.txt"; my $filename1 = " abc_2011_11_07.txt";

But $filename does NOT have $filename1 in it.
I suggest you play with the =~ operator a little bit.

my $filename = "abc_yyyy_mm_dd.txt"; my $str = "yy_m";
if ($filename =~ $str) {
  print "Yess!\n"
}

will print Yess! because $filename contains "yy_m".