#!/usr/bin/perl -wT
#
#sub_test.pl   . . .just a proof-of-concept 
#                   to get subroutines to be recognized.

use strict;
use warnings;
use CGI;
use CGI::Carp qw(fatalsToBrowser);
my $q = new CGI;

#-------------------------------------------------------------
#my $con = $q->param('con');  #  This works 
#                                . . .a subroutine in the CGI module?
#my $whatever = $q->parm('whatever');
# Does the subroutine, "whatever" need to be to be installed as a 
# Perl module in order that the CGI can "see" it within the CGI's bubble?
# . . .I hope not!  
# I don't want to install every ad hock "used-in-only-one-script" 
# subroutine in order to access it for execution.

sub whatever {
    print "<p>Got into <b><i>\"whatever's\"</i></b> subroutine $_[0]</p>";
}

#if ($q->parm( "whatever" )){
#   whatever();  # . . .then execute the whatever subroutine.
#};

#-------------------------------------------------------------
print $q->header,
      $q->start_html( -title => "sub_test.pl");

@_ = "as a result of a non-conditional invocation; therefore, it IS defined.";
&whatever;  # This non-conditional call works; 
            # therefore, the subroutine IS defined . . .somewhere.

#---- Hello Button ------------------------------------------
print $q->button( 
      -name    => 'Say hello', 
      -onClick => 'alert("Hello!")'),   # . . .This works (try it!).
      
#---- Return Button ------------------------------------------
      $q->submit( -name    => 'whatever',
                  -value   => '. . .click here for whatever',
                  -onClick => 'whatever'); # . . .sucks air (:-(
                  
print ". . .and if you do, the the SOB complains that \"whatever\" is not 
defined.";            
print "     <br><br>(Use Firefox with Error console opened . . .not MS/IE.)";   
                           
                  
print $q->end_html;


-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/

Reply via email to