Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: passing qr//'d regexp via Perl/Tk Entry widget

by injunjoel (Priest)
on Jun 23, 2005 at 22:18 UTC ( #469548=note: print w/replies, xml ) Need Help??


in reply to passing qr//'d regexp via Perl/Tk Entry widget

Greetings,
I feel this has more to do with the binding operator  =~ than it does with your entry widgets get method. Here is the perlop snippet that makes me think so. clipped for clarity
...``=~'' binds a scalar expression to a pattern match. ... (If the right argument is an expression rather than a search pattern, substitution, or transliteration, it is interpreted as a search pattern at run time.

So if you simply type in "foo" you get a match since the  =~ seems to be treating it as /foo/ by default.
One workaround might be to strip off the "qr/" and trailing "/" prior to the match.
Here is an example of the behavior
#!/usr/bin/perl -w use strict; my $string = "foobarbaz"; my $exp = "foo"; if($string =~ $exp){ print "without /'s works fine"; }elsif($string =~ /$exp/){ print "with /'s is needed"; }else{ print "WTF!??"; }

This outputs
without /'s works fine
-InjunJoel
"I do not feel obliged to believe that the same God who endowed us with sense, reason and intellect has intended us to forego their use." -Galileo

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (7)
As of 2020-08-03 15:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Which rocket would you take to Mars?










    Results (27 votes). Check out past polls.

    Notices?