Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Re: Re: print format

by pfaut (Priest)
on Apr 22, 2003 at 16:26 UTC ( #252310=note: print w/replies, xml ) Need Help??


in reply to Re: Re: print format
in thread print format

Use a temporary variable. Set it to the value to print before entering the loop. After the first print in the loop, set it to an empty string. This assumes that the loop will produce at least one line of output.

my ($print_accession) = sprintf("%08s",$accession); foreach (@accession) { ... $item1=...; $item2=...; printf("%8s%16s%8s\n",$print_accession,$item1,$item2); $print_accession = ""; }

If you don't like your strings right aligned in their field, use '%-16s' - the minus indicates the field should be left aligned. See perldoc -f sprintf for details on the available formats.

90% of every Perl application is already written.
dragonchild

Log In?
Username:
Password:

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

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





    Results (74 votes). Check out past polls.

    Notices?