From the keyboard of Ronald J Kimball [16.11.11,14:14]:
On Wed, Nov 16, 2011 at 07:49:14PM +0100, Olof Johansson wrote:
On 2011-11-16 11:57 -0500, Ronald J Kimball wrote:
No, you are wrong. s/0*// is sufficient, because /0*/ will always match at
the start of the string anyway.
rye
You're clearly an expert. I yield. Can you open a bug report with perl
and getting this fixed?
It's working as expected for me, so I'm not sure what needs to be fixed.
well... the ternary ?: isn't necessary with s/0*// because s/0*// is
always successful, so
print"$_: ",($_=unpack"B*",pack"N",$_)=~s/0*//&&$_ for@ARGV;
two strokes ;-)
but as Olof pointed out,
printf"$_:%b\n",$_ for@ARGV
is less convoluted. Why do I forget about printf almost always?
'cause I'm not a C hacker, but a heck parler, I guess ;-)
for some JAPH, see my signature. Latin-1 only, though
cheers,
0--gg-
% cat tmp.pl
#!perl -l
print"$_: ",($_=unpack"B*",pack"N",$_)=~s/0*//?$_:$_ for@_=@ARGV;
print"$_: ",($_=unpack"B*",pack"N",$_)=~s/^0*//?$_:$_ for@_=@ARGV;
% perl tmp.pl 2147483648 3000000000
2147483648: 10000000000000000000000000000000
3000000000: 10110010110100000101111000000000
2147483648: 10000000000000000000000000000000
3000000000: 10110010110100000101111000000000
%
Are you seeing different behavior?
Ronald
--
_($_=" "x(1<<5)."?\n".q·/)Oo. G°\ /
/\_¯/(q /
---------------------------- \__(m.====·.(_("always off the crowd"))."·
");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}