Tim McGeary Senior Library Systems Specialist Lehigh University 610-758-4998 [EMAIL PROTECTED]
Jeff 'japhy' Pinyan wrote:
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 }
since I have this already: foreach $item (@banner_array) { my ($patron_id, $name_f, $name_l, $email, $disc_id, $contact, $pwd, $un, $group, $code) = split(/,/,$item);
can I just simply do:
if ($patron_id | $name_f | $name_l | ... eq '') { send to error log
???
| => OR, but maybe I'm not correct with that.
Tim
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>