Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
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: (16)
As of 2014-12-18 12:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (51 votes), past polls