in reply to Re: Re: Untainting 'bad' filenames
in thread Untainting 'bad' filenames

That ensures that the value of $1 from a successful match does not leak outside the block, but it doesn't protect you from $1 from an earlier successful match leaking into the block:
#!/usr/local/bin/perl -w use strict; $_ = 'perlmonks.org'; for my $re (qw/monks minks/) { /(perl)/; print "$1\n"; { # new block for regex /($re)/; print "$1\n"; } } __END__ perl monks perl perl
It's generally necessary to check whether a regex succeeded before using any of the regex special variables.