Hi Monks,
I have a little program file that's meant to search itself for lines which contain a specific word which is the first word in line 3 (ie $testVar).
For some reason it does not work.
Anyone clues as to how to make this work?
### this file is called regex.pl
my $testVar;
$testVar = "January";
### read this file
open(FH,"<regex.pl") or die "cannot open file";
my @myself = <FH>;
close(FH);
### make $pattern: $testVar
$myself[2]=~/([^ ]+)/;
my $pattern = $1;
print "Pattern: $pattern\n";
### print lines with this pattern
for(@myself)
{
print if /$pattern/;
}
Thanks.