foreach (@biglonglist) { if (/(thing1)misc stuff(thing2)random garbage(thing3)/) { $x->{a} = $1; $x->{b} = $2; $x->{c} = $3; } }