#!/usr/bin/perl -w use strict; use warnings; my $test = "abc"; my $count = 1; while ($test =~ m/([abc]{$count})/) { my $match = $1; ++$count; printf "%s\n", $match; }