Line 23: printf is not the operator to use ( Perl is not C ). Use print with a trailing newline where appropriate(or, with a recent version of Perl, say)

You'll find this ( sorta' ) works:

for (@ID,@ISIN,@SYMBOL, "\n",) { print "$_:"; } ...

That's a really ugly hack and produces many lines containing only a single colon.

Nonetheless, for part one, see printf and compare to print.

For part two, writing a coherent set of suggestions about the other problems (unnecessary use of arrays which you then route thru a foreach; failing to give your series of "ifs" an escape route (better, perhaps, an if, two elsifs and an else); etc.; would take more time than I have just now. [<update> Besides, muba did a fine job on most of it while I was still fiddling. </update>] Sorry, but perhaps you can infer (or read docs) how this works:

#!/usr/bin/perl use 5.014; sub getValue { my ($value, $name); # $name is a throwaway; why? $_ = shift; ( $name, $value ) = split(/:/); $value =~ s/\s//g; return $value; } print "ID SYMBOL ISIN\n"; while (<DATA>) { my ($ID,$ISIN,$SYMBOL); if ($_ =~ m/ID:/) { $ID = getValue($_); $ID = $ID . ":"; # append colon removed by split chomp $ID; print $ID; } elsif ($_ =~ m/Symbol:/) { $SYMBOL = getValue($_); chomp $SYMBOL; $SYMBOL .= ":"; # alternate method to append colon print $SYMBOL; } elsif ($_ =~ m/ISIN:/) { $ISIN = getValue($_); chomp $ISIN; print $ISIN ."\n"; } else { next; } } __DATA__ Deleted; see careless OP's request in node below and +, as msgd to me: "Sorry for bothering you sir. But could you please change the data on +node : http://www. perlmonks.org/? displaytype= displaycode; node_id= +976512 to : http://www. perlmonks.org/? displaytype= displaycode; nod +e_id=991009 , appreciate it! !prod data"

output:

ID SYMBOL ISIN QYQ:LUP2L100OHM:SE0004017929 R1M:TLS2K50OHM:SE0004018539 QNF:MINILONGOMXAO:SE0003990183 QX8:ALF2K160OHM:SE0004017440 NC0:BOL2K170OHM:SE0003842137 NEV:NOK2K90OHM:SE0003843069

OP or OP's management seems to believe one can make things disappear from the internet.

Wrong. Can you spell "cache" or "waybackmachine?"

OP also seems to think I have some hold over kenosis, as evidenced by this message (verbatim), also received by me:

"kamchez says Re Re: matching strings into array from txtfile and printing on same line

kenosis, could you please change all of the "data" to dummy data as follows, the reason is that the current data is important production data that shouldn't be online (my fault) and that my employer wants it removed asap "


In reply to Re: matching strings into array from txtfile and printing on same line by ww
in thread matching strings into array from txtfile and printing on same line by kamchez

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.