[Israel.pm] What is happening here (or -why) ?
Levenglick Dov-RM07994
RM07994 at freescale.com
Mon Jun 7 03:33:52 PDT 2010
You might want to consider evaluating $input once, as it doesn’t seem to change.
Best Regards,
Dov Levenglick
SmartDSP OS Development Leader
From: perl-bounces at perl.org.il [mailto:perl-bounces at perl.org.il] On Behalf Of Yuval Kogman
Sent: Monday, June 07, 2010 13:04
To: Perl in Israel
Subject: Re: [Israel.pm] What is happening here (or -why) ?
On 7 June 2010 11:44, Yossi Itzkovich <Yossi.Itzkovich at ecitele.com> wrote:
When I give the input: "$input" (without the quotes) it finds nothing.
$ is matched as the end of line assertion.
BTW, if you want to match a literal $ every time (i.e. fgrep semantics), match this pattern:
/\Q$input\E/
or use quotemeta()
But when I give "\$input" it finds all "input", even in line 15.
i can't reproduce this with your script. it matches other lines though:
Enter a pattern:\$input
chomp (my $input=<STDIN>);
#print "input=$input.\n";
print if /$input/;
but of course these all contain literal $'s
More information about the Perl
mailing list