This is a very simple and non-critical question. I have some programming background eons ago (starting with FORTRAN, that's how long ago) and am working on learning some basics of perl coding using Simon Cozen's Beginning Perl. Chapter 2 assignments include writing a simple program to interpret an integer entry (<STDIN>
) and printing the decimal integer equal to the number. I have Windows 7. When the integer is entered, the program outputs the warning
Illegal hexadecimal digit '
' ignored at [path] line [the line containing the print instruction], <STDIN> line 1
Then it does print the correct hex number.
The code is
$number = <STDIN>;
print hex($number), "\n";
When I change the program to output an octal I don't get the warning.
The warning says the illegal digit occurs at the print line even though it references the STDIN line. Does it have to do with the enter key? If so, why does the oct version of the same program not have a problem?
The problem is that $number
has the line terminator in it still; use chomp
to remove it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With