Path: utzoo!attcan!utgpu!news-server.csri.toronto.edu!rutgers!uwm.edu!zaphod.mps.ohio-state.edu!samsung!munnari.oz.au!metro!usage.csd.unsw.oz.au!spectrum!cameron From: cameron@usage.csd.oz (Cameron Simpson,foo) Newsgroups: comp.lang.perl Subject: Re: unpack and endianness Message-ID: <885@usage.csd.unsw.oz.au> Date: 6 Oct 90 12:25:00 GMT References: <9821@jpl-devvax.JPL.NASA.GOV> Sender: news@usage.csd.unsw.oz.au Reply-To: cameron@spectrum.cs.unsw.oz.au (Cameron Simpson) Distribution: comp Organization: none Lines: 17 From article <9821@jpl-devvax.JPL.NASA.GOV>, by lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall): | In article thoth@reef.cis.ufl.edu (Gilligan) writes: | :Is there any way to specify the endiannes of the data you are unpacking? | | There's no way to do this with unpack on a big-endian machine at the moment. | The best you can do, as far as I can see, is to say | sub swab { | $_[0] =~ s/([\0-\377])([\0-\377])/$2$1/g; | } [...] Um, why can't I write sub swab { $_[0] =~ s/(.)(.)/$2$1/g; } - Cameron Simpson, cameron@spectrum.cs.unsw.oz.au