R
Robert
Hi,
I'm building a small subroutine that will check many variables at once for
certain matches and then take action based on it's results. Currently I am
doing it like this:
if ($name =~ /XXX/ || $email =~ /XXX/ || $inquiry =~ /XXX/ || $phone =~
/XXX/ || $comments =~ /XXX/) { &terminate; }
The the above check the 5 variables for "XXX" and if ANY of them contain
"XXX" goes to sub routine &terminate. I would like to know if there is a
more efficient/cleaner way of doing this with less code. While the above
checks 5 variables, my real script checks 22 which maks for a really long
line of code. Is there a better way to do this? For example (not real code):
if ($name,$email,$inquiry,$phone,$comments =~ /XXX/) { &terminate; }
That of course isn't real code but its cleaner and easier to manage. Thats
what I'm looking for, a better way to match many variables.
Thanx all, much appriciated.
Robert
I'm building a small subroutine that will check many variables at once for
certain matches and then take action based on it's results. Currently I am
doing it like this:
if ($name =~ /XXX/ || $email =~ /XXX/ || $inquiry =~ /XXX/ || $phone =~
/XXX/ || $comments =~ /XXX/) { &terminate; }
The the above check the 5 variables for "XXX" and if ANY of them contain
"XXX" goes to sub routine &terminate. I would like to know if there is a
more efficient/cleaner way of doing this with less code. While the above
checks 5 variables, my real script checks 22 which maks for a really long
line of code. Is there a better way to do this? For example (not real code):
if ($name,$email,$inquiry,$phone,$comments =~ /XXX/) { &terminate; }
That of course isn't real code but its cleaner and easier to manage. Thats
what I'm looking for, a better way to match many variables.
Thanx all, much appriciated.
Robert