open(INPUT, "< ./vrsticni_fonti.txt") or die "Couldn't open ./vrsticni_fonti.txt for reading: $!\n"; my $line; while () { $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