foreach my $file (@files){ my @arr=split(/\//,$file); print "\n $arr[2];"; }