DaveC426913
Programmer
1] How can I reliably debug PERL by displaying the contents of variables? What if the script hasn't actually created a page yet, but might?
The pages I'm debugging are doing various things that might or might not generate an HTML page, redirect to another page or run a shell script. The very act of displaying a variable may mess with the operation of the script (especially if it hasn't printed the header yet).
While I'm at it, same question about shell scripting.
2] I run my PERL script (createdir.pl) but, rather than being redirected, it displays this - I don't understand what it is telling me:
Status: 302 Moved Location:
It should be going to that URL (which does exist). Why isn't it? Does 'moved location' simply mean "I would go there if I could find it"?
Here are the relevant parts of the code (there's other bits, hopefully I've pared them out correctly):
#!/usr/bin/perl -w
use strict; # Activate compile-time syntax checking
use CGI; # Needed for CGI environment
use CGI::Carp qw(fatalsToBrowser); # Throw errors as HTML pages
use File::Copy; # Much easier for duplicating the sample conf
my $thecgi = new CGI;
my ($instructions,$redirect,$code,$clientDB,$clientName,$eventID,$eventName,$mode);
print "Content-type: text/html\n\n";
newEvent();
$code = $thecgi->param("c");
$instructions = "$mode $clientDB $eventID";
$redirect = "
#####
my $cmd = "./createdir.sh $instructions";
my $result = system($cmd);
$result >>= 8; # shift 8 bits
select (STDOUT);
print $thecgi->redirect( $redirect );
exit 0;
#####
function newEvent(){
etc, etc.
}
exit 0;
The pages I'm debugging are doing various things that might or might not generate an HTML page, redirect to another page or run a shell script. The very act of displaying a variable may mess with the operation of the script (especially if it hasn't printed the header yet).
While I'm at it, same question about shell scripting.
2] I run my PERL script (createdir.pl) but, rather than being redirected, it displays this - I don't understand what it is telling me:
Status: 302 Moved Location:
It should be going to that URL (which does exist). Why isn't it? Does 'moved location' simply mean "I would go there if I could find it"?
Here are the relevant parts of the code (there's other bits, hopefully I've pared them out correctly):
#!/usr/bin/perl -w
use strict; # Activate compile-time syntax checking
use CGI; # Needed for CGI environment
use CGI::Carp qw(fatalsToBrowser); # Throw errors as HTML pages
use File::Copy; # Much easier for duplicating the sample conf
my $thecgi = new CGI;
my ($instructions,$redirect,$code,$clientDB,$clientName,$eventID,$eventName,$mode);
print "Content-type: text/html\n\n";
newEvent();
$code = $thecgi->param("c");
$instructions = "$mode $clientDB $eventID";
$redirect = "
#####
my $cmd = "./createdir.sh $instructions";
my $result = system($cmd);
$result >>= 8; # shift 8 bits
select (STDOUT);
print $thecgi->redirect( $redirect );
exit 0;
#####
function newEvent(){
etc, etc.
}
exit 0;