Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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

In reply to Re^2: pack() returns an unusable string by syphilis
in thread pack() returns an unusable string by syphilis

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • 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.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (3)
As of 2024-04-26 02:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found