Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^3: pack() returns an unusable string

by tybalt89 (Prior)
on May 26, 2021 at 23:29 UTC ( #11133098=note: print w/replies, xml ) Need Help??


in reply to Re^2: pack() returns an unusable string
in thread pack() returns an unusable string

OP said error only happens on D<, not d<, which doesn't run on my machine.

However, here is a number for which the error occurs on 5.32 with d<

#!/usr/bin/perl -l use strict; use warnings; my $template = 'd<'; my $nv = 2.4; $nv = 4135; # NOTE errors for this number my $p = pack $template, $nv; my $s = "'$p'"; print ">$s<\n"; system $^X, '-wle', "print unpack('H*', $s);";

Outputs:

>''@'< Can't find string terminator "'" anywhere before EOF at -e line 1.

which shows that my guess that the pack produces a single quote character is plausible.

Replies are listed 'Best First'.
Re^4: pack() returns an unusable string
by choroba (Archbishop) on May 27, 2021 at 09:54 UTC
    In blead, it runs with D< and fails with
    Can't find string terminator "'" anywhere before EOF at -e line 1.

    However, when I tried to output

    say join ', ', map ord, split //, $p;
    I got
    0, 152, 153, 153, 153, 153, 153, 153, 0, 64, 0, 0, 0, 0, 0, 0

    map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (6)
As of 2021-12-01 12:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    R or B?



    Results (6 votes). Check out past polls.

    Notices?