in reply to perl bit matrix transposition / weak typing problem
Update: another way:
Just as background, in case it helps with your problem, note that perl's bitops have two different modes, numeric (where the scalar operands are numbers) and bitwise, where the operands are strings and the operation is done on each bit of each character. The numeric mode is triggered whenever either of the operands was set to a number or has been used in a numeric context. For example, 3|8 is 11, but "3"|"8" is ";". You can force one or the other regardless of where a scalar's been by replacing one of the operands, say $x, with (0+$x) to force numeric mode, or stringize both, so $x^$y becomes "$x"^"$y", to force bitwise mode. See perlop for more info.sub transpose { return if length $_[0] < $BUFSIZE; pack"B*",join"",(split//,unpack"B*",substr$_[0],0,$BUFSIZE)[map$_% +$BUFSIZE*$BUFSIZE+int($_/$BUFSIZE),0..$BUFSIZE**2-1] }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: perl bit matrix transposition / weak typing problem
by infi (Acolyte) on Dec 13, 2004 at 12:29 UTC | |
by ysth (Canon) on Dec 13, 2004 at 12:31 UTC | |
by infi (Acolyte) on Dec 13, 2004 at 13:16 UTC |