To see your program as Perl sees it, deparse it:
c:\@Work\Perl\monks>perl -wMstrict -MO=Deparse,-p -e
"print 'Enter decimal number less than 256: ';
my $decimal;
$decimal=<STDIN>;
chomp $decimal;
print $decimal & 128 <=> 0;
print $decimal & 64 <=> 0;
print $decimal & 32 <=> 0;
print $decimal & 16 <=> 0;
print $decimal & 8 <=> 0;
print $decimal & 4 <=> 0;
print $decimal & 2 <=> 0;
print $decimal & 1 <=> 0;
"
BEGIN { $^W = 1; }
use strict 'refs';
print('Enter decimal number less than 256: ');
my($decimal);
($decimal = <STDIN>);
chomp($decimal);
print(($decimal & 1));
print(($decimal & 1));
print(($decimal & 1));
print(($decimal & 1));
print(($decimal & 1));
print(($decimal & 1));
print(($decimal & 1));
print(($decimal & 1));
-e syntax OK
See O and B::Deparse.
Update: Why does every expression like 128 <=> 0 become the constant 1? Because the Perl compiler, like most compilers today, is smart enough to know that the result of the comparison of a constant to a constant is just going to be yet another constant, 1 in all these cases. (Update: I believe this process is called constant folding.)
Give a man a fish: <%-(-(-(-<
|