Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: Creating data delimited by ASCII code 1 using perl

by shmem (Chancellor)
on Jun 21, 2019 at 12:07 UTC ( [id://11101667]=note: print w/replies, xml ) Need Help??


in reply to Creating data delimited by ASCII code 1 using perl

ASCII code 1 (binary1),

ASCII code 1:

$\ = "\n"; # output record separator print "\x01"; # hex print "\001"; # octal print "\cA"; # control char print pack "C",1; # byte with the lowest bit set

You can use any of them with join and split.

perl -le'print map{pack c,($-++?1:13)+ord}split//,ESEL'

Replies are listed 'Best First'.
Re^2: Creating data delimited by ASCII code 1 using perl (updated)
by haukex (Archbishop) on Jun 21, 2019 at 13:20 UTC

    TIMTOWTDI Party? ;-)

    print "\x{0001}"; print "\N{U+1}"; print "\N{START OF HEADING}"; print chr(1); print v1; print "x"^"y"; vec(my $x,0,8)=1; print $x;

    Update: "x"^"y" only works if the new bitwise feature is off; it could be turned on implicitly by the -E switch or a use 5.028; or higher (thanks for pointing this out, davido!). When the bitwise feature is on, one has to use the new ^. operator instead. Also, \N{START OF HEADING} requires charnames to be loaded explicitly on Perls before 5.16.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (4)
As of 2024-04-19 02:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found