Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: print format

by ctilmes (Vicar)
on Apr 22, 2003 at 16:03 UTC ( #252302=note: print w/replies, xml ) Need Help??


in reply to print format

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 .

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://252302]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (7)
As of 2021-05-17 15:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Perl 7 will be out ...





    Results (157 votes). Check out past polls.

    Notices?