use File::Path qw(make_path); open (my $infile, '<', 'file') or die "cannot open file: $!"; binmode ($infile); make_path ('./extracted'); my $curpos = ''; my $fileLocation = ''; my $fileSize = ''; my $fileName = ''; my $file =''; my $chunk = ''; my $empty = ''; #GET File Location, File Size, File Name and write to file seek ($infile, 0x10, 0); until ($curpos =~ 0x04c0){ $curpos = tell $infile; seek ($infile, $curpos, 0); read ($infile, $fileLocation, 0x08); $curpos = tell $infile; seek ($infile, $curpos, 0); read ($infile, $fileSize, 0x08); $curpos = tell $infile; seek ($infile, $curpos, 0); read ($infile, $fileName, 0x20); $curpos = tell $infile; $fileLocation =~ s/(.)/sprintf("%02x",ord($1))/eg; $fileSize =~ s/(.)/sprintf("%02x",ord($1))/eg; $fileName =~ s/\0+$//; open($file, '>', "extracted/$fileName") or die "Cannot open $fileName + $!"; binmode($file); sysseek ($infile, hex($fileLocation), 0); sysread ($infile, $chunk, hex($fileSize)); syswrite ($file, $chunk); $fileLocation = ''; $fileSize = ''; };
In reply to Re^2: problem with sysseek in loop
by james28909
in thread problem with sysseek in loop
by james28909
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |