10.4. printf Formats Don't Impose Context

If you're a die-hard C programmer (and is there any other kind?), you might think that to print the number of entries in an array, since the %d printf format specifier means “number,” well gosh, a number is a scalar, and so that's the context it'll put its argument into:

printf "Number of entries in @foo = %d", @foo;

but by now you know us too well to fall for that … yes, @foo is in list context here, because that's what printf is prototyped to take. So you'll either get the first entry of @foo printed, or a complaint if that's not a number.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset