Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^4: Regex in json: escaping forward slash

by mhearse (Hermit)
on Aug 22, 2012 at 23:37 UTC ( #989169=note: print w/ replies, xml ) Need Help??


in reply to Re^3: Regex in json: escaping forward slash
in thread Regex in json: escaping forward slash

Thanks for your reply. I made a poor assumption. I was under the impression that:

my $regex = ".*/home/members/index.htm.*"; if (/$regex/)
Was the same as
if (/.*/home/members/index.htm.*/)
Which would fail. I was wrong!


Comment on Re^4: Regex in json: escaping forward slash
Select or Download Code
Replies are listed 'Best First'.
Re^5: Regex in json: escaping forward slash
by davido (Archbishop) on Aug 22, 2012 at 23:42 UTC

    perlop (Gory Details of Parsing Quoted Constructs): "The most important Perl parsing rule is the first one discussed below: when processing a quoted construct, Perl first finds the end of that construct, then interprets its contents."

    m// is a quoted construct. So the "end" will be found before the contents are interpreted (including interpolated). Now if you say, "m/a/b/", the problem is that the end is found between 'a' and 'b'. But when you say, $c='/', and then m/a${c}b/, the end is found after 'b', and later the interpolation of $c takes place.


    Dave

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (11)
As of 2015-07-31 11:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (276 votes), past polls