Reputation: 7281
What is the most convenient way to extract a specified byte range of a file on disk into a variable?
Upvotes: 4
Views: 736
Reputation: 132920
Sometimes I like to use File::Map, which lazily loads a file into a scalar. That turns it into string operations instead of filehandle operations:
use File::Map 'map_file';
map_file my $map, $filename;
my $range = substr( $map, $start, $length );
Upvotes: 3