#!/usr/bin/perl -w use strict; open(my $in,"/Users/Desktop/Pipelines/fungi.1.aa.hypothetical.faa"); open(my $out,">Users/Desktop/Pipelines/fungi.1.aa.hypothetical50.faa"); local $/ = undef; my @chunks = split(/>/, <$in>); my @hypothetical50 = @chunks[0..49]; for my $hypothetical50(@hypothetical50){ if($hypothetical50 =~ s/^gi/>gi/g){ print $out "$hypothetical50\n"; } } close($in); close($out);