$names12[$i]=@myNames[$i].','; #should be $names12[$i]=$myNames[$i].',';

Actually there's lots more issues in your program than this one. Its really a case of if you want to solve this properly, don't start from where you are at present! :-)

Why are you splitting on tabs when you indicated you wanted to split out words before? The answers given in your previous question do things much more efficiently than your code, so what is wrong with them?

Please give an example of the text you want to split and what you want it to look like at the end

Something roughly like this will put all your data in @names12:

# execute as perl -n program.pl < myTextFile #!/usr/bin/perl # get the words from current text block and push into array.... while (/(\w+)/g) { push @names12, $1; } END { # your array contains words, now add comma to printout print join(',', @names12); }
If you spot any bugs in my solutions, it's because I've deliberately left them in as an exercise for the reader! :-)

In reply to Re^3: text to array by space_monk
in thread text to array by torres09

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.