#!/usr/bin/perl

$var="foo foofoo";

@matches = ( $var =~ /(?<!foo)foo/g );

print "@matches";
