let me give an example:
use File::Slurp;
open ( my $file, '<', "file" );
binmode($file);
my @array = read_file ("pointers");
seek ( $file, 0x67, 0 );
print $file @array[0];
foreach ( my $line(@array){
chomp ( $line );
seek ( $file, 20, 0 );
print ( $file $this );
}
this is the code i have tried. it will write to the file, but not in an expected way. As you know i do most of my work/programs on binary files. so the data being pushed to the array will have to be written back to the file, but as byte characters/hexadecimal characters and in raw format.
so when it puts "29" into the array, i need it to write 29 in the raw file as a byte, and the code above writes it as a character 29 (which is 32 39 in plain text).
The open file is in raw or binary mode, but it writes in text mode from the array. i need to write in binary mode. if you run the script on the files i posted earlier, then you can make a file with this in it:
21
4B
A8
C6
and read that into an array, then try to write from the array to a raw file, it doesnt work, and looks to still write to the raw file in text mode. and if i try to binmode the array, it throws errors as expected.
im am very confused at this point, as i need to write the pointers back to the file but in raw/binary mode. and i am unsure how to do that from an array because it looks as if it writes back to a raw file in text mode.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.