On Aug 10, Tim McGeary said:

>Jeff 'japhy' Pinyan wrote:
>
>>   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
>>   }
>
>This makes my output unordered and extraneous.  I don't want to
>field_names to output, so I don't think a hash works for this.  But in
>its essense, it is what I need to do.  I just need to keep the
>field_names from outputting, too.  Just the data, in the same order I
>bring it in.

You could use an array instead of a hash, then.  But the output isn't
unordered if you make @field_names hold the names in the order you want
them used.

-- 
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>


Reply via email to