#!/usr/bin/perl
#------------------------------------------
# Read characters from file1, and
# write to file2, where character# is between
# $start and $end
#------------------------------------------
$file1 = $ARGV[0];
$file2 = $ARGV[1];
$size1 = -s $file1 ;
# modify below settings, for different ranges to extract
$start1 = 100 ;
$end1 = 200 ;
open(FILE1,"<$file1") or die "Input file: Cannot open file1\n\n";
open(FILE2,">>$file2") or die "Input file: Cannot open file2\n\n";
binmode FILE1 ;
binmode FILE2 ;
$i = 0 ;
while ($i < $size1 )
{
$i ++ ;
$ch = getc(FILE1);
if (($i >= $start1) && ($i <= $end1))
{
print FILE2 $ch ;
}
}
close(FILE1);
close(FILE2);
|
|