Use \G to match rest of text
#!/usr/bin/perl use warnings; use strict; my $text = "3 2 1 abc"; if ($text =~ /\G\s*(.+)$/) { print ucfirst($1), "!\n"; }