> -----Original Message-----
> From: Aimee Cardenas [mailto:aim...@sfbrgenetics.org] 
> Sent: Tuesday, October 27, 2009 15:53
> To: Perl Beginners
> Subject: printf
> 
> 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;
        Yes you can.

        printf OFILE "%*s\n",
                        $varlen,
                        $var;
         If you have any questions and/or problems, please let me know.
         Thanks.
 
Wags ;)
David R. Wagner
Senior Programmer Analyst
FedEx Freight Systems
1.719.484.2097 Tel
1.719.484.2419 Fax
1.408.623.5963 Cell
http://fedex.com/us 

> 
> 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
> 
> -- 
> To unsubscribe, e-mail: beginners-unsubscr...@perl.org
> For additional commands, e-mail: beginners-h...@perl.org
> http://learn.perl.org/
> 
> 
> 

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


  • RE: printf Wagner, David --- Senior Programmer Analyst --- CFS

Reply via email to