[Mastering-perl] Check out the chapters on configuration, subroutines, and Pod

Derek B. Smith derekbellnersmith at yahoo.com
Wed Sep 20 15:13:43 EDT 2006


Brian, 

In the section listed belwo your English is
inconsistant.  For example you say 87 other modules
with GetOpt in the name but later on you say 89
modules matching GetOpt.


... including Getopt::Std, Getopt::Long, and 87 other
modules with Getopt in the name.
....

 simple scripts. Although CPAN had 89 modules matching
"Getopt", I only looked at the ones I was able to
install without a problem, and even then, looked
further at the ones whose documentation didn't require
too much work for me to figure out.

perl's Config at the bottom seems of place and should
be mentioned closer to the top.


under one of your text blocks you state: "If I don't
set some of the enviroment variables, that script I
just modified to use them complains since I have
warnings on. When I try to check the values in the if
statements, I'm using an undefined value. To get
around that, I set some defaults. The || short circuit
operator is handy here."

but I tested this code using use strict; use warnings;
and I received no undefined messages as you stated?
  
Here is the code:

<CODE>
#!/usr/bin/perl

use strict;
use warnings;

## If script is used as a CGI script, the web server
sets several environment variables, i
## including one called REQUEST_METHOD. If script sees
that its a CGI script, it prints a CGI
## response header. Otherwise, it figures I must be at
a terminal and skips that part

## Process prior to compilation ##

BEGIN {
    require "config.pl"; }


my $Debug   = $ENV{DEBUG};
my $Verbose = $ENV{VERBOSE};

print "Starting processing\n" if $Verbose;
print "Content-type: text/plain\n\n" if
$ENV{REQUEST_METHOD};


foreach my $key ( sort keys %ENV ) {
    printf "%-20s %s\n", $key, $ENV{$key};
}

warn "\nStopping script unexpectedly" if $Debug;

</CODE>

Here is the configp.pl file

<CODE>
#!/usr/bin/perl

use strict;
use warnings;
use vars qw( $Debug $Verbose $Email $DB );

my $Debug   = 0;
my $Verbose = 1;
my $Email   = 'alice at example.com';
my $DB      = 'DBI:mysql';

</CODE>

Here is the output of 

<OUTPUT>

root at DUBHADM1# DEBUG=1 ./env_setup.plx
ALTIRIS              /opt/altiris/notification/nsagent
COLUMNS              97
DEBUG                1
DISPLAY             
dubmtgraver1.cardinalhealth.net:0.0
EDITOR               vi
ERASE                ^H
HOME                 /
LINES                45
LOGNAME              root
MANPATH             
/usr/share/man/%L:/usr/share/man:/usr/contrib/man/%L:/usr/contrib/man:/usr/local/man/%L:/usr/local/man:/opt/upgrade/share/man/%L:/opt/upgrade/share/man:/opt/pd/share/man/%L:/opt/pd/share/man:/opt/pd/share/man/%L:/opt/pd/share/man:/opt/pd/share/man/%L:/opt/pd/share/man:/opt/resmon/share/man:/opt/hparray/share/man/%L:/opt/hparray/share/man:/opt/graphics/common/man:/usr/dt/share/man:/opt/samba/man:/opt/gnome/man:/opt/perf/man/%L:/opt/perf/man:/opt/prm/man/%L:/opt/prm/man:/opt/ignite/share/man/%L:/opt/ignite/share/man:/opt/ssh/share/man:/opt/hpnpl//man:/opt/sec_mgmt/share/man/%L:/opt/sec_mgmt/share/man:/opt/OV/man:/opt/scr/share/man:/opt/quest/man
NETBKUP              /usr/openv/netbackup
PATH                
/usr/sbin:/usr/bin:/usr/ccs/bin:/usr/contrib/bin:/opt/hparray/bin:/opt/nettladm/bin:/opt/upgrade/bin:/opt/fcms/bin:/opt/pd/bin:/opt/resmon/bin:/usr/bin/X11:/usr/contrib/bin/X11:/opt/graphics/common/bin:/opt/gnome/bin:/opt/perf/bin:/opt/mozilla:/opt/prm/bin:/opt/ignite/bin:/usr/sbin/diag/contrib:/opt/hpnpl//bin:/opt/sec_mgmt/spc/bin:/opt/OV/bin:/opt/scr/bin:/opt/OV/bin/OpC:/sbin:/home/root:/usr/local/sbin:/usr/contrib/Q4/bin:/opt/perl_64/bin
PERL5LIB            
/opt/perl/lib/5.8.2:/usr/contrib/Q4/lib/q4lib_11.11:/opt/perl/lib/site_perl/5.8.2:
PERLDIR              /usr/local/admin/perl
PS1
[$PWD]
root at DUBHADM1#
PWD                  /usr/local/admin/perl/derek_perl
SHELL                /sbin/sh
TERM                 xterm
TZ                   EST5EDT
_                    ./env_setup.plx

Stopping script unexpectedly at ./env_setup.plx line
27.
</OUTPUT>


--- Stefan Lidman <lidden at gmail.com> wrote:

> typo
> 
> >    
>
http://www252.pair.com/comdog/mastering_perl/Chapters/configuration.html
> 
> print "I was compiled on
> $Config{myhostname}.$Config{mydomain)\n";
> 
> s/ ) / } /x
> 
> /Stefan
> _______________________________________________
> Mastering-perl mailing list
> Mastering-perl at theperlreview.com
>
http://five.pairlist.net/mailman/listinfo/mastering-perl
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


More information about the Mastering-perl mailing list