[11658] in Perl-Users-Digest
Perl-Users Digest, Issue: 5259 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Mar 30 16:03:59 1999
Date: Tue, 30 Mar 99 13:01:26 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Tue, 30 Mar 1999 Volume: 8 Number: 5259
Today's topics:
Need Help making this perl counter script work. <royd@wic.net>
Need Help making this perl counter script work. <royd@wic.net>
Re: NT Kernel in Perl <cassell@mail.cor.epa.gov>
Perl DBI 'crypt' not available <nelson@dynacs.infohwy.com>
Re: Perl question <jacks@cybersource.com>
PFR gone? <dturley@pobox.com>
Re: Protecting Scripts from Privacy <cassell@mail.cor.epa.gov>
Question: Odd If-Else problem. <euston@mindspring.com>
timeout on user input? <lee.ramirez@westgroup.com>
Tk800.013 Won't work on my RH 5.2 system <d3h486@wd19518.emsl.pnl.gov>
Re: What does this variable mean? <nelson@dynacs.infohwy.com>
Re: What does this variable mean? <droby@copyright.com>
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 30 Mar 1999 13:02:24 -0700
From: "Roy D." <royd@wic.net>
Subject: Need Help making this perl counter script work.
Message-Id: <37012DCF.30F850DB@wic.net>
I have been trying to get this script to work for 2 weeks now and I need
help.
This is the script as I have it loaded on my server.
I have set everything as I understand it should be and it keeps
returning a
"[File Lock Error]" in place of the counter.
It does not matter if I set the file locking feature to 0, it still
gives the same output.
Any help would pe appreciated.
Thanks, Roy
#!/usr/bin/perl
############################################
## ##
## CounterLog ##
## by Darryl Burgdorf ##
## (e-mail burgdorf@awsd.com) ##
## ##
## version: 1.13 ##
## last modified: 7/4/98 ##
## copyright (c) 1998 ##
## ##
## latest version is available from ##
## http://awsd.com/scripts/ ##
## ##
############################################
# COPYRIGHT NOTICE:
#
# Copyright 1998 Darryl C. Burgdorf. All Rights Reserved.
#
# This program may be used and modified free of charge by anyone, so
# long as this copyright notice and the header above remain intact. By
# using this program you agree to indemnify Darryl C. Burgdorf from any
# liability.
#
# Selling the code for this program without prior written consent is
# expressly forbidden. Obtain permission before redistributing this
# program over the Internet or in any other medium. In all cases
# copyright and header must remain intact.
# DESCRIPTION:
#
# CounterLog monitors accesses to any pages which contain an SSI code
# referencing it. It can create NCSA-format agent and referer logs,
# which can be handy if your server doesn't happen to already provide
# you with that information. It can also be used to put text-based
# access counters on some or all of your pages. (Requires SSI.)
# VERSION HISTORY:
#
# 1.13 07/04/98 Rewrote file locking routines
# 1.12 05/02/98 Trapped "run on" URLs
# Modified lock routine cycle time
# 1.11 03/09/98 Corrected new glitch in URL processing
# Made agent & referer logs optional
# 1.10 01/23/98 Added "today's" hits to counter display
# Yet a few more small tweaks
# 1.02 08/06/97 A few small tweaks
# 1.01 05/05/97 Fixed minor bug in file locking
# Minor format changes
# 1.00 02/25/97 Initial "public" release
#########
# SETUP #
#########
# Any page you want monitored should contain somewhere the following
# SSI code:
#
# <!--#exec cgi="/cgi-bin/counterlog.pl"-->
#
# (If you've put the CounterLog script somewhere other than in your
# cgi-bin directory, the location should be revised accordingly.)
#
# If you're putting a counter on the page, of course, the SSI code
# should be placed on the page where you want the counter to appear.
# Otherwise, it makes no difference at all where you put it.
# The following variables define the location of the three log files.
# Make sure that the files actually exist and that they are set world-
# writable!
$AccessFile = "/home/mine/public_html/count/count_access";
$AgentFile = "/home/mine/public_html/count/count_agent";
$RefererFile = "/home/mine/public_html/count/count_referer";
# If $IncludeDomain is set to "1" the access and referer logs will
# include the domain of the local pages accessed. This can be handy
# if you have several different virtual domains on the system, and want
# to be able to keep track of accesses to pages with the same names
# (e.g., "index.html") under each domain. Setting it to "0" will
# prevent the domain from being listed.
$IncludeDomain = 1;
# If $IgnoreIntRefs is set to "1" the referer log will *not* list
# references from another page within the same domain. (This works
# regardless of the setting of $IncludeDomain.) This helps to keep
# the size of the referer log down. Set this to "0" if you need to
# know how often people are coming to a given page from each of
# several other pages on the same site, but set it to "1" if you're
# really only interested in knowing which outside pages link to yours.
$IgnoreIntRefs = 1;
# If you want to ignore accesses from specific domain names and/or
# IP numbers, list them here:
# @IgnoreIP = ("");
# By default, the CounterLog script prints nothing on a page which
# accesses it. If you want it to print a counter number on the page,
# list it here as it appears on the access list:
@PlainCounter =
("shadowmall.com/index.html","shadowmall.com/singles.html");
# If you want a particular page to feature an ordinalized counter
# (e.g., 1st, 2nd, 3rd, etc.) rather than a plain counter, list it
# here:
# @OrdCounter = ();
# If your system supports the flock() command, set the
# $UseLocking variable to "1"; set it to "0" otherwise.
$UseLocking = 1;
###############
# ACCESS FILE #
###############
print "Content-type: text/html\n\n";
&LockOpen (COUNT,"$AccessFile");
if (defined $ENV{'DOCUMENT_URI'}) {
$doc_uri = $ENV{'DOCUMENT_URI'};
if (defined $ENV{'SERVER_NAME'}) {
$server = $ENV{'SERVER_NAME'};
$server =~ s/www\.//i;
if ($IncludeDomain) {
$doc_uri = $server . $doc_uri;
}
}
}
else { $doc_uri = ""; }
$doc_uri =~ s#([^:])//#$1/#go;
$doc_uri =~ s#\.((s|p)*html*)/.*$#\.$1#o;
$doc_uri =~ s#/$##o;
$location = tell COUNT;
while ($line = <COUNT>) {
if (($acc,$day,$dayacc,$uri) = ($line =~ /^(\d+) (\d+) (\d+)
'(\S+)'$/)) {
if ($uri eq $doc_uri) {
last;
}
}
last if ($uri eq $doc_uri);
$location = tell COUNT;
$acc = 0;
$dayacc = 0;
}
$acc += 1;
$time = time;
($mday,$mon,$year) = (localtime($time))[3,4,5];
$year += 1900;
if ($mday < 10) { $mday = "0".$mday; }
$mon += 1;
if ($mon < 10) { $mon = "0".$mon; }
$today = $year.$mon.$mday;
unless ($day eq $today) {
$dayacc = 0;
}
$dayacc += 1;
foreach $key (@PlainCounter) {
if ($doc_uri eq $key) {
$printacc = &commas($acc);
$printdayacc = &commas($dayacc);
last;
}
}
foreach $key (@OrdCounter) {
if ($doc_uri eq $key) {
$printacc = &commas($acc) . &ordinalize($acc);
$printdayacc = &commas($dayacc) . &ordinalize($dayacc);
last;
}
}
if ($printacc) { print "$printacc ($printdayacc today)"; }
$ignore = 0;
if ((defined $ENV{"REMOTE_ADDR"}) && (defined @IgnoreIP)) {
$ignore = grep($ENV{"REMOTE_ADDR"} =~ /$_/, @IgnoreIP);
}
if ($doc_uri && !$ignore) {
seek(COUNT, $location, 0);
$longacc = sprintf("%010.10d", $acc);
$longdayacc = sprintf("%010.10d", $dayacc);
print COUNT "$longacc $today $longdayacc '$doc_uri'\n";
}
&LockClose (COUNT,"$AccessFile");
##############
# AGENT FILE #
##############
if ($AgentFile) {
open (COUNT,">>$AgentFile");
if (defined $ENV{'HTTP_USER_AGENT'}) {
$doc_agent = $ENV{'HTTP_USER_AGENT'};
}
else { $doc_agent = ""; }
if ($doc_agent && !($ignore)) {
print COUNT "$doc_agent\n";
}
close (COUNT);
}
################
# REFERER FILE #
################
if ($RefererFile) {
open (COUNT,">>$RefererFile");
if (defined $ENV{'HTTP_REFERER'}) {
$doc_referer = $ENV{'HTTP_REFERER'};
}
else { $doc_referer = ""; }
if ($doc_referer && $doc_uri && !($ignore)) {
unless ($IgnoreIntRefs && ($doc_referer =~ m#$server#oi)) {
print COUNT "$doc_referer -> $doc_uri\n";
}
}
close (COUNT);
}
###############
# SUBROUTINES #
###############
sub LockOpen {
local(*FILE,$lockfilename) = @_;
local($TrysLeft) = 100;
unless (-e "$lockfilename") {
open (FILE,">$lockfilename");
print FILE "\n";
close (FILE);
}
if ($UseLocking) {
open (FILE,"+<$lockfilename") || &Error;
flock(FILE,2) || &Error;
}
else {
if ((-e "$lockfilename.lok") &&
((stat("$lockfilename.lok"))[9]+30<$time)) {
unlink ("$lockfilename.lok");
}
while ($TrysLeft--) {
if (-e "$lockfilename.lok") {
select(undef,undef,undef,0.01);
}
else {
open (LOCKFILE,">$lockfilename.lok");
print LOCKFILE "\n";
close (LOCKFILE);
last;
}
}
if ($TrysLeft >= 0) {
open (FILE,"+<$lockfilename") || &Error;
}
else {
&Error;
}
}
}
sub LockClose {
local(*FILE,$lockfilename) = @_;
close (FILE);
unlink ("$lockfilename.lok");
}
sub Error {
print "[File Lock Error]";
exit(0);
}
sub ordinalize {
local($count) = @_;
local($last, $last2);
$last2 = $count % 100;
$last = $count % 10;
if ($last2 < 10 || $last2 > 13) {
return "st" if $last == 1;
return "nd" if $last == 2;
return "rd" if $last == 3;
}
return "th";
}
sub commas {
local($_)=@_;
1 while s/(.*\d)(\d\d\d)/$1,$2/;
$_;
}
------------------------------
Date: Tue, 30 Mar 1999 13:02:49 -0700
From: "Roy D." <royd@wic.net>
Subject: Need Help making this perl counter script work.
Message-Id: <37012DE8.E7ABB7A2@wic.net>
I have been trying to get this script to work for 2 weeks now and I need
help.
This is the script as I have it loaded on my server.
I have set everything as I understand it should be and it keeps
returning a
"[File Lock Error]" in place of the counter.
It does not matter if I set the file locking feature to 0, it still
gives the same output.
Any help would be appreciated.
Thanks, Roy
#!/usr/bin/perl
############################################
## ##
## CounterLog ##
## by Darryl Burgdorf ##
## (e-mail burgdorf@awsd.com) ##
## ##
## version: 1.13 ##
## last modified: 7/4/98 ##
## copyright (c) 1998 ##
## ##
## latest version is available from ##
## http://awsd.com/scripts/ ##
## ##
############################################
# COPYRIGHT NOTICE:
#
# Copyright 1998 Darryl C. Burgdorf. All Rights Reserved.
#
# This program may be used and modified free of charge by anyone, so
# long as this copyright notice and the header above remain intact. By
# using this program you agree to indemnify Darryl C. Burgdorf from any
# liability.
#
# Selling the code for this program without prior written consent is
# expressly forbidden. Obtain permission before redistributing this
# program over the Internet or in any other medium. In all cases
# copyright and header must remain intact.
# DESCRIPTION:
#
# CounterLog monitors accesses to any pages which contain an SSI code
# referencing it. It can create NCSA-format agent and referer logs,
# which can be handy if your server doesn't happen to already provide
# you with that information. It can also be used to put text-based
# access counters on some or all of your pages. (Requires SSI.)
# VERSION HISTORY:
#
# 1.13 07/04/98 Rewrote file locking routines
# 1.12 05/02/98 Trapped "run on" URLs
# Modified lock routine cycle time
# 1.11 03/09/98 Corrected new glitch in URL processing
# Made agent & referer logs optional
# 1.10 01/23/98 Added "today's" hits to counter display
# Yet a few more small tweaks
# 1.02 08/06/97 A few small tweaks
# 1.01 05/05/97 Fixed minor bug in file locking
# Minor format changes
# 1.00 02/25/97 Initial "public" release
#########
# SETUP #
#########
# Any page you want monitored should contain somewhere the following
# SSI code:
#
# <!--#exec cgi="/cgi-bin/counterlog.pl"-->
#
# (If you've put the CounterLog script somewhere other than in your
# cgi-bin directory, the location should be revised accordingly.)
#
# If you're putting a counter on the page, of course, the SSI code
# should be placed on the page where you want the counter to appear.
# Otherwise, it makes no difference at all where you put it.
# The following variables define the location of the three log files.
# Make sure that the files actually exist and that they are set world-
# writable!
$AccessFile = "/home/mine/public_html/count/count_access";
$AgentFile = "/home/mine/public_html/count/count_agent";
$RefererFile = "/home/mine/public_html/count/count_referer";
# If $IncludeDomain is set to "1" the access and referer logs will
# include the domain of the local pages accessed. This can be handy
# if you have several different virtual domains on the system, and want
# to be able to keep track of accesses to pages with the same names
# (e.g., "index.html") under each domain. Setting it to "0" will
# prevent the domain from being listed.
$IncludeDomain = 1;
# If $IgnoreIntRefs is set to "1" the referer log will *not* list
# references from another page within the same domain. (This works
# regardless of the setting of $IncludeDomain.) This helps to keep
# the size of the referer log down. Set this to "0" if you need to
# know how often people are coming to a given page from each of
# several other pages on the same site, but set it to "1" if you're
# really only interested in knowing which outside pages link to yours.
$IgnoreIntRefs = 1;
# If you want to ignore accesses from specific domain names and/or
# IP numbers, list them here:
# @IgnoreIP = ("");
# By default, the CounterLog script prints nothing on a page which
# accesses it. If you want it to print a counter number on the page,
# list it here as it appears on the access list:
@PlainCounter =
("shadowmall.com/index.html","shadowmall.com/singles.html");
# If you want a particular page to feature an ordinalized counter
# (e.g., 1st, 2nd, 3rd, etc.) rather than a plain counter, list it
# here:
# @OrdCounter = ();
# If your system supports the flock() command, set the
# $UseLocking variable to "1"; set it to "0" otherwise.
$UseLocking = 1;
###############
# ACCESS FILE #
###############
print "Content-type: text/html\n\n";
&LockOpen (COUNT,"$AccessFile");
if (defined $ENV{'DOCUMENT_URI'}) {
$doc_uri = $ENV{'DOCUMENT_URI'};
if (defined $ENV{'SERVER_NAME'}) {
$server = $ENV{'SERVER_NAME'};
$server =~ s/www\.//i;
if ($IncludeDomain) {
$doc_uri = $server . $doc_uri;
}
}
}
else { $doc_uri = ""; }
$doc_uri =~ s#([^:])//#$1/#go;
$doc_uri =~ s#\.((s|p)*html*)/.*$#\.$1#o;
$doc_uri =~ s#/$##o;
$location = tell COUNT;
while ($line = <COUNT>) {
if (($acc,$day,$dayacc,$uri) = ($line =~ /^(\d+) (\d+) (\d+)
'(\S+)'$/)) {
if ($uri eq $doc_uri) {
last;
}
}
last if ($uri eq $doc_uri);
$location = tell COUNT;
$acc = 0;
$dayacc = 0;
}
$acc += 1;
$time = time;
($mday,$mon,$year) = (localtime($time))[3,4,5];
$year += 1900;
if ($mday < 10) { $mday = "0".$mday; }
$mon += 1;
if ($mon < 10) { $mon = "0".$mon; }
$today = $year.$mon.$mday;
unless ($day eq $today) {
$dayacc = 0;
}
$dayacc += 1;
foreach $key (@PlainCounter) {
if ($doc_uri eq $key) {
$printacc = &commas($acc);
$printdayacc = &commas($dayacc);
last;
}
}
foreach $key (@OrdCounter) {
if ($doc_uri eq $key) {
$printacc = &commas($acc) . &ordinalize($acc);
$printdayacc = &commas($dayacc) . &ordinalize($dayacc);
last;
}
}
if ($printacc) { print "$printacc ($printdayacc today)"; }
$ignore = 0;
if ((defined $ENV{"REMOTE_ADDR"}) && (defined @IgnoreIP)) {
$ignore = grep($ENV{"REMOTE_ADDR"} =~ /$_/, @IgnoreIP);
}
if ($doc_uri && !$ignore) {
seek(COUNT, $location, 0);
$longacc = sprintf("%010.10d", $acc);
$longdayacc = sprintf("%010.10d", $dayacc);
print COUNT "$longacc $today $longdayacc '$doc_uri'\n";
}
&LockClose (COUNT,"$AccessFile");
##############
# AGENT FILE #
##############
if ($AgentFile) {
open (COUNT,">>$AgentFile");
if (defined $ENV{'HTTP_USER_AGENT'}) {
$doc_agent = $ENV{'HTTP_USER_AGENT'};
}
else { $doc_agent = ""; }
if ($doc_agent && !($ignore)) {
print COUNT "$doc_agent\n";
}
close (COUNT);
}
################
# REFERER FILE #
################
if ($RefererFile) {
open (COUNT,">>$RefererFile");
if (defined $ENV{'HTTP_REFERER'}) {
$doc_referer = $ENV{'HTTP_REFERER'};
}
else { $doc_referer = ""; }
if ($doc_referer && $doc_uri && !($ignore)) {
unless ($IgnoreIntRefs && ($doc_referer =~ m#$server#oi)) {
print COUNT "$doc_referer -> $doc_uri\n";
}
}
close (COUNT);
}
###############
# SUBROUTINES #
###############
sub LockOpen {
local(*FILE,$lockfilename) = @_;
local($TrysLeft) = 100;
unless (-e "$lockfilename") {
open (FILE,">$lockfilename");
print FILE "\n";
close (FILE);
}
if ($UseLocking) {
open (FILE,"+<$lockfilename") || &Error;
flock(FILE,2) || &Error;
}
else {
if ((-e "$lockfilename.lok") &&
((stat("$lockfilename.lok"))[9]+30<$time)) {
unlink ("$lockfilename.lok");
}
while ($TrysLeft--) {
if (-e "$lockfilename.lok") {
select(undef,undef,undef,0.01);
}
else {
open (LOCKFILE,">$lockfilename.lok");
print LOCKFILE "\n";
close (LOCKFILE);
last;
}
}
if ($TrysLeft >= 0) {
open (FILE,"+<$lockfilename") || &Error;
}
else {
&Error;
}
}
}
sub LockClose {
local(*FILE,$lockfilename) = @_;
close (FILE);
unlink ("$lockfilename.lok");
}
sub Error {
print "[File Lock Error]";
exit(0);
}
sub ordinalize {
local($count) = @_;
local($last, $last2);
$last2 = $count % 100;
$last = $count % 10;
if ($last2 < 10 || $last2 > 13) {
return "st" if $last == 1;
return "nd" if $last == 2;
return "rd" if $last == 3;
}
return "th";
}
sub commas {
local($_)=@_;
1 while s/(.*\d)(\d\d\d)/$1,$2/;
$_;
}
------------------------------
Date: Tue, 30 Mar 1999 10:06:07 -0800
From: "David L. Cassell" <cassell@mail.cor.epa.gov>
Subject: Re: NT Kernel in Perl
Message-Id: <3701128F.2DF7A43@mail.cor.epa.gov>
Uri Guttman wrote:
> >>>>> "CS" == Christopher Spence <ComputerShoppe@mediaone.net> writes:
> CS> I am trying to rewrite the NT Kernel in Perl hoping i can get some
> CS> performance gains. Anyone want to help?
>
> CS> :)
>
> check out larry wall's view on this theme:
>
> http://segfault.org/story.phtml?mode=2&id=36fc3f8c-0138b980
>
> :-)
Heh-heh-heh. I laughed so loud one of my colleagues came over to
see what was going on.
David
--
David L. Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Tue, 30 Mar 1999 13:10:46 -0600
From: Nelson Thompson <nelson@dynacs.infohwy.com>
Subject: Perl DBI 'crypt' not available
Message-Id: <370121B5.D6259E57@dynacs.infohwy.com>
In moving from perl 5.004 to Perl-DBI (based upon 5.004),
the 'crypt' function no longer works.
Attempting to use the function generates the error message"
"The crypt() function is unimplemented due to excessive paranoia"
Question 1: how can I re-install crypt() ??
Question 2: why the paranoia; why was crypt() removed from Perl-DBI ??
--
Nelson Thompson
Project Lead,
Dynacs Engineering -- Houston Operations
281 333-4419 ext 118
"Specialization is for Insects." R. A. Heinlein
------------------------------
Date: Tue, 30 Mar 1999 12:41:48 -0800
From: Jack Schlotthauer <jacks@cybersource.com>
Subject: Re: Perl question
Message-Id: <3701370B.26311823@cybersource.com>
When someone hits the enter key they send both a newline and
a return.
$value[$n] =~ s/%0D%0A/ /g;
or
$value[$n] =~ (s/\r\n/ /g);
jgangemi@ccf.rutgers.edu wrote:
> In article <36f56f64.91746384@news.truman.edu>,
> q969@truman.edu wrote:
>
> > It works fine except when a user tries to enter multiple lines
> > separated by an enter (newline). In this case, perl only displays the
> > first line (i.e. everything up to the newline character). I've been
> > told that this is because a newline is a default record delimeter.
> >
> > I've tried to use the =~ command to parse out newlines and replace
> > them with spaces (though any character would do). The command I've
> > used is $value[$n] =~ s/\n/ /; But this never works (I've tried
> > changing the 's' to a 'tr'). I get the same output to the text file
> > whether I include this line or not.
>
> try this : $value[$n] =~ s/.\n/\ /g;
>
> I was having the same problem, and this fixed it.
>
> -Jae
>
> -----------== Posted via Deja News, The Discussion Network ==----------
> http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
--
x$0`/`0$x,8_8,x$0$x8_8,x$0`/`0$x
Jack Schlotthauer
1 (408) 260-6174
jacks@cybersource.com
Webmaster BarberShop
http://barbershop.cybersource.com
x$0`/`0$x,8_8,x$0$x8_8,x$0`/`0$x
------------------------------
Date: Tue, 30 Mar 1999 20:43:21 GMT
From: David Turley <dturley@pobox.com>
Subject: PFR gone?
Message-Id: <7drd16$5l1$1@nnrp1.dejanews.com>
I just tried to go to the Perl Function Repository at
http://moiraine.dimensional.com/~dgris/perl/pfr/
and got a found no found error. :-)
Is this great site gone?
--
David Turley
dturley@pobox.com
http://www.binary.net/dturley
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Tue, 30 Mar 1999 10:28:06 -0800
From: "David L. Cassell" <cassell@mail.cor.epa.gov>
Subject: Re: Protecting Scripts from Privacy
Message-Id: <370117B6.DBCED161@mail.cor.epa.gov>
Mike Watkins wrote:
> Hi there,
> I'm sure some of you have had this problem, so I thought I would ask. Is
> there anyway way to protect your CGI scripts which you sell from being
> pirated?
Short answer: no.
Medium answer: this is a FAQ, so there's more you can read just using
perldoc [or the html version if you have it].
Unfortunate answer: you can put legal stuff in it to stop the clueless,
but there's nothnig you can do to stop a real 'pirate'. If Micro$oft
can't stop pirates and dongles can't stop pirates, I don't see how it
can possibly be cost-effective for a lone programmer to do it.
Of course you can always write code in such an obfuscated manner that
other programmers have cerebral hemorrhages trying to understand it.
I've been accused of that. :-)
David
--
David L. Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Tue, 30 Mar 1999 15:22:15 -0500
From: "Ed" <euston@mindspring.com>
Subject: Question: Odd If-Else problem.
Message-Id: <7drbt1$rde$1@camel29.mindspring.com>
I've encountered an odd error with the following section of a simple
script. The problem section is included below. The problem I'm having
is that the print immediately after the delete prints fine, but nothing else
will print, even the print after the if-else construct. I look in the
database and
the delete is deleting the correct records. BTW: I have a standard
subroutine
to print the html header information with a background, and the header and
background is being output.
I called my web provider to ask them if they had any suggestions, and
their response was, "I spoke to our PERL guru and we saw that it doesn't
work."
I would appreciate any help that anyone could give. E-mail (
euston@mindspring.com) is fine.
Thanks in advance,
Edward
script follows:
if (defined($class{$title})) {
delete($class{$title});
print qq|
<h3> $title deleted #3.
|;
if (!exists($class{$title})) {
print qq|
<h3> $title deleted.
|;
}
else {
print qq|
<h3> $title delete unsuccesful.
|;
}
print qq|
<h3> I just skipped the if - else.
|;
}
------------------------------
Date: Tue, 30 Mar 1999 12:08:16 -0600
From: "Lee Ramirez" <lee.ramirez@westgroup.com>
Subject: timeout on user input?
Message-Id: <37011254@wwwproxy3.westgroup.com>
I have a script that asks two questions of
the user in the beginning with the responses
going to standard input. Is there anyway I
can set a timeout on the input? For example,
if the user doesn't respond in 10 seconds the
script uses a default value.
Thanks,
Lee
------------------------------
Date: 30 Mar 1999 11:14:35 -0800
From: John Daschbach <d3h486@wd19518.emsl.pnl.gov>
Subject: Tk800.013 Won't work on my RH 5.2 system
Message-Id: <m3hfr26b8k.fsf@wd19518.emsl.pnl.gov>
I have been using PerlTk for a few years on older Linux systems, using
the Tk4 series of PerlTk. I upgraded to RH 5.2 on one machine and
grabbed the Tk800.013 tarball. PerlTk compiled fine, and ran the
tests (make test) with one exception (I don't have DataDumper
installed presently).
But PerlTk does not run. I consistently get the following error
message. This is from running the demos, but the same result obtains
with my PerlTk scripts that have run for years.
[d3h486@wd19518 demos]$ perl browse
Goto undefined subroutine &main::-1 at /usr/lib/perl5/site_perl/Tk/Widget.pm line 324.
[d3h486@wd19518 demos]$ perl color_editor
Assuming 'require Tk::Frame;' at color_editor line 13
Goto undefined subroutine &main::-1 at /usr/lib/perl5/site_perl/Tk/Widget.pm line 324.
[d3h486@wd19518 demos]$ perl composite
Assuming 'require Tk::Entry;' at /usr/lib/perl5/site_perl/Tk/LabEntry.pm line 23
Goto undefined subroutine &main::-1 at /usr/lib/perl5/site_perl/Tk/Widget.pm line 324.
at /usr/lib/perl5/site_perl/Tk/LabEntry.pm line 23
[d3h486@wd19518 demos]$
Line 324 is the end of the AUTOLOAD routine.
Can someone help with what's going on? This is the first time I can
remember installing a Perl package which passed all the tests and had
it fail.
-John
jl_daschbach@pnl.gov
------------------------------
Date: Tue, 30 Mar 1999 13:20:00 -0600
From: Nelson Thompson <nelson@dynacs.infohwy.com>
Subject: Re: What does this variable mean?
Message-Id: <370123E0.3F8BB293@dynacs.infohwy.com>
solidice@my-dejanews.com wrote:
> $salt = substr($pwd, 0, 2);
> What does this mean? Or can someone give me a link with a description of all
> the CGI script variables?
Simply, it takes the first two ascii characters in the string $pwd, and
assigns them as the value of the string $salt.
If $pwd = "barsoom", then
$salt = "ba".
This command is found in Programming Perl, chapter 3: Functions, under
the description of the crypt() function.
--
Nelson Thompson
Project Lead,
Dynacs Engineering -- Houston Operations
281 333-4419 ext 118
"Specialization is for Insects." R. A. Heinlein
------------------------------
Date: Tue, 30 Mar 1999 19:55:41 GMT
From: Don Roby <droby@copyright.com>
Subject: Re: What does this variable mean?
Message-Id: <7dra7n$2vc$1@nnrp1.dejanews.com>
In article <7dqsal$li6$1@nnrp1.dejanews.com>,
solidice@my-dejanews.com wrote:
> $salt = substr($pwd, 0, 2);
> What does this mean? Or can someone give me a link with a description of all
> the CGI script variables?
>
>
A variable means just what I choose it to mean -- neither more nor less.
In this instance, based on the programmer's choice of variable names and the
context of their uses, I would say that $pwd is a user's password read from a
Unix-style passwd file, and $salt is the salt for the crypt function,
extracted from that store password. For some more context around this, I
recommend a look at the section on crypt in the perlfunc man page. It in
fact contains your code snippet exactly.
There are occasionally other reasons for extracting the first two characters
from a string though.
Nobody can give you a "description of all the CGI script variables". You can
use as many variables as you like in a Perl program or any other CGI script.
But look at the "Idiot's Guide to Solving Perl/CGI Problems" and the "CGI
Programming FAQ", both available at http://language.perl.com/faq, for some
help getting started with CGI.
The snippet of Perl code you posted has nothing really to do with CGI, though
it could certainly be used in a CGI program. And CGI programming has really
nothing to do with Perl, though Perl is a popular language for coding CGI.
--
Don Roby
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>
Administrivia:
Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing.
]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body. Majordomo will then send you instructions on how to confirm your
]subscription. This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V8 Issue 5259
**************************************