Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Hex Error Code

by xenchu (Friar)
on Dec 14, 2003 at 23:26 UTC ( #314712=perlquestion: print w/replies, xml ) Need Help??
xenchu has asked for the wisdom of the Perl Monks concerning the following question:

While drifting around the Monastery I read some mention of the Config module. Since I had not looked at it before I decided to check it out. To cut to the chase I found a sample program in the module and decided to run it. I copied it to gedit, saved it and ran it as follows:

perl -c configure.pl (My name for the program, of course.)

I got the following response:

Unrecognized character \xE2 at configure.pl line 12.

Of course I looked at the program again and saw no srange characters. I have left out the shebang line and a comment line at the top of the program. Here is the program:

use Config; use strict; my %sig_num; my @sig_name; unless($Config{sig_name} && $Config{sig_num}) { die "No sigs?"; } else { my @names = split \’ \’, $Config{sig_name}; @sig_num{@names} = split \’ \’, $Config{sig_num}; foreach (@names) { $sig_name[$sig_num{$_}] \|\|= $_; } } + print "signal #17 = $sig_name[17]\n"; if ($sig_num{ALRM}) { print "SIGALRM is $sig_num{ALRM}\n"; }

Sorry, this software program seems unable to print single quotes and pipes properly. My question then, is how do I locate this mysterious character? I realize that I could probably just delete the line and re-type it, but I would rather fix the problem. Besides, next time it might be something serious.

Thanks,

xenchu

Update: Thanks pg, let me give that a try...whoa! that compiles! That's great! How did you find out what the strange characters were? I am using 5.8.0 btw.

Update2:Thanks, ysth. Another valuable lesson learned.


The Needs of the World and my Talents run parallel to infinity.

Replies are listed 'Best First'.
Re: Hex Error Code
by pg (Canon) on Dec 14, 2003 at 23:38 UTC

    This is not a straight copy of the code in doc, and I saw strange chars like \ and \|. Here is the code copied from 5.8.1 (The original code says split on space):

    use Config; use strict; my %sig_num; my @sig_name; unless($Config{sig_name} && $Config{sig_num}) { die "No sigs?"; } else { my @names = split ' ', $Config{sig_name}; @sig_num{@names} = split ' ', $Config{sig_num}; foreach (@names) { $sig_name[$sig_num{$_}] ||= $_; } } print "signal #17 = $sig_name[17]\n"; if ($sig_num{ALRM}) { print "SIGALRM is $sig_num{ALRM}\n"; }
Re: Hex Error Code
by ysth (Canon) on Dec 14, 2003 at 23:55 UTC
    Try adding this to the beginning of your file:
    use Data::Dumper; $Data::Dumper::Useqq = 1; print Dumper <DATA>; __DATA__
Re: Hex Error Code
by shelob101 (Sexton) on Dec 15, 2003 at 04:02 UTC
    I know this is not a perl based solution but in general, when there is "unprintable character weirdness" in any text file or program script I am working with, I find the unix utility "od" to be very helpful. It provides an octal dump (or decimal, or hexadecimal in some versions) of each and every byte of the argument file. You can use it like this:
    $ od -c <filename>
    which will produce output similar to:
    $ od -c innkeeper.pl 00000 # ! / u s r / l o c a l / b i n 00020 / p e r l \n \n u s e F i l e : 00040 : s t a t ; \n u s e F r e e z 00060 e T h a w q w ( f r e e z e 00100 t h a w ) ; # I m p o r t 00120 f r e e z e ( ) a n d t h a 00140 w ( ) \n \n % l i s t = ( ) ; \n \n 00160 $ A R G V [ 0 ] o r d i e 00200 " u s a g e : $ 0 d a t a f 00220 i l e \ n " ; \n \n o p e n ( I 00240 N , s h i f t ) ; \n \n w h i l 00260 e ( $ o b j = < I N > ) { \n 00300 c h o m p ( $ o b j ) ; \n ( 00320 $ s , $ s o ) = t h a w ( $ o b 00340 j ) ; \n p r i n t " $ s = 00360 > " , " " . l o c a l t 00400 i m e ( $ s o - > m t i m e ) , 00420 " \ n " ; \n } \n
    You can see the decimal value of unprintable characters, and some common ones are given the well-known names like \n and \t, etc. Hope this may help in the future.
    When there is no wind, row.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://314712]
Approved by pg
help
Chatterbox?
[Corion]: "Unmatched ) in regex; marked by <-- HERE in m/(&#9583;&# 9633;)&#9583;&# 65077; &#9531;&#9473;&# 9531;) <-- HERE / at -e line 1." :)
[Corion]: Meh - my "flip the table" string doesn't render here ;)

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (8)
As of 2018-07-17 16:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?















    Results (372 votes). Check out past polls.

    Notices?