Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Using '#' at the beginning of a format?

by Marshall (Prior)
on Jan 10, 2013 at 12:44 UTC ( #1012651=note: print w/ replies, xml ) Need Help??


in reply to Using '#' at the beginning of a format?

When I first saw the Perl format thing, I thought it would be very cool. Well as it turns out, using printf() is usually far better for any kind of normal report.

#!/usr/bin/perl -w use strict; my @stuff = qw( large 90.12 small 12.34 medium 57.78 super 75.0 ); print "# Name Price\n", "# ---- -----\n"; while (my ($name,$price) = splice (@stuff,0,2)) { printf "%10s %8.2f\n", $name, $price; } __END__ Prints: # Name Price # ---- ----- large 90.12 small 12.34 medium 57.78 super 75.00


Comment on Re: Using '#' at the beginning of a format?
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (14)
As of 2015-07-07 15:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (90 votes), past polls