Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
I stuck your test data into a structure purely for an example. Concentrate on the loops and the format/write. Fill in your own logic for setting $accession, $item1 and $item2.
my %accession = ( '1223455' => [ { item1 => 'abdkek', item2 => 'akdjeg' }, { item1 => 'ksitjls', item2 => 'jsoirl' }, { item1 => 'lsiet', item2 => 'oliut' } ], '2874824' => [ { item1 => 'lsiugl', item2 => 'potpsgj' }, { item1 => 'postis', item2 => 'potltids' } ], '1375080' => [ ], '0875709' => [ { item1 => 'llskgjo', item2 => 'ooiwuto' } ], '9876653' => [ { item1 => 'lsgjgdlk', item2 => 'ldkgjldj' } ] ); my ($accession, $item1, $item2); foreach $accession (sort keys %accession) { #.... if (not scalar @{$accession{$accession}}) # no items { $item1 = $item2 = ''; write; next; } foreach my $itemset (@{$accession{$accession}}) { # Do whatever you want to set $item1, $item2 $item1 = $itemset->{item1}; $item2 = $itemset->{item2}; write; $accession = ''; # blank for subsequent prints } } format STDOUT_TOP = Accession item1 item2 . format STDOUT = @<<<<<<<<<<<<< @<<<<<<<<<< @<<<<<<<<< $accession, $item1, $item2 .

In reply to Re: print format by ctilmes
in thread print format by Anonymous Monk

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, 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
  • 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.
  • 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 browsing the Monastery: (3)
    As of 2021-05-07 20:07 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?
      Perl 7 will be out ...





      Results (93 votes). Check out past polls.

      Notices?