kage-yojimbo has asked for the wisdom of the Perl Monks concerning the following question:
I have written this very primitive subroutine that pads a string with blanks to return a standard length string. I'm sure there is a much easier way to do this job - any suggestions?
Thanks!
Thanks!
sub standard_fill { my $string = $_[0]; my $length = $_[1]; for (my $i = length($string); $i <= $length; $i++) { $string = $string." "; } return $string; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Generating standard length strings
by Roy Johnson (Monsignor) on Apr 14, 2005 at 18:59 UTC | |
by ihb (Deacon) on Apr 15, 2005 at 02:37 UTC | |
Re: Generating standard length strings
by BrowserUk (Patriarch) on Apr 14, 2005 at 18:59 UTC | |
Re: Generating standard length strings
by Corion (Patriarch) on Apr 14, 2005 at 19:04 UTC | |
by crashtest (Curate) on Apr 14, 2005 at 19:20 UTC | |
Re: Generating standard length strings
by jdporter (Paladin) on Apr 14, 2005 at 18:59 UTC | |
Re: Generating standard length strings
by crashtest (Curate) on Apr 14, 2005 at 19:04 UTC | |
Re: Generating standard length strings
by RazorbladeBidet (Friar) on Apr 14, 2005 at 19:00 UTC | |
Re: Generating standard length strings
by Fletch (Bishop) on Apr 14, 2005 at 19:00 UTC |
Back to
Seekers of Perl Wisdom