open ( my $input_fh, "<", $input_file ); open ( my $output_fh, ">", $output_file ); foreach my $line ( <$input_fh> ) { ########## i have to use regex here to first see if this line start with a HDR - correct? then if it does i would do a substring to delete the first 50 and write the rest to the output file else write the entire line to output similarly check if it starts with EDR and substring again ########## } close ( $input_fh ); close ( $output_fh );