No, I meant print reverse($num)+0;, which extracts '1' from the integer 100, as the OP asked. He didn't ask about 52, 583, 47, or 32767, he asked about 100. ;)
Yours works too, of course. The difference being, yours works over any integer, and mine works for the integer 100, or any other integer where the leading digit contains a positive value and the subsequent digits are zero. But both extract 1 from 100.
He may also have meant all integers, or he may also have meant any integer with one leading significant digit and all trailing digits being zero. Or he may have meant only the integer 100, or maybe an integer beginning with 1 and followed by only zeros, or maybe he meant only positive integers, or maybe something else entirely, but he said an integer, 100. Any other assertion is guesswork.
Of course we're just having fun. Everyone knows the best way is this:
print shift @{[(split//,$num)[0-(@{[split//,$num]})]]}
|