use strict; # I think " " is more what you intend than / / # see the split docs in perlfunc, and then # you also don't need to chomp it. for my $prev (split " ", $input) { print " -> $prev\n"; my $current=$prev; for my $find (@code) { chomp($find); if ($prev=~/$find/i) { print "$blink $cyan -> Logged \n"; print "$normal$green"; #HERE IS THE SPLIT PROBLEM AREA! my $tparse=split(/-/,$current); my $writer=$tparse[2]; my $writes=$#tparse; print "$cyan -> $prev \n $green"; # You had an error here which 'use strict' # also would've caught #print "$cyan -> $#writes \n $green"; print "$cyan -> $writes \n $green"; print "$cyan -> $writer \n $green"; last; } } }