in reply to pack() returns an unusable string
Parameters can't contain the NUL character. Your so-called working code breaks if you change 2.4 to 2.5 (which generates at least one a NUL byte).
I recommend that you pass the hex of the packed string. You could also use base64, JSON, etc, etc, etc.
Furthermore, you have a code-injection bug. "'$p'" is not an appropriate way to generate a Perl string literal. $p could easily contain byte 0x27 (single quote). A trailing byte 0x5C (backslash) would also be problematic.
I recommend that you pass the value as an argument.
use strict; use warnings; my $template = 'd<'; my $nv = 2.5; my $p = pack $template, $nv; system $^X, '-wle', 'print $ARGV', unpack('H*', $p);
Seeking work! You can reach me at firstname.lastname@example.org
|Replies are listed 'Best First'.|
Re^2: pack() returns an unusable string
by syphilis (Bishop) on May 29, 2021 at 08:53 UTC