Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Edits for the new information from the asker.</p> <p>If you just want to process the contents of all those files, this should work: </p> <pre><code>@ARGV = qw&lt;F1 f2 f3 f4&gt;; print "&lt;XML&gt;\n"; while ( my $line = &lt;&gt; ) { print " $line"; } print "&lt;/XML&gt;\n"; </code></pre> <p>Of course, you could just cat the files together if you cared as little about indentation as XML does--and bookend it with "\n" ... "\n".</p> <hr> <p>Name of the current file will be in <code>$ARGV</code> if you need it. Number of current record is in <code>$.</code> ( or via English: <code>$NR</code> or <code>$INPUT_LINE_NUMBER</code> ) </p> <h3>Merge</h3> <p>If you want to <em>merge</em> files, they need to be sorted ( <a href="http://search.cpan.org/perldoc?File::Sort" rel="nofollow noreferrer">File::Sort</a> ). And then you need to have a dedicated buffer to all the files you want to merge and scan for the lowest record based on the sorting scheme. If you choose that buffer, refresh it from that file, and process the buffer.</p> <p>Those steps are: </p> <ol> <li>Pick first in concatenation order</li> <li>Refresh from respective file, flag if EOF</li> <li>Process record</li> </ol> <p>I would create a <code>Buffer</code> as well as <code>BufferSet</code> class to encapsulate this functionality. The <code>Buffer</code> knows how to offer up the current record when asked, and to refresh from its IO source, when chosen. The <code>BufferSet</code> knows to look for next record from its list of Buffer objects and to handle the <code>Buffer</code> objects. The <code>BufferSet</code> object should definitely know the sorting order, and it might also handle the job of making sure that any buffer has been sorted.</p> <p>You can use <a href="http://search.cpan.org/perldoc?Class::Delegator" rel="nofollow noreferrer">Class::Delegator</a> to make the BufferSet behave like a straight IO object, if you wanted to do that. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload