in reply to C style strings

Back when I was using C a lot (before Unicode) strings were just arrays of char which are 8 bit unsigned integers.

So a 12 character string like "Hello world\n" is the 13 element array 72 101 108 108 111 32 119 111 114 108 100 10 0

The Linux ascii man page lists the C escape sequences:

    007   7     07    BEL '\a' (bell)
    010   8     08    BS  '\b' (backspace)
    011   9     09    HT  '\t' (horizontal tab)
    012   10    0A    LF  '\n' (new line)
    013   11    0B    VT  '\v' (vertical tab)
    014   12    0C    FF  '\f' (form feed)
    015   13    0D    CR  '\r' (carriage ret)

Which are the same in Perl except for \v which Perl doesn't use.

Naked blocks are fun! -- Randal L. Schwartz, Perl hacker

Replies are listed 'Best First'.
Re^2: C style strings
by kcott (Archbishop) on Dec 31, 2022 at 21:07 UTC

    G'day jwkrahn,

    The following is just a point of clarification; it's not intended as a correction.

    "Which are the same in Perl except for \v which Perl doesn't use."

    Actually, Perl does use \v; you can't use it to insert a VT, but you can use it to detect one. See "perlrebackslash: All the sequences and escapes":

    ... \v Match any vertical whitespace character. ...

    This was introduced in Perl v5.10: "perl5100delta: Vertical and horizontal whitespace, and linebreak".

    I don't know for certain, but I imagine this is unavailable in the "TinyPerl 5.8" being used by the OP.

    $ perl -we 'print "abc\vdef\n"' Unrecognized escape \v passed through at -e line 1. abcvdef $ perl -we 'print "abc\x{0b}def\n"' abc def

    — Ken