lamar211us
2007-03-13 10:14:49 UTC
Text File:
CPAN stands for comprehensive Perl Archive Network.
^ and $ are used as anchors in a regular expression.
/pattern/ is a pattern match operator.
Perl is very easy to learn.
Enter 'H' or 'h' for help.
#!/usr/local/bin/perl
open INPUT, "
{
my($line) = $_;
chomp($line);
if ($line =~ m\b\^p*\bi) {print "$&\n";}
if ($line =~ m/p$*/i) {print "$&\n";}
else {print "No match, sorry.\n";}
}
close INPUT;
The output is supposed to be:
Perl
pattern
pattern
Perl
help
But I only get:
P
p
p
P
p
How do I make the program print out the whole word?