If you used strict and warnings then you'd probably see output from your code along the lines of:

Line: 0xf0 0x0f 0x01 0x02 0x03 0x04 0x05 0x06 Extracted numbers : 0xf0|0x0f|0x01|0x02|0x03|0x04|0x05|0x06 Argument "0xf0" isn't numeric in bitwise and (&) at c:\test\junk.pl li +ne 12, <> line 1. Argument "0x0f" isn't numeric in bitwise and (&) at c:\test\junk.pl li +ne 12, <> line 1. Argument "0x01" isn't numeric in bitwise and (&) at c:\test\junk.pl li +ne 12, <> line 1. Argument "0x02" isn't numeric in bitwise and (&) at c:\test\junk.pl li +ne 12, <> line 1. Argument "0x03" isn't numeric in bitwise and (&) at c:\test\junk.pl li +ne 12, <> line 1. Argument "0x04" isn't numeric in bitwise and (&) at c:\test\junk.pl li +ne 12, <> line 1. Argument "0x05" isn't numeric in bitwise and (&) at c:\test\junk.pl li +ne 12, <> line 1. Argument "0x06" isn't numeric in bitwise and (&) at c:\test\junk.pl li +ne 12, <> line 1. Changed fonts : 0|0|0|0|0|0|0|0

Which would identify that whilst Perl knows to convert hex encoded barewords in source code into numbers, it does not automatically do the same for hex strings read in from external sources. Ie. The problem lies with your data parsing not the code I posted.

The simplest fix is to use the built-in hex function to convert them to numbers:

open(INPUT, "< ./vrsticni_fonti.txt") or die "Couldn't open ./vrsticni_fonti.txt for reading: $!\n"; my $line; while (<INPUT>) { $line = $_ ; print "Line: $line \n"; # my @rows = ( 0x04, 0x04, 0x04, 0x04, 0x00, 0x00, 0x04, 0x00 ); my @rows = ($line =~ m/(0x[a-fA-F0-9]+)/g); ## convert the hex strings to numbers. @rows = map hex, @rows; print "Extracted numbers : " . join("|", @rows) . "\n"; my @cols = (0) x 8; for my $c ( 0 .. 7 ){ $rows[ $_ ] & 1 << $c and $cols[ $c ] |= 1 << $_ for 0 .. 7; } print "Changed fonts : " . join("|", @cols) . "\n"; # printf "0x%02x\n", $_ for @cols; } close(INPUT); __END__ Line: 0xf0 0x0f 0x01 0x02 0x03 0x04 0x05 0x06 Extracted numbers : 240|15|1|2|3|4|5|6 Changed fonts : 86|154|226|2|1|1|1|1

Note: The extracted numbers now display as numbers and the transformed output is no longer zeroes.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
"Too many [] have been sedated by an oppressive environment of political correctness and risk aversion."

In reply to Re^3: Font bitmaps manipulation in perl (transposing row like font description to column like).... by BrowserUk
in thread Font bitmaps manipulation in perl (transposing row like font description to column like).... by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.