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[0]', unpack('H*', $p);
Seeking work! You can reach me at ikegami@adaelis.com
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: pack() returns an unusable string
by syphilis (Archbishop) on May 29, 2021 at 08:53 UTC | |
by ikegami (Patriarch) on May 29, 2021 at 23:19 UTC | |
by syphilis (Archbishop) on May 30, 2021 at 08:46 UTC | |
by ikegami (Patriarch) on May 31, 2021 at 17:58 UTC | |
by syphilis (Archbishop) on May 31, 2021 at 23:31 UTC | |
| |
by ikegami (Patriarch) on May 31, 2021 at 01:10 UTC |