Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Generating standard length strings

by Corion (Patriarch)
on Apr 14, 2005 at 19:04 UTC ( [id://447917]=note: print w/replies, xml ) Need Help??


in reply to Generating standard length strings

As nobody has mentioned it already, there is another way:

sub rpad { pack "A$_[1]", $_[0]};

Replies are listed 'Best First'.
Re^2: Generating standard length strings
by crashtest (Curate) on Apr 14, 2005 at 19:20 UTC
    Note that your sub will cut off the input string if its length is larger than the padding width:
    sub rpad { pack "A$_[1]", $_[0] }; my $string = 'averylongstringthatislongerthan10charsforsure!'; print "]", rpad($string, 10), "[\n"; __END__ ]averylongs[
    I am not sure if that is what the OP intended.

Log In?
Username:
Password:

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

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

    No recent polls found