CrazyDiamond has asked for the wisdom of the Perl Monks concerning the following question:
Output for single row in file is like that:@fields_from=qw|field1 field2 field3 field4 field5 field6 field7 field +8 field9 field10 field11 field12 field13|; ### <FROM> is a text file with 13 field, separated by ';;' while ($tmpline = <FROM>) { chomp ($tmpline); $tmpline =~ s/\s*(\d+);;(.+);;\s*(\d+);;\s*(\d+);;\s*(\d+);;\s*(\d+ +);;\s*(\d+);;\s*(\d+);;\s*(\d+);;(.+?)\s*;;\s*(.*?)\s*;;\s*(\d+);;(.+ +)\s*/"$1", "$2", "$ 3", "$4", "$5", "$6", "$7", "$8", "$9", "$10", "$11", "$12", "$13"/; ### Pattern always match. @data_from = $tmpline; @from{@fields_from} = @data_from; #Problem is here? while (($key, $value) = each %from) { print "$key => $value\n"; }
... same for all, exept field1 ! So, why all data in @data_from goest to first element of hash, why its not splitted between all elements?field1 => "33", "GS4", "24", "34", "4", "24034004", "1183031", "407785 +", "1", "cc", " zz", "0", "xx" Use of uninitialized value in concatenation (.) or string at ./script. +pl line 159, <FROM> line 2. field2 => Use of uninitialized value in concatenation (.) or string at ./script. +pl line 159, <FROM> line 3. field3 =>
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Troubles with building a hash slice
by BrowserUk (Patriarch) on Jan 16, 2008 at 11:56 UTC | |
by CrazyDiamond (Initiate) on Jan 16, 2008 at 12:37 UTC | |
|
Re: [SOLVED] Troubles with building a hash slice
by dsheroh (Monsignor) on Jan 16, 2008 at 15:32 UTC | |
|
Re: Troubles with building a hash slice
by hipowls (Curate) on Jan 16, 2008 at 12:09 UTC |