use strict; use warnings; my $file = $ARGV[0]; open(my $fh, "<", $file) or die "Can't open $file: $!"; while ( <$fh> ) { chomp; # $_ is default input if ( /\>/ ) { # $_ is still default input, # match is default operation my @modify_line = split( /\s/ ); # $_ is still default input my $line = $modify_line[0]; # if you are going to use an array print $line; }