Perhaps it's me - maybe I'm dumb and am getting this working solution wrong...
I have a binary value 00000011 in $binVal and I want to print the result in denary, so in perl I did as the perldoc -f oct told me to do and added a 0b prefix as so:
$binVal = "0b" . $binVal;
then I wanted to print the result, so I did:
print oct( $binVal );
If my binary calculations are right, I should get "3", instead I get "0" - why? where am I going wrong?
This is what I get on my Win32 machine at work when I tested out the previous code:
D:\>cat test.pl
$binVal = "000011";
$binVal = "0b" . $binVal;
print oct($binVal);
D:\>test.pl
3
D:\>perl -version
This is perl, v5.6.1 built for MSWin32-x86-multi-thread
(with 1 registered patch, see perl -V for more detail)
Copyright 1987-2001, Larry Wall
Binary build 633 provided by ActiveState Corp. http://www.ActiveState.com
Built 21:33:05 Jun 17 2002
Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.
Complete documentation for Perl, including FAQ lists, should be found on
this system using `man perl' or `perldoc perl'. If you have access to the
Internet, point your browser at http://www.perl.com/, the Perl Home Page.