Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

Re: unpack() removing data

by shnatko (Initiate)
on Jan 11, 2013 at 19:51 UTC ( #1012967=note: print w/replies, xml ) Need Help??

in reply to unpack() removing data

the problem appears to be in the
$data = qx{sg_logs --page=0x34,1 pd1 -H -r };
line where the 0x0D byte which is part of the sg_logs result is getting stripped when sent to $data with the '=' operator is there a way to ensure the result from the qx{} is sent to $data as binary data without any interference? something like binmode but for '=' instead of for file handles?

Replies are listed 'Best First'.
Re^2: unpack() removing data
by BrowserUk (Pope) on Jan 11, 2013 at 20:14 UTC

    Instead of using qx//, use a piped open whereby you can binmode the handle before importing the data:

    open PIPE, '-|', 'sg_logs --page=0x34,1 pd1 -H -r' or die $!; binmode PIPE; my $data = do{ local $/; <PIPE> }; close PIPE;

    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
      thank you! this is exactly what I needed. looks to be working correctly now.

      thanks again

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1012967]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (3)
As of 2018-03-22 02:51 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (272 votes). Check out past polls.