in reply to formating string var with % in it
$ostr = sprintf("$format", @stuff); printf $ostr;
That second printf is trying to do another interpolation. You want to use print here. Had you used warnings or if you ran your program using perl -w, Perl would raised at least a warning for the printf, even if that warning is misleading (in 5.10, fixed in 5.12 or at least 5.13.5):
> perl -wle "$f=sprintf'%-13s','%util';print $f;printf $f" Use of uninitialized value $f in printf at -e line 1. 0til
Of course, $f is not uninitialized, but there is no named variable anyway.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: formating string var with % in it
by crdrtl (Initiate) on Sep 22, 2010 at 18:44 UTC |