in reply to Validating User Input

It appears in your code that you set $bool to undef if the regex does match. Do the elements in @_ describe input that you want to keep, or that you want to reject?

In any case, your code will accept or reject based only on the last element of @_. If the regex matches, $bool will be undef, and if the regex doesn't match, $bool will be true, regardless of how all the previous regexes turned out.

As soon as you know you want to accept/reject input, you should last out of the loop. For example:

sub getline { my $line = <>; chomp $line; if (@_) { my $reject; for (@_) { if ($line =~ /$_/) { $reject = 1; last; } } $line = undef if $reject; } return $line; }