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[0]', unpack('H*', $p);
Seeking work! You can reach me at ikegami@adaelis.com
In reply to Re: pack() returns an unusable string
by ikegami
in thread pack() returns an unusable string
by syphilis
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |