Let me give yall a better explanation of what i am trying to do, i already have the byte reversing done so no need to read a file backwards, but i can open both files before the byte reversal like this:
use File::Slurp;
open my $in_file, '<', "file";
binmode($file);
open ( my $out_file, '>', "reversed" );
binmode($out_file);
my ( $buf, $data, $n, $bytes );
while (( $n = read $in_file, $data, 4096 ) != 0 ) {
syswrite $out_file, pack( "v*", unpack("n*", $data ));
$bytes+=$n;
}
this above code will successfully read a file then byte reverse it to the other file, but you have to have a file on disk to do it.
now, what i want to be able to do, is open the $in_file, then byte reverse it in memory, and then write it to file after reversing it, or in other words, byte reverse the file in memory, then do whatever i want with it.
use File::Slurp;
open ( my $in_file, '<', "file" );
binmode( $file );
my $temp;
open my $mem_file, '>', \$temp;
binmode( $mem_file );
my ( $buf, $data, $n, $bytes );
while (( $n = read $in_file, $data, 4096 ) != 0 ) {
syswrite $mem_file, pack( "v*", unpack("n*", $data ));
$bytes+=$n;
}
open ( my $out_file, '>', "reversed" );
binmode( $out_file );
syswrite ( $out_file, $mem_file );
i have tried a few different things and nothing has worked tho i am able to get the program to actually write the file, but it writes SCALAR(XXXXXXXX) or GLOB(XXXXXXXX) ect to the file and not the actual reversed data.