Hi again
Ich bin leider mit Active Perl geschlagen. Dort steht in der Doku nur, daß sprintf() sich so verhält wie printf() in C.
Weiss nicht, wie aktuell Deine Distri ist, aber bei mir steht da mehr (Build 521). "Wie in C" ist aber mit
Vorsicht zu geniessen, da Perl ja nicht zwischen Zahlen und Strings unterscheidet, da duerfte eine
C-Erklaerung stellenweise ziemlich unlogisch klingen.
- einem %-Zeichen (%%)
Das war dann der Teil, den ich mir nicht erklären konnte (welch sagenumwobene undokumentierte
Geheimwaffe von Perl sich dahinter wohl verbergen konnte ? ;-).
Ist das % also auch zur eigenen Maskierung zu verwenden ?!?
Nur in diesen printf-Formaten. Denn % leitet hier eine "Anweisung" an die (s)printf-Funktion ein, also muss
es auch irgendwie maskiert werden koennen. In normalen Strings hat ja auch \ ne spezielle Bedeutung, also
wird es auch mit sich selbst escaped.
Also gut, auf die Gefahr hin dass das Posting gross wird, kopier ich einfach mal die sprintf-Doku hin, die
bei mir in perlfunc steht:
sprintf FORMAT, LIST
Returns a string formatted by the usual printf() conventions of the C library function sprintf(). See sprintf(3) or printf(3) on your system for an explanation of the general principles.
Perl does its own sprintf() formatting -- it emulates the C function sprintf(), but it doesn't use it (except for floating-point numbers, and even then only the standard modifiers are allowed). As a result, any non-standard extensions in your local sprintf() are not available from Perl.
Perl's sprintf() permits the following universally-known conversions:
%% a percent sign
%c a character with the given number
%s a string
%d a signed integer, in decimal
%u an unsigned integer, in decimal
%o an unsigned integer, in octal
%x an unsigned integer, in hexadecimal
%e a floating-point number, in scientific notation
%f a floating-point number, in fixed decimal notation
%g a floating-point number, in %e or %f notation
In addition, Perl permits the following widely-supported conversions:
%X like %x, but using upper-case letters
%E like %e, but using an upper-case "E"
%G like %g, but with an upper-case "E" (if applicable)
%p a pointer (outputs the Perl value's address in hexadecimal)
%n special: *stores* the number of characters output so far
into the next variable in the parameter list
Finally, for backward (and we do mean ``backward'') compatibility, Perl permits these unnecessary but widely-supported conversions:
%i a synonym for %d
%D a synonym for %ld
%U a synonym for %lu
%O a synonym for %lo
%F a synonym for %f
Perl permits the following universally-known flags between the % and the conversion letter:
space prefix positive number with a space
+ prefix positive number with a plus sign
- left-justify within the field
0 use zeros, not spaces, to right-justify
# prefix non-zero octal with "0", non-zero hex with "0x"
number minimum field width
.number "precision": digits after decimal point for
floating-point, max length for string, minimum length
for integer
l interpret integer as C type "long" or "unsigned long"
h interpret integer as C type "short" or "unsigned short"
There is also one Perl-specific flag:
V interpret integer as Perl's standard integer type
Where a number would appear in the flags, an asterisk (\*'') may be used instead, in which case Perl uses the next item in the parameter list as the given number (that is, as the field width or precision). If a field width obtained through
*'' is negative, it has the same effect as the ``-'' flag: left-justification.
If use locale is in effect, the character used for the decimal point in formatted real numbers is affected by the LC_NUMERIC locale. See perllocale.
So long, Calocybe