Beefy Boxes and Bandwidth Generously Provided by pair Networks Bob
Perl Monk, Perl Meditation
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

I could give you hints and try to string you along, but for a self-professed newbie to Perl, sometimes a good example is more instructive than coming up with a sub-optimal solution of your own:

use warnings; use strict; my @fh; # Store filehandles open $fh[@fh], '<', $_ or die "Can't open `$_': $!" for <1039418/*.tx +t>; while (1) { no warnings qw/uninitialized io/; my $line; $line .= <$_> // "\n" for @fh; last if $line =~ /^\n*$/; # All files finished or blank $line =~ s/\n(?!\z)/,/g; # Delimit with commas, except for last +\n print $line; }

The challenge to you, james4545, is to take this and understand it. Break it apart. Figure out why each statement does what it does. Put it back together in a different way. Ask specific questions. Thoroughly read the documentation for each of the functions, plus perlop and perlre. Watch an episode of Futurama and then code it (this example, not Futurama) yourself from scratch without looking. Meditate on the beauty of =~ . Have a @π[1..3]. And then so shall you follow the path of a Perlmonk.

Or, by all means, copy/paste this code and move on. As much as we like to see others walk the monastic path, we monks tend to be a self-satisfied bunch.


In reply to Re: arrange output in columns by rjt
in thread arrange output in columns by james4545

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!
  • 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, 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, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            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.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others examining the Monastery: (11)
    As of 2014-04-21 15:15 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      April first is:







      Results (495 votes), past polls