The latest version of this hack is lang2


Convert Arc strings to Perl

(def escape-perl-string (s)
  (ac-scheme:regexp-replace* "[\\\\']" s "\\\\&"))

(def strperl (s)
  (if (ac-scheme:bytes? s)
       ((ac-scheme bytes-append) #"'" (escape-perl-string s) #"'")
       (string                   "'"  (escape-perl-string s) "'")))

strperl converts an Arc string to a Perl string literal that, when used in a Perl program or read with Perl’s eval function, will result in a string in Perl that contains the same value as the original Arc string.

arc> (do (prn (strperl "What's this?"))
'What\'s this?'

Get this hack

Download toperl0.arc and also get the hacks it relies on: scheme-values and ac.

Or, using the hackinator:



This code is in the public domain.

Contact me

Twitter: awwx
Email: andrew.wilcox [at]