Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Best practice on escapes in interpolated strings

by Skeeve (Vicar)
on Jul 29, 2013 at 11:35 UTC ( #1046845=note: print w/ replies, xml ) Need Help??


in reply to Best practice on escapes in interpolated strings

I, for some timenow, do it lke this:

"Page %(pg)d - Section %(sec)d - %(sec)s"

In a first step I extract from all the "%(something)" the "something" leaving just a % so that the examp string becomes:

"Page %d - Section %d - %s"

At the same time I push the "something"s onto an array.

I borrowed this syntax from python. The escaping should then simply be: Double the %:

%%(foo)

s$$([},&%#}/&/]+}%&{})*;#$&&s&&$^X.($'^"%]=\&(|?*{%
+.+=%;.#_}\&"^"-+%*).}%:##%}={~=~:.")&e&&s""`$''`"e


Comment on Re: Best practice on escapes in interpolated strings
Select or Download Code
Re^2: Best practice on escapes in interpolated strings (sprintfnamed)
by Anonymous Monk on Jul 29, 2013 at 11:49 UTC

      Thanks for this! Didn't even THINK of searching for that, but did it on my own.


      s$$([},&%#}/&/]+}%&{})*;#$&&s&&$^X.($'^"%]=\&(|?*{%
      +.+=%;.#_}\&"^"-+%*).}%:##%}={~=~:.")&e&&s""`$''`"e

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (5)
As of 2014-09-18 03:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (105 votes), past polls