Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^2: program cant find values that start with $

by LanX (Cardinal)
on Jan 31, 2020 at 02:25 UTC ( #11112152=note: print w/replies, xml ) Need Help??


in reply to Re: program cant find values that start with $
in thread program cant find values that start with $

Two different things!

Escaping the dollar means that variable interpolation won't happen and only literal '$zoek' can match.

quotemeta on the other hand escapes regex metas after inserting the content of $zoek

"zoek" is Dutch for "search" and is literal user input via Tk. But a $ in input is also a meta which needs to be quoted.

main::(-e:1): 0 DB<1> $x='.' DB<2> p 'a' =~ /$x/ 1 DB<3> p 'a' =~ /\Q$x/ DB<4> p '.' =~ /\Q$x/ 1 DB<5> p '.' =~ /$x/ 1 DB<6> p '.' =~ /\$x/ DB<7> p '$x' =~ /\$x/ 1 DB<8>

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

Replies are listed 'Best First'.
Re^3: program cant find values that start with $
by AnomalousMonk (Bishop) on Jan 31, 2020 at 08:32 UTC

    Another way to look at this is via the stringization of qr//:

    c:\@Work\Perl\monks>perl -wMstrict -le "my $x = '.'; print for qr{$x}, qr{\Q$x}, qr{\$x}, 'etc...'; " (?-xism:.) (?-xism:\.) (?-xism:\$x) etc...


    Give a man a fish:  <%-{-{-{-<

      Good point! ++

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://11112152]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (5)
As of 2020-10-26 16:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My favourite web site is:












    Results (252 votes). Check out past polls.

    Notices?