Hi,
I have been reading "Learning Perl the Hard Way" and I was trying to complete one of the exercises which involved the use of regular expressions. I could get all of the anchors working except for "$". I have my code below with errors. I was just curious if someone could take a look at it for me. Thank you for your time--rgpii
#!/usr/bin/perl
use strict;
use warnings;
my $pattern = "(g$)";
my @fileargs = @ARGV;
foreach my $argument (@fileargs)
{ print "File Handle--> $argument\n";
my $fhandle = $argument;
open FILE,$fhandle;
while (my $line = <FILE>)
{ print "Printing Line --> $line\n";
if($line =~ m/$pattern/)
{
print "Pattern Matched!--> $line\n";
}
}
}
Here are my errors:
Final $ should be \$ or $name at ./grep.plx line 4, within string
syntax error at ./grep.plx line 4, near "= "(g)$""