Q:

How to make expect command in Expect module of perl search for multiple occurences of same string

I have a scenario where i am using expect module of perl to automate terminal based applications.  I am passing a regular expression as an argument to the expect command as shown below
$ssh->expect(20, '-re',
    'Dev:(\d+)\W*Bdaddr:((?:[[:xdigit:]]{2}:){5}[[:xdigit:]]{2})\W*Name:' );

So i want to make the same regular expression search for multiple occurrences of the pattern within the string buffer that expect uses.  How can it be achieved. Also, I want to know how to capture those multiple occurrences. 

A:

Check whether this helps. 
use Expect;

my $Obj = Expect->new();

$Obj->spawn("/some/tst.bash");

$Obj->expect(undef,
    [ qr/(?:.*?Hello){2}/i, sub {
            my $Self = shift;
            print "Matched qr/.*?Hello.*?Hello/i..\n";
            exp_continue; }
    ]
);

And /some/tst.bash looks like this. 
echo "Hello!  This is for testing. ! Hello"

Basically the regex (?: .*?Hello){2} looks for anything/nothing followed by Hello twice.  So in essence the following too would have matched HelloHello

