wc -l command issue with perl

Hi Team,

the Following program execute with out error but the out is not save with create2.txt. kindly help me!!!

print "Enter your Number \n";

my $name = <STDIN>;

if ($name =="*91111*")

{ 

@dirlist1 = `wc -l $name > create2.txt`;

}

else {print "do not match";}
@dirlist1=`echo $ name| wc -l > create2.txt`

this will work in unix but not sure if it works in perl.

its not working in PERL

wc(1) is trying to open the file with file name which contains an "\n" at the end. You need chomp($name) before if().

 
print "Enter your Number \n";

chomp(my $name = <STDIN>);