Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re^3: Left padding a number with zeros: PerlFaq method didn't work for me.

by McDarren (Abbot)
on Jan 17, 2006 at 04:46 UTC ( [id://523667]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    $padded = sprintf("%${pad_len}s", $text);
    
  2. or download this
    $padded = sprintf("%04d", $text);
    
  3. or download this
    #!/usr/bin/perl -w
    use strict;
    ...
    my $padded2 = sprintf("%${pad_len}s", $string2);
    
    print "|$padded1|\n|$padded2|\n";
    
  4. or download this
    |     12345|
    |1234567890|
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (1)
As of 2024-04-25 02:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found