I'm not sure how you define C-style string, do you have a proper specification?

Anyway, if your main worry is that Perl is doing interpolation, you could try to escape the $ and @ in the string

Though I have to admit I had problems with your full string so I shortened it...

This is only a stub, one would have probably also have to deal with already escaped $ and @ too.

use v5.12; use warnings; use Data::Dump qw/pp dd/; my $scl ="XXX"; my @arr = 1..3; # my $raw = <<'___'; # \r\n\t\tHello\tWorld\uFF00\\0\\n\\n\\!!\\"--->\\xf3\\"abc\\x4\\2\\8\ +\­2 # ___ my $raw = <<'___'; \r\n\t\tHello\tWorld $scl@arr ___ chomp $raw; dd $raw; $raw =~ s/(\$|\@)/\\$1/g; my $str = eval qq("$raw"); dd $str; # probably better done with unpack printf "%02X ",ord($_) for split //,$str;

"\\r\\n\\t\\tHello\\tWorld\n\$scl\@arr" "\r\n\t\tHello\tWorld\n\$scl\@arr" 0D 0A 09 09 48 65 6C 6C 6F 09 57 6F 72 6C 64 0A 24 73 63 6C 40 61 72 7 +2

Cheers Rolf
(addicted to the 𐍀𐌴𐍂𐌻 Programming Language :)
Wikisyntax for the Monastery


In reply to Re: C style strings by LanX
in thread C style strings by harangzsolt33

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.