Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
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 drinking their drinks and smoking their pipes about the Monastery: (21)
As of 2014-10-30 15:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (208 votes), past polls