[comp.lang.perl] Bug on Sun 3's

abe@mace.cc.purdue.edu (Vic Abell) (04/06/91)

In article <MITCH.91Apr5134209@hq.af.mil> mitch@hq.af.mil (Mitch Wright) writes:
>This program works on my Sun386i (SunOS 4.0.2) just fine, but refuses to
>work on our Sun 3/180S under SunOS 4.1.
>#!/usr/gnu/perl
>print unpack("H2", pack("I", 97));

Try "H8" as the first unpack argument.  You're only printing the first
8 bits.  On my NeXT work station, "H8" produces:

	00000061

What's the byte ordering on a 180S?

Vic Abell, <abe@mace.cc.purdue.edu>

rbj@uunet.UU.NET (Root Boy Jim) (04/06/91)

In article <MITCH.91Apr5134209@hq.af.mil> mitch@hq.af.mil (Mitch Wright) writes:
?Well, 
?	I think I've found a bug, though I'm hoping that I've just done
?something wrong.

Your hope is justified.

?This program works on my Sun386i (SunOS 4.0.2) just fine, but refuses to
?work on our Sun 3/180S under SunOS 4.1.

No, it just works differently.

?#!/usr/gnu/perl
?#
?print unpack("H2", pack("I", 97));
?
?
?On the 386i it prints 61 as expected [by me at least].
?
?On the Sun 3/180, it prints 00.

One is Big Endian, the other Little Endian.

To see the difference, change "H2" to "H2H2H2H2"
and run on both machines.
-- 
		[rbj@uunet 1] stty sane
		unknown mode: sane