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

Re: Interpolation in character class

by sandfly (Beadle)
on Oct 02, 2003 at 20:18 UTC ( #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?

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

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (1)
As of 2022-01-23 03:15 GMT
Find Nodes?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:

    Results (63 votes). Check out past polls.