Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: More on hex pack/unpack

by httptech (Chaplain)
on Jun 26, 2000 at 20:20 UTC ( [id://19872]=note: print w/replies, xml ) Need Help??


in reply to More on hex pack/unpack

Ok, I took the good image and looked at it in a hex editor... Looks like your data is truncated, because the following works for me:
print "Content-type: image/gif\n\n"; print Image(); sub Image { my $image = '4749463839610f001000a2ff00848684' . 'dfe0dfc6c7c6c0c0c000000000000000' . '000000000021f90401000003002c0000' . '00000f00100040034048baacf3608049' . 'a98824ca0aae78d9b375a4164a92470e' . '016a8dde10721c48dfc029ee528b0ac0' . 'e06717121a8132cd6729b4ed8cc4c891' . '97a45a09b286569100003b00'; return(pack("H*",$image)); }
So the problem must lie in the unpack code.

Replies are listed 'Best First'.
RE: Re: More on hex pack/unpack
by BBQ (Curate) on Jun 26, 2000 at 20:33 UTC
    I have come to the source of my problem... STAY AWAY FROM ACTIVESTATE! I have 5.005_03 installed on both of my test machines, one running linux the other running NT 4.0. Guess what?

    The unpack code only truncates under the NT 4.0 machine. Same image source, same everything. #*$%^@ ActiveState distro! I'm going to install DynamicPerl now! Thanks for the helping hand, httptech!

    Code for unpacking (thanks mdillon) here:
    #!/usr/bin/perl open IMG, "foo.gif" or die "Couldn't open image: $!\n"; undef $/; $image = <IMG>; $hex = unpack("H*", $image); close IMG; while ($txt = substr($hex,0,32,'')) { print "'$txt'\n"; }


    #!/home/bbq/bin/perl
    # Trust no1!
      It's too late to help you, but I just got an advisory warning that the latest versions of ActiveState Perl are seriously broken.

      So, yeah, it looks like avoiding them for a while might be a very good thing.

      - Ozymandias

      Update: Here's the text; not an official advisory, but a warning from someone I know and trust:

      Activestate Perl 5.6 build 613. Stop! If you haven't downloaded this version of Perl for Windows. DON'T! The Perl Package Manager (PPM) section is fatally broken. If you don't need the ability to install or update modules I guess you can go ahead and download this. But otherwise. DON'T. Yes, they have a "Hotfix" that updates PPM to version 1.1.4. But it doesn't work. The PPM commands install, verify, update, search, and query do not work both before and after installing the "fix". What's worse is that Activestate has known of these problems for at least two months but is not saying a thing about it on their website (except for what is displayed on the bug tracking server). If I were them, I would immediately pull this distribution and wait until all of the problems were resolved rather than letting people blindly download this thinking it is a stable release. An extreme WTF experience.

      Since I got the warning, I've heard again from him that other things are broken; although he didn't mention pack or unpack, it wouldn't surprise me a bit if there's even more screwed up than he mentioned.

        Would you care to send me a copy? Most of my development machines at work run on NT Workstation with ActiveState. It would be nice to know what's going on in advance. (just checked ActiveState's site and came up with zero).

        Updated too:
        Ok, so it seems this applies to 5.6 only. I have found a few odd features in the past with activestate (this binmode unpack was a new one though). We are currently using build 522 (5.005_03), so the above doesn't really apply. Nevertheless, I'm going to give Dynamic Perl a shot. I'm dropping the "better the devil you know" philosofy for a new chance at getting something more stable.

        #!/home/bbq/bin/perl
        # Trust no1!
      i've only used Perl under Windows a couple times, but i believe this can be fixed by calling binmode on IMG before anything reads from it.
        Damnit you guys are good... Yup, that works also. Then again, calling binmode on linux worked as well. SO I guess its just a matter of calling binmode whenever regardless of the platform.

        #!/home/bbq/bin/perl
        # Trust no1!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://19872]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2024-04-24 19:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found