in reply to Reg Exp Help

$input = "AR12CR32LC85AR16"; @fourbytes= unpack("A4" x (length($input)/4), $input);

Fast.

-Waswas
Edited, whoops missed the example data with spaces in it, this only works for the first example data, but it is damn fast.

Replies are listed 'Best First'.
Re: Re: Reg Exp Help
by bart (Canon) on Aug 28, 2002 at 20:09 UTC
    @fourbytes= unpack("A4" x (length($input)/4), $input);
    Careful: this will strip spaces of the end of each string. Use "a4" instead of "A4" as a template to prevent that.
      ++, nice catch.

      -Waswas
Re^2: Reg Exp Help
by Aristotle (Chancellor) on Aug 28, 2002 at 19:22 UTC
    I believe the bit with spaces in it was sample output data, not sample input data, so your post works. Plus it is the canonical way to do this kind of thing, so ++

    Makeshifts last the longest.