#!/usr/bin/perl $file0="54252-05.paz"; $outfile0="54252-05.gz"; $file1="54-252.rez"; $outfile1="54-252.gz"; open(IN, "$file0"); open(OUT, "> $outfile0"); binmode(OUT); while () { if($_ =~ /^S3/){ $num=hex(substr($_,2,2))*2-10; print OUT pack("H$num",substr($_,12,$num)); } } close(OUT); close(IN); open(IN, "$file1"); open(OUT, "> $outfile1"); binmode(OUT); while () { if($_ =~ /^S3/){ $num=hex(substr($_,2,2))*2-10; print OUT pack("H$num",substr($_,12,$num)); } } close(OUT); close(IN);