"t" == toylet <toylet_at_mail.hongkong.com> writes:
t> Can this be done with an ounce with regular expression only?
t> print padr("99",5,"0"); #00099
huh??
t> sub padr {
t> ($char, $maxlen, $filler) = @_;
t> $x=$maxlen-length($char);
t> return $filler x $x . $char;
t> }
please learn some basic perl. you are using GLOBAL variables for args
there. use strict or die!!
why would you want to use a regex? any workable regex (and it can be
done but i won't show you) will be more complex looking than your sub
call. and don't say but the body of the sub is complex. the key is what
the call looks like as you use the sub to HIDE the complexity. so again,
why do you want to do this? and write proper perl code. you are going to
get slammed for that sub by all who followup.
uri