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