#!/usr/bin/perl -w my $string = "more than one part\nanother sentence more than"; sub getone { qr/(more)/ } sub gettwo { qr/(than)/ } my @array = $string =~ /(\s@{[ getone() ]}\s@{[ gettwo() ]})/g;