sub some_module_code { my $arg = shift; warn "Some custom warning about $arg"; } my @w = warns { some_module_code("foo"); }; is grep({/\bSome custom warning\b/i} @w), 1; is grep({/\bUse of uninitialized value\b/i} @w), 0;