Sudarshan Raghavan wrote:
> Sachin Hegde wrote:
>
> > Hi,
> > There is this warning which I can't remove :
> >
> > Illegal hexadecimal digit '
> > ' ignored at test.pl line 131, <FH> line 23.
>
>
> It is the newline at the end
>
> >
> >
> > test.pl is the name of the program while FH is a file handle(read
> > only). Part of my code is:
> >
> > <129>     $ln = <FH>;
> > <130>     @flds = split(/ /,$ln);
>
>
> Change this to
> @flds = split (' ', $ln);
> perldoc -f split #Read about the difference between split (' ', ...) and
> split (/ /, ...)
>
> >
> > <131>     if($flds[5] =~ /[a-zA-Z]+/)            # Check for a hex number
> > <132>     {
> > <133>         $mtype = hex($flds[5]);
> > <134>     }

Also your check for a hex number is wrong - it will be successful if the
string contains at least one alpha character. Change this for

  if ($flds[5] =~ /^[a-z0-9]+$/)

or

  if ($flds[5] =~ /^[[:xdigit:]]+$/)

or

  if ($flds[5] !~ /[^[:xdigit:]]/)

Cheers,

Rob







-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to