On Aug 10, Tim McGeary said:
>follow-up question: will this only be true if $item of @array is
>completely empty? This is the type of data for each $item of @array:
>
>ID, name_f, name_l, email, id, contact, group, member
>
>I am splitting this by commas into different $scalers to manipulate.
>And I know that same of these fields are empty (to which I need to
>report back to the people sending me the data). It will NEVER happen
>that a whole line is empty, but just one or two of the fields in each line.
I don't see how this changes things, really. This is how I would do
things:
my @field_names = qw( ID name_f name_l email id contact group member );
my %long_names;
@[EMAIL PROTECTED] = (
'ID', 'First Name', 'Last Name',
'Email Address', 'id', 'Contact', 'Group', 'Member',
);
while (<INPUT>) {
chomp;
my %record;
@[EMAIL PROTECTED] = split /,/;
if (my @empty = grep length $record{$_} == 0, @field_names) {
empty_fields(@empty);
}
else {
# process record
}
}
Where the empty_fields() function would do something like:
sub empty_fields {
my $msg = "You left these fields empty: ";
$msg .= join ", ", @[EMAIL PROTECTED];
# displays $msg to the user somehow
}
--
Jeff "japhy" Pinyan % How can we ever be the sold short or
RPI Acacia Brother #734 % the cheated, we who for every service
http://japhy.perlmonk.org/ % have long ago been overpaid?
http://www.perlmonks.org/ % -- Meister Eckhart
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>