I would guess that your packed string '$p' has either a single quote "'" in it or an escape or $ or @ at the end that eats the closing single quote
I should add that there's nothing special about the given NV value of 2.4.
The behaviour I'm seeing is happening for all NV values that I've tested.
To get a dump of $s:
# test.pl
use warnings;
use Devel::Peek;
$template = 'D<';
$nv = 2.4;
$p = pack $template, $nv;
$s = "'$p'";
Dump $s;
system $^X, '-wle', "print unpack('H*', $s);";
That outputs the following (which does, at least, contain an "@"):
C:\_32\pscrpt>perl test.pl
SV = PV(0x4bcf98) at 0x571248
REFCNT = 1
FLAGS = (POK,pPOK)
PV = 0x4b7e88 "'\232\231\231\231\231\231\231\231\0@\0\0\0\0\0\0'"\0
CUR = 18
LEN = 20
Can't find string terminator "'" anywhere before EOF at -e line 1.
But if I change the value of $nv to 2.4e100, I get:
C:\_32\pscrpt>perl test.pl
SV = PV(0x3ecf98) at 0x383348
REFCNT = 1
FLAGS = (POK,pPOK)
PV = 0x3e7e88 "'\vL\177v\257zb\206\264>\0\0\0\0\0\0'"\0
CUR = 18
LEN = 20
Can't find string terminator "'" anywhere before EOF at -e line 1.
Interestingly, changing the value to 3.1e-100 results in a different warning:
C:\_32\pscrpt>perl test.pl
SV = PV(0x26cf98) at 0x5311f8
REFCNT = 1
FLAGS = (POK,pPOK)
PV = 0x267e88 "'9\302\271\243\"\211\224\255\264>\0\0\0\0\0\0'"\0
CUR = 18
LEN = 20
Use of uninitialized value $_ in print at -e line 1.
Perhaps something to do with the internal double quote.
For a value of 13.16e-100, I get:
C:\_32\pscrpt>perl test.pl
SV = PV(0x38cf98) at 0x4c51b8
REFCNT = 1
FLAGS = (POK,pPOK)
PV = 0x387e88 "'\245^,\356\266\0208\270\266>\0\0\0\0\0\0'"\0
CUR = 18
LEN = 20
Can't find string terminator "'" anywhere before EOF at -e line 1.
Is there some way to pass the string returned by pack() to that system command ?
I assume that it ought to be possible, and that I'm just doing something dumb.
Cheers,
Rob
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.