in reply to retriving info from a csv file in Tk
Assuming everything else in place the above code should read a file and give you two arrays, one of names one of IDs.require Text::CSV; my $csv = Text::CSV->new; open( FH, "<$fh" ) || die "Error: no open for $fh: $!"; foreach (<FH>) { if ( $csv->parse($_) ) { my @field = $csv->fields; my ( $Emp_ID, $Emp_Name ) = @field; push(@id, $Emp_ID); push(@names, $Emp_Name); } } # end foreach close(FH);
More esteemed monks can I am sure point out better ways of doing this, I'm sure. I justy wated to give an example of Text::CSV for you to look at.
Lance
Kia Kaha, Kia Toa, Kia Manawanui!
Be Strong, Be Brave, Be perservering!
|
|---|