if ($line =~ /v/) { # B M 5yrs Straphanger-Amy Hest Driver:...........u chomp $line; my ($trainer, $last_driver) = split //, $line; # Remove whitespaces from start $trainer =~ s/^\s+//; # Remove the first chars of variable $last_driver = substr($last_driver, 1); # Remove whitespaces from start $last_driver =~ s/^\s+//; print OUTPUT " $trainer $last_driver "; }