On Wed, Nov 16, 2011 at 03:32:03PM +0100, Georg Moritz wrote:
> golfed down a bit, just for fun...
> 
> #!/usr/bin/perl -l
> @ARGV or die "No args";
> print"$_: ",($_=unpack"B*",pack"N",$_)=~s/0+//?$_:$_ for@ARGV;

That should be s/0*//, otherwise you'll get the wrong result for numbers
above 2147483647.

Ronald

P.S. Golfed further:
#!/usr/bin/perl -l
print"$_: ",(unpack"B*",pack N,$_)=~/(1.*)/for@ARGV?@ARGV:die"No args"

Reply via email to