G'day DAVERN,

Welcome to the monastery.

You originally wrote:

"i need the next result

xxx=DATA00, xxx=DATA10, xxx=DATA20; "

This is easy:

#!/usr/bin/env perl -l use strict; use warnings; while (<DATA>) { next unless /^DATA/; print 'xxx=', join(', xxx=' => split), ';'; } __DATA__ TABLE NAME HEAD0 HEAD1 HEAD2 DATA00 DATA10 DATA20 DATA01 DATA11 DATA21 END

Output:

xxx=DATA00, xxx=DATA10, xxx=DATA20; xxx=DATA01, xxx=DATA11, xxx=DATA21;

You then showed some unformatted code:

"print {$OUT} "xxxxx", $data[0], "yyy", $data2,";","\n";"

Guessing that's supposed to be:

print {$OUT} "xxxxx", $data[0], "yyy", $data[2],";","\n";

This is only slightly less easy. Just change the print line to:

print 'xxxxx', join('yyy' => (split)[0,2]), ';';

Output:

xxxxxDATA00yyyDATA20; xxxxxDATA01yyyDATA21;

Please give careful consideration to what you are attempting to achieve before posting. You'll find monks may be less inclined to help if you keeping changing what you want.

Your code for opening files seems absolutely fine. Change <DATA> to <$your_input_filehandle> and print ... to print {$your_output_filehandle} ... and that should do what you want.

-- Ken


In reply to Re: text processing by kcott
in thread text processing by DAVERN

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.