[EMAIL PROTECTED] wrote: > > On Fri, Nov 16, 2001 at 06:00:42AM -0500, Sherri shaped the electrons to read: > > > > Please tell me if this is the correct program for making attribute codes. In this >program I need to do like a form with an employee's name, age, position and start >date. This is the way I wrote it. Please tell me what is missing or incorrect. > > > > #!/usr/bin/perl -w > > use strict; > > $name_field = 0; $age_field = 1; $position_field = 2; $start_date = 3; > > @employee = ("John Doe", 32, "Software Engineer", "10/12/2000"); > > print "Name: ", $employee[$name_field]; > > Actually what you really need is a hash not an array ... > %employee = ( 'name'=>'John Doe' , 'age'=>32 , 'position'=>'SE' , >'start_date'=>'10/12/2000' ); > > for my $field (%employee) { ^^^^^^^^^ This will flatten the hash to a list of alternating keys and values.
for my $field ( keys %employee ) { print "$field: $employee{$field}\n"; } John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]