develooper Front page | perl.beginners | Postings from October 2009

printf

Thread Next
From:
Aimee Cardenas
Date:
October 27, 2009 14:53
Subject:
printf
Message ID:
F3A92D2E-E608-465B-99C0-F5EAC4266EFF@sfbrgenetics.org
Hi, All!

I need to fix the width of some strings padding with leading spaces if  
necessary.  I wanted to use printf but I don't know if you can put a  
variable in the format part the the printf statement.  For example, if  
I wanted to use the following format type:

printf OFILE "%7s\n", $str;

but instead of '7' have a variable such as $w there, how might I do  
this?  Or is there a better function for what I'm trying to do?

Thanks,

Aimee Cardenas

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About