Create a Perl script to store the information in Excel

Hello,
--------------------------------------
id name address
1 cristine New York
2 murray Redmond
3 kumar Sunnyvale
--------------------------------------

This is 'samples.xlsx' file.
'id' string in A1, 'name' in B1, 'address' in C1 column in excel file.

Create a Perl script to store the information about employee using the header as in raw 1. The Perl script should be able to provide data of any employee using the id or name or address. For example: If I need details that who is the person lives in Sunnyvale, the Perl script should give me back the result as Kumar.

*What data structure you have used and why?
*Try out usage of GetOptions in Perl script...?
*How can I manage duplicate data if any?

Please help me and answer me..

Questions by Cristine Thine

Showing Answers 1 - 1 of 1 Answers

elavv

  • Aug 10th, 2011
 

You can construct one hash where the the emp id as key to the hash and rest of the elements as values in the structure of array ref.

Code
  1. #!<SHEBANG LINE HERE>

  2. 'INPUT_FILE.xls'#my $sheet = ($xls->sheets)[2]; # Sheet 1

  3. #my $data = ($sheet->next_row)[-1]; # last col of row 1

  4. ">"'.xml'$!

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions