Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: number formatting

by aquacade (Scribe)
on Aug 08, 2001 at 19:10 UTC ( [id://103080]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    Left padding a string with blanks (no truncation:
    $padded = sprintf("%${pad_len}s", $text);
    ...
    $padded = sprintf("%0${pad_len}d", $num);
    # Right padding a string with blanks using pack (will truncate):
    $padded = pack("A$pad_len",$text);
    
  2. or download this
    $padded = $pad_char x ( $pad_len - length( $text ) ).$text;
    $padded = $text . $pad_char x ($pad_len - length($text));
    
  3. or download this
    substr($text, 0, 0)=$pad_charx($pad_len-length($text));
    $text .= $pad_char x ($pad_len - length($text));
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (4)
As of 2024-04-16 04:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found