Hi,
Browsing perlvar the other day, I noticed a deprecated variable called $# controlling the printing of floating point values. The examples I found of its usage hinted at sprintf style formatting and in fact it appears to work oK. However, I got curious enough to try out format chars other than g with disastrous results. I do admit that playing with a deprecated variable in an unintended manner is sort of asking for trouble, but I didn't expect the whole perl interpreter to crash without any debug messages.

Here's the code which runs fine till the last print statement, and even has time to nag about the $# variable.

use strict; use warnings;
my $pi = 3.141592; # some double value.
local $\ = "\n";

local $# = "%+.3g"; # Normal usage.
print $pi; # works fine.

$# = '%s'; # But an invalid format.
print $pi; # crashes the interpreter.

I mainly posted this to find out more on Why it crashes, just out of curiosity. If there's something wrong with a regular printf it rarely causes this bad results in my experience. So, I wonder why $# is so fatal.

I'm running Active State Perl v5.8.7 build 815 [211909]. The OS is XP Pro SP2 with all the latest fixes and this is an HP & Compaq NX8220 laptop, in case it has any relevance.

--
With kind regards Veli-Pekka Tätilä ([EMAIL PROTECTED])
Accessibility, game music, synthesizers and programming:
http://www.student.oulu.fi/~vtatila/
_______________________________________________
Perl-Win32-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to