[tpm] 'use CGI::Carp' being calling in an 'if' block when condition not met

Madison Kelly linux at alteeve.com
Thu Jan 8 14:21:10 PST 2009

Hi all,

   I've got a program that can either be printed to a browser or shell. 
To this end, I have a simple function that determines how the program is 
running. When it detects a browser, it loads 'CGI::Carp 

   The problem is that this module is being loaded regardless of whether 
The containing 'if' block's condition is met.

   Here's the function

sub detect_calling_method
	my ($conf)=@_;
	# Now determine if we are being called via the command line or a
	# browser and update the 'conf' value.
		# HTML, load  CGI.
		use CGI::Carp qw(fatalsToBrowser);
		print "Content-type: text/html; charset=utf-8\n\n";
	elsif ($ENV{SHELL})
	print "$THIS_FILE ".__LINE__.": system::display::mode: 
	# Not detecting a mode is no longer fatal, it simply remains the
	# default value set in the config file.

   So even if '$ENV{HTTP_USER_AGENT}' is empty and 
'$conf->{'system'}{display}{mode}' is set to 'text' (showing that it was 
the condition matched), calling 'die' shows an HTML'ized error like:

common.lib 238: system::display::mode: [text]
<h1>Software error:</h1>
<pre>Looping in common.lib at line 665 on string: [Opening log file on: 
[#!var!0!#] at: [#!var!1!#] from file: [#!var!2!#].]. Exiting.
For help, please send mail to this site's webmaster, giving this error 
and the time and date of the error.


   Any tips?

More information about the toronto-pm mailing list