[Wellington-pm] program using <STDIN> giving error.

Daniel Pittman daniel at rimspace.net
Sun Aug 27 23:44:00 PDT 2006


"David Benton" <davidthebenton at gmail.com> writes:

> Hi people i'm a some what inactive member of this list but am having a
> problem and as I'm still just learing perl its pretty basic but I was
> wondering if someone could help me out with this and tell me what the
> problem is...

[...]

> 	my $hex = <STDIN>;

This reads the newline at the end of the input as well as the number.

[...]

> 	Illegal hexadecimal digit '
> 	' ignored at hex2dec.plx line 14, <STDIN> line 1.

This shows you the illegal character.

[...]

> If you could tell me whats wrong it would be appreciated.

You need to use chomp, or chop, to strip the trailing character off your
input.  Read the documentation on those two, because they are somewhat
different, and understanding why helps choose the right one.

Regards,
        Daniel
-- 
Digital Infrastructure Solutions -- making IT simple, stable and secure
Phone: 0401 155 707        email: contact at digital-infrastructure.com.au
                 http://digital-infrastructure.com.au/


More information about the Wellington-pm mailing list