If you don't actually care about the variable names, then a variation on
leronim's example might do the trick:
#!/usr/bin/perl -w
use strict;
use warnings;
my @varNames = qw { name vorname plz tel tel49 };
my @vars;
while (<DATA>) {
print;
chomp;
(@vars) = split /\s*,\s*/;
print "\t";
for my $var (@varNames) {
print $var, ":", shift @vars ? "good " : "bad ";
}
print "\n\n";
}
__DATA__
john, stuart, some_plz, 123456, 234557
john, stuart, some_plz, 123456,
john, stuart, some_plz, 123456
john, stuart, some_plz,, 234557
, stuart, , 123456, 234557
,,,123456, 234557
john,,some_plz,, 234557
Which prints:
john, stuart, some_plz, 123456, 234557
name:good vorname:good plz:good tel:good tel49:good
john, stuart, some_plz, 123456,
name:good vorname:good plz:good tel:good tel49:bad
john, stuart, some_plz, 123456
name:good vorname:good plz:good tel:good tel49:bad
john, stuart, some_plz,, 234557
name:good vorname:good plz:good tel:bad tel49:good
, stuart, , 123456, 234557
name:bad vorname:good plz:bad tel:good tel49:good
,,,123456, 234557
name:bad vorname:bad plz:bad tel:good tel49:good
john,,some_plz,, 234557
name:good vorname:bad plz:good tel:bad tel49:good
--
roboticus
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.