in reply to Re^3: Question about binary file I/O
in thread Question about binary file I/O

Okay, I fixed all the scope issues and stuff. It still doesn't work, though:
{ local $/ = \2; my $TileData = 0x0000; while(my $TileData = <$fhin>) { if(length($TileData) != 2) { warn "Warning: The input file had an uneven length. Last +byte read: $TileData."; last; } my $NewTileData = (($TileData & 0xFC7F) | ($GFXFileBits)); print {$fhout} $NewTileData; } }
$TileData is still a string instead of a number, so it doesn't work with the bitwise operators.

Replies are listed 'Best First'.
Re^5: Question about binary file I/O
by eyepopslikeamosquito (Archbishop) on Feb 06, 2011 at 07:18 UTC

    $TileData is still a string instead of a number, so it doesn't work with the bitwise operators.
    Well, of course it doesn't since my suggestions related to the file handling aspects of your code only (as I thought I made clear in my original response) because BrowserUk had already answered the bitwise operator aspects of your problem. Please re-read his answer and study the documentation for pack and unpack then show us your code and explain precisely why it doesn't do what you want it to.