[prog] Perl error

Almut Behrens almut-behrens at gmx.net
Fri Jan 28 08:44:19 EST 2005


On Thu, Jan 27, 2005 at 06:04:21PM +0000, David Sumbler wrote:
> I recently downloaded uni-vga from
> http://www.inp.nsk.su/~bolkhov/files/fonts/univga/ .
> 
> To create the required fonts I have to run 'make'.  This calls a perl
> script, but I get a repeated error.  The error messages consist of
> lines such as:
> 
> Character in 'c' format wrapped in pack at ./bdf2psf.pl line 45, <BDF> line 991.
> 
> After a lot of experimenting, I have narrowed the problem down.  The
> script contains a sub-routine with the line:
> 
> $bitmaps[$encoding] .= ByteOf((hex(substr($_, 0, 2))) >> $BBxoff0x*1);
> 
> I find that hex(substr($_, 0, 2)) produces an ASCII representation of
> a byte value in decimal.
> 
> The sub-routine ByteOf() reads:
> 
> sub ByteOf($)
> {
>     return pack("c", $_[0]);
> }
> 
> The error appears to be produced by this sub-routine whenever the
> value passed (in ASCII) is greater than 127.


To get rid of the error, you'll need to put a capital C (=unsigned char)
into pack's format specification, i.e. 'pack("C", $_[0])'.

The original author probably simply did not realize this minor error,
as older versions of Perl did not complain in this case, while newer
versions (>5.8) do.
(The result should be the same in both cases, though.)

Cheers,
Almut



More information about the Programming mailing list