Hi Rajeev,
On Fri, 27 Sep 2013 22:59:01 -0700 (PDT)
Rajeev Prasad <[email protected]> wrote:
> hello,
>
> following is obtained by concatenating 3 values using an underscore to
> produce a list:
>
> abc_12_4567
> xy4z_xtr4_sdf
> PQRSDR_xcvf_scc234
> i want them to look neat, something like this: where they look in line. I do
> not know before hand how long each word would be....
>
> abc____12____4567
> xy4z___xtr4__sdf
> PQRSDR_xcvf__scc234
>
> how could i use the sprintf to obtain such an effect?
>
I don't think sprintf can pad with underscores, but you can use the following
function (untested):
<CODE>
sub pad_with_underscores
{
my ($str, $len) = @_;
return $str . ('_' x ($len - length($str)));
}
</CODE>
Maybe this can also be done with https://metacpan.org/module/Text::Table (which
I should note that I maintain).
Regards,
Shlomi Fish
--
-----------------------------------------------------------------
Shlomi Fish http://www.shlomifish.org/
Apple Inc. is Evil - http://www.shlomifish.org/open-source/anti/apple/
http://en.wikipedia.org/wiki/Evil redirects to XSLT.
— http://www.shlomifish.org/humour/bits/facts/XSLT/
Please reply to list if it's a mailing list post - http://shlom.in/reply .
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/