chanakya has asked for the wisdom of the Perl Monks concerning the following question:
CSV file format:use strict; use warnings; my $file = "/tmp/index.csv"; open (FL, "< $file"); while ($line = <FL>){ my ($country, $exchange, $name, $forex, $ric, $isin, $cusip) = +split(/\;/ $line); #similarly 100 vars are declared }
The first line of the CSV is the header. Using map function I want to dynamically assign the splitted values to the variables given in the header of CSV (Country;Exchange;NAME;Forex;RIC;ISIN;CUSIP;). i.e the final output should look like:##CSV file format Country;Exchange;NAME;Forex;RIC;ISIN;CUSIP; AT;XETRA (AT) ;RAIFFEISEN INTERNATIONAL BANK ;EUR;RIBH.VI +;AT0000606306; ;B0704T9; AT;XETRA (AT) ;IMMOEAST IMMOBILIEN ANLAGEN AG;USD;IMEA.VI +;AT0000642806; ;
I'd like some suggestions on how to dynamically map the splitted values in the above way.$Country = "AT"; $Exchange ="Xetra (AT)"; $NAME = "RAIFFEISEN INTERNATIONAL BANK "; #etc..
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Dynamically map the elements of CSV
by izut (Chaplain) on May 29, 2006 at 14:30 UTC | |
|
Re: Dynamically map the elements of CSV
by Tanktalus (Canon) on May 29, 2006 at 15:11 UTC | |
|
Re: Dynamically map the elements of CSV
by BrowserUk (Patriarch) on May 29, 2006 at 14:38 UTC | |
|
Re: Dynamically map the elements of CSV
by CountZero (Bishop) on May 29, 2006 at 19:33 UTC | |
|
Re: Dynamically map the elements of CSV
by tcf03 (Deacon) on May 29, 2006 at 15:00 UTC |