for my $syn (@syntax) { my ($re, $cb) = @$syn; if (my (@matches) = ($line =~ $re)) { $cb->(@matches); last; } }