Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
hi there,
i am trying to get the printf function to print a variable. the issue is complex (for me) as the variable i am trying to print(f) contains strings and integers. i would like to print in a nice format. is this possible.... ? see my example code:
my $pi = 3.14159; printf "%11s %3d %5.1f\n", "Hello there", 123, $pi; # this works fine +! $newarray="%11s %3d %5.1f\nHello there"; $newarray.=" 123 $pi"; printf $newarray; # this doesn't work :-( as the printf above, any id +eas?
20050213 Janitored by Corion: Added formatting
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: printf and variables
by friedo (Prior) on Feb 13, 2005 at 21:03 UTC | |
by Anonymous Monk on Feb 13, 2005 at 22:35 UTC | |
|
Re: printf and variables
by Zaxo (Archbishop) on Feb 13, 2005 at 21:03 UTC | |
by Tanktalus (Canon) on Feb 14, 2005 at 03:49 UTC | |
|
Re: printf and variables
by m-rau (Scribe) on Feb 13, 2005 at 21:12 UTC |