| | |
Illegal hex digit
Please support our Perl advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved |
•
•
Join Date: Apr 2009
Posts: 8
Reputation:
Solved Threads: 0
Hello,
I have this code of converting hexadecimal value to decimal but getting a warning at compilation. I'm starting to learn Perl and this one really makes me - almost - crazy!
---
---
When I try to compile it:
Sproky: $ perl hexoct2dec2.plx
Please enter a hexadecimal value to be converted to decimal: 30
Illegal hexadecimal digit '
' ignored at hex2dec2.plx line 11, <STDIN> line 1.
The value in decimal is: 48
Anyone to shed some light please??
I have this code of converting hexadecimal value to decimal but getting a warning at compilation. I'm starting to learn Perl and this one really makes me - almost - crazy!

---
perl Syntax (Toggle Plain Text)
#!/usr/bin/perl use strict; use warnings; my $decVal; print "Please enter a hexadecimal value to be converted to decimal: "; $decVal = <STDIN>; print "The value in decimal is: ", hex($decVal), "\n";
---
When I try to compile it:
Sproky: $ perl hexoct2dec2.plx
Please enter a hexadecimal value to be converted to decimal: 30
Illegal hexadecimal digit '
' ignored at hex2dec2.plx line 11, <STDIN> line 1.
The value in decimal is: 48
Anyone to shed some light please??
Last edited by sprok; Apr 19th, 2009 at 10:10 am. Reason: typo
Do I really have to sign here? Is it ok if I'll use my right hand, instead?!
•
•
Join Date: Apr 2009
Posts: 8
Reputation:
Solved Threads: 0
Worked like a charm! Thanks.
I asked a colleague (when I posted this, I'm at home, so never had the chance) I was told that it removes the "extra" character "\n" as I press Enter. Noted!
I asked a colleague (when I posted this, I'm at home, so never had the chance) I was told that it removes the "extra" character "\n" as I press Enter. Noted!
Do I really have to sign here? Is it ok if I'll use my right hand, instead?!
![]() |
Similar Threads
- Hex string to char (C++)
- I've got Trojan.Holax... is this bad? (Viruses, Spyware and other Nasties)
- not-a-virusadware (Viruses, Spyware and other Nasties)
Other Threads in the Perl Forum
| Thread Tools | Search this Thread |





