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;
}
read(STDIN, $_, 2*2);
&swab($_);
($exp, $maxexp) = unpack("s2", $_);
: Also, what is the filehandle for <>, I hate having to type
: "moriainterp.perl < moria.dc".
It's ARGV, but you can't do a read() on it and keep the other semantics of <>.
You want something more like open(STDIN,shift).
Larry
Um, why can't I write
sub swab {
$_[0] =~ s/(.)(.)/$2$1/g;
}
- Cameron Simpson, cam...@spectrum.cs.unsw.oz.au
Because . doesn't match \n. [\0-\377] is the most efficient way to match
everything currently. Maybe \e should match everything.
And \E would of course match nothing. :-)
Larry
Goes back and Rs the FM more closely. Oh the embarrassment.
| [\0-\377] is the most efficient way to match
| everything currently. Maybe \e should match everything.
Nah. What's wrong with [^]?
| And \E would of course match nothing. :-)
Correspondingly, []. Haven't tried it yet (does so). Ouch. The ] at the
start of the pattern is taken as part of the range. A feature. Well, it
was a nice idea...
- Cameron Simpson
cam...@spectrum.cs.unsw.oz.au
"To every problem there is a simple, obvious, wrong solution."
How do you specify ] in a [^...] expression, then? You mention the same
problem with []...
---Dan
Um, why can't I write
sub swab {
$_[0] =~ s/(.)(.)/$2$1/g;
}
Basically, because it doesn't work. This swaps every pair of bytes,
but doesn't swap the byte pairs, etc. The goal is to turn ABCD into
DCBA.
Dale Worley Compass, Inc. wor...@compass.com
--
The great unsolved problem of feminsm is to decide whether we need to
make men more like women, or women more like men.
>Because . doesn't match \n. [\0-\377] is the most efficient way to match
>everything currently. Maybe \e should match everything.
>And \E would of course match nothing. :-)
>Larry
I would rather see \* match everything and \e be ESC as it is in
other utilities. And maybe \!* matches nothing? :-)
dml
Dale> In <98...@jpl-devvax.JPL.NASA.GOV> lw...@jpl-devvax.JPL.NASA.GOV
Dale> (Larry Wall) writes:
>Because . doesn't match \n. [\0-\377] is the most efficient way to match
>everything currently. Maybe \e should match everything.
>And \E would of course match nothing. :-)
>Larry
Dale> I would rather see \* match everything and \e be ESC as it is in
Dale> other utilities. And maybe \!* matches nothing? :-)
Dale> dml
Please do not create any non-alphanumeric metacharacters. It would
break the quoting of a pattern that might contain metacharacters using
$pattern =~ s/(\W)/\\$1/g;
--
Mark D. Baushke
m...@ESD.3Com.COM
But doesn't \* already mean "turn off the special meaning of *".
i.e. match only an asterix?
Cimarron Taylor
Electronics Research Laboratory / POSTGRES project
University of California, Berkeley
cima...@postgres.berkeley.edu
'Sides, there's millions of scripts out there that already use \* to mean
a literal *.
And \e doesn't mean ESC to me, it means \. What utilities does it mean
ESC in? /etc/termcap uses \E, which is close.
I HAVE considered making \a mean \007 (since K&R2 has it), but there's
gotta be a limit somewhere.
[Strange, that never stopped you before.]
Oh, shaddap!
Larry
| And \e doesn't mean ESC to me, it means \. What utilities does it mean
| ESC in? /etc/termcap uses \E, which is close.
Well, GNU Emacs does this, if you can call something its size a
"utility" :-)
Eric
--
Eric Peterson <> epet...@encore.com <> uunet!encore!epeterson
Encore Computer Corp. * Ft. Lauderdale, Florida * (305) 587-2900 x 5208
Why did Constantinople get the works? Gung'f abobql'f ohfvarff ohg gur Ghexf.
What's an asterix? Why would you want perl to match a cartoon character?