Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: substr and strings on the outside

by OeufMayo (Curate)
on Aug 19, 2001 at 20:23 UTC ( #106035=note: print w/ replies, xml ) Need Help??


in reply to substr and strings on the outside

Hello,
I'm not sure I perfectly understood what you wanted to do. Do you want to append '12345' to the $f variable, with at least 5 spaces at the beginning?

If so, here's a snippet that should do what you want:

sub pad { my ($spaces, $string) = @_; return( " " x (5 - length $spaces) . $string ); } my $add = "12345"; my $f = " " x 4; # for leading spaces smaller than 5 print "[" . pad( $f, '12345') . "]";
<kbd>--
my $OeufMayo = new PerlMonger::Paris({http => 'paris.mongueurs.net'});</kbd>


Comment on Re: substr and strings on the outside
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (4)
As of 2015-07-04 03:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (57 votes), past polls