http://qs321.pair.com?node_id=11133098


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 (Cardinal) 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]