Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Interpolation in character class

by sandfly (Beadle)
on Oct 02, 2003 at 20:18 UTC ( [id://296067]=note: print w/replies, xml ) Need Help??


in reply to Interpolation in character class

The perlretut man page says "If you've been around Perl a while, all this talk of escape sequences may seem familiar. Similar escape sequences are used in double-quoted strings and in fact the regexps in Perl are mostly treated as double-quoted strings. This means that variables can be used in regexps as well. Just like double-quoted strings, the values of the variables in the regexp will be substituted in before the regexp is evaluated for matching purposes."

So the answer to your question is that your construction works because you would expect a double-quoted string to work that way. You could also use the octal excape syntax: /\A\020[^\020]/.

The reason \x{$a} doesn't work is the same reason that it doesn't work in a double-quoted string - probably that the double-quoted string interpolation mechanism is single-pass and not recursive. (This is only a guess.)

Log In?
Username:
Password:

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

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

    No recent polls found