On Sat, Aug 29, 2009 at 3:51 PM, Daniel Burgaud<[email protected]> wrote:
> Hi
>
> I have a problem with printf/sprintf
>
> Basically I have this code:
> printf "%-50s %10.2f\n", $item, $price;
>
> This code prints a line that is 61 chars long with the Item's name on the
> Left and Price on the right.
> However, I want to make it variable width based on either screen width, or
> user input:
> ie,
>
> print "%-$Ws %10.2f\n", $item, $price;
>
> Obviously, this does not work. How do I code it to work like i want it?
printf "%-${W}s %10.2f\n", $item, $price;
Gabor
--
Gabor Szabo http://szabgab.com/blog.html
Perl Training in Israel http://www.pti.co.il/
Test Automation Tips http://szabgab.com/test_automation_tips.html
Perl 6 Tricks and Treats http://szabgab.com/perl6_tricks_and_treats.html
_______________________________________________
Perl-Win32-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs