Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

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

by injunjoel (Priest)
on Jun 23, 2005 at 22:18 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://469548]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (4)
As of 2024-04-20 10:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found