sub is_valid_pattern { my $pat = shift; return eval { "" =~ /$pat/; 1 } || 0; }