abhilashm86
July 22nd, 2009, 04:17 PM
when i try matching uppercase or lower case scalar variable, its not recognising, is regular expression wrong in if statement??
#!/usr/bin/perl
%words= qw(
abc cool
gabreilla fool
sony pool
brooke bool
);
print "whats your partner??\n";
$n=<STDIN>;
chomp($n);
if($n = ~/^abhilash\b/i)
{
print "hi $n, you can enjoy night !!!!!\n";
}
else
{
$sw=$words{$n};
print "hi $n, tell proper codeword\n";
$code=<STDIN>;
chomp($code);
while($code ne $sw)
{
print "hey your code is not matching, try once again!!!\n";
$code=<STDIN>;
chomp($code);
}
print "howdy $n!!!, welcome to party\n";
}
abhilash@abhilash:~$ perl pgm7.pl
whats your partner??
abhilash
hi 4294967295, you can enjoy night !!!!!
abhilash@abhilash:~$
abhilash@abhilash:~$ perl pgm7.pl
whats your partner??
sony
hi 4294967295, you can enjoy night !!!!!
its not checking for other inputs also, i even tried substituting eq instead of =, but din't work.....
#!/usr/bin/perl
%words= qw(
abc cool
gabreilla fool
sony pool
brooke bool
);
print "whats your partner??\n";
$n=<STDIN>;
chomp($n);
if($n = ~/^abhilash\b/i)
{
print "hi $n, you can enjoy night !!!!!\n";
}
else
{
$sw=$words{$n};
print "hi $n, tell proper codeword\n";
$code=<STDIN>;
chomp($code);
while($code ne $sw)
{
print "hey your code is not matching, try once again!!!\n";
$code=<STDIN>;
chomp($code);
}
print "howdy $n!!!, welcome to party\n";
}
abhilash@abhilash:~$ perl pgm7.pl
whats your partner??
abhilash
hi 4294967295, you can enjoy night !!!!!
abhilash@abhilash:~$
abhilash@abhilash:~$ perl pgm7.pl
whats your partner??
sony
hi 4294967295, you can enjoy night !!!!!
its not checking for other inputs also, i even tried substituting eq instead of =, but din't work.....