#!/usr/bin/perl -- use strict; use warnings; use Path::Tiny; my( $inFile, $outFile ) = @ARGV; my $outfh = path( $outFile )->openw_raw; my $infh = path( $infile )->openr_raw; while( my $line = <$infh>){ chomp $line; if ($line =~ /\>/) { my @modify_line = split(/\s/,$line); $line = $modify_line[0]; } print $outfh "$line\n"; } close $infh; close $outfh;