Hello!
CAN I DELETE OR CLOSE THAT POST?
Answer is: push @data_from, $tmpline =~ /\".*?\"/g;
I'm trying to build a hash slice, but something goes wrong, could you please check it? (It's my 1st post at perlmonks, sry if something's incorrect)
@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"; }
Output for single row in file is like that:
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 =>
... 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?

In reply to [SOLVED] Troubles with building a hash slice by CrazyDiamond

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.