Loop Control

An example for using the last command

This program extracts the sequence from a GenBank entry.

Input file: genbank_entry.txt
Output file: genbank_seq.txt

#!/usr/bin/perl

my $input_file = "genbank_entry.txt";
my $result_file = "genbank_seq.txt";

open (IN, $input_file) || die "cannot open \"$input_file\": $!";
open (OUT, ">$result_file") || die "cannot open \"$result_file\": $!";

while ($line = <IN>) {
   print OUT $line;
   last if $line eq "ORIGIN\n";
}


Table of Contents.
Previous | Next.