I am working with a Perl regular expression of this kind:

```
/(^.*)XXX/g

```

I want this regexp to match text of the type

```
******XXX****XXX***XXX

```

so that in this case the regexp would match three times and provide these results:

```
******XXX****XXX***
******XXX****
******

```

However, when I put this regexp in a list context like this

```
while($_=~/(^.*)XXX/g)

```

there's only one match and it is

```
******XXX****XXX***

```

Where am I going wrong?