# assume $regex has been built with qr// and matches what you want my $regex = qr/foobar/; # assuming $data contains all the data you want to scan from my @things_im_interested_in = ( $data =~ /($regex)/g ); # or, if it isn't and you are doing this from multiple data # strings push @things_im_interested_in, $data_chunk =~/($regex)/g;