Just save your variables as values in a hash and use a simple grep:
It prints:#!usr/bin/perl my ($name, $vorname, $plz, $tel, $tel49); my %vars; while (<DATA>) { print; chomp; ($name, $vorname, $plz, $tel, $tel49) = split /\s*,\s*/, $_, -1; @vars{qw/name vorname plz tel tel49/} = ($name, $vorname, $plz, $t +el, $tel49); my @good = grep {$vars{$_}} keys %vars; printf " %s %s good\n", @good ? join ", ", @good : "No variables", @good == 1 ? "is" : "are"; } __DATA__ john, stuart, some_plz, 123456, 234557 john, stuart, some_plz, 123456, john, stuart, some_plz,, 234557 , stuart, , 123456, 234557 , , , , 234557 ,,,,
john, stuart, some_plz, 123456, 234557 tel49, vorname, tel, plz, name are good john, stuart, some_plz, 123456, vorname, tel, plz, name are good john, stuart, some_plz,, 234557 tel49, vorname, plz, name are good , stuart, , 123456, 234557 tel49, vorname, tel are good , , , , 234557 tel49 is good ,,,, No variables are good
In reply to Re: A Case with 5 Var's
by Ieronim
in thread A Case with 5 Var's
by ultibuzz
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |