[19886] in Perl-Users-Digest
Perl-Users Digest, Issue: 2081 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Nov 7 00:06:19 2001
Date: Tue, 6 Nov 2001 21:05:10 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <1005109509-v10-i2081@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Tue, 6 Nov 2001 Volume: 10 Number: 2081
Today's topics:
Re: Best language for low IQ programmers? <mspight@dnai.com>
Re: Can't call method "add_handler" error. <goldbb2@earthlink.net>
Re: Failed scripts leave Perl behind <goldbb2@earthlink.net>
Re: Failed scripts leave Perl behind <goldbb2@earthlink.net>
Re: Failed scripts leave Perl behind (Garry Williams)
getting just the variable names from inputs in a form (Keith Clay)
Re: getting just the variable names from inputs in a fo <gamu829@yahoo.com>
Help Installing Modules (CPAN) problems (Scooby)
Re: Help modifying a sort routine <goldbb2@earthlink.net>
Re: Help with a tough algorithm <goldbb2@earthlink.net>
Help with simple while loop (Rashyid)
Re: Help with simple while loop <echang@netstorm.net>
Re: Help: simple perl question on Windows (Garry Williams)
Re: hi <goldbb2@earthlink.net>
How to assign initial value to variable? <spamfree@go-away.net>
is there a function... <sidarous@isr6132.urh.uiuc.edu>
Re: is there a function... <wyzelli@yahoo.com>
Re: is there a function... <mikesl@wrq.com>
Re: is there a function... <wyzelli@yahoo.com>
Re: is there a function... (Tad McClellan)
Re: Leftmost SHORTEST <goldbb2@earthlink.net>
Re: Leftmost SHORTEST <goldbb2@earthlink.net>
NOTICE: Perlfaq updates (Chris Fedde)
Re: NOTICE: Perlfaq updates <uri@stemsystems.com>
Re: One for the Perl Wizards... (mario)
Posting manual pages to clpm? (Chris Fedde)
Re: Posting manual pages to clpm? <wyzelli@yahoo.com>
Re: Problem with make while installing Perl 5.6.1 on So (Real Newbie)
Re: range operator and look ahead <goldbb2@earthlink.net>
Re: removing a file extension from list data. <goldbb2@earthlink.net>
Sending Data to a Printer? <newsgroup_mike@ultrafusion.co.uk>
Re: simple perl question on Windows <hkdennis2k@yahoo.com.hk>
Re: strange behavior from cgi inside protected director <wyzelli@yahoo.com>
Re: Untainting globally with regular expression? <spamfree@go-away.net>
Re: using a variable in a subroutine name <mjcarman@home.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 06 Nov 2001 23:58:21 GMT
From: "Marshall Spight" <mspight@dnai.com>
Subject: Re: Best language for low IQ programmers?
Message-Id: <xO_F7.3475$Mt6.1789628@news1.rdc1.sfba.home.com>
"Joona I Palaste" <palaste@cc.helsinki.fi> wrote in message news:9s9pk1$rrt$2@oravannahka.helsinki.fi...
> Well technically JSP/Servlets and HTML are orthogonal technologies. For
> example, our company develops Servlets which do not necessarily have to
> output HTML.
True enough. Still, I find it pretty wacky to have been passed over
for something because of a missing ten cent technology, when I
had hundred dollar skills listed on my resume.
Marshall
------------------------------
Date: Tue, 06 Nov 2001 22:11:28 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Can't call method "add_handler" error.
Message-Id: <3BE8A660.E91D06F0@earthlink.net>
Scott wrote:
[snip]
> my $conn = $aim->newconn(Screenname => 'aimhandle',
> Password => 'password')
> or die "Can't connect to AIM server.\n";
>
> $conn->add_handler('config', \&on_config);
[snip]
> However, when I try to run it, I get the following error message:
> Can't call method "add_handler" without a package or object reference
> at ./aim_message.pl line 13
Right after the 'use strict;' line at the top of your script, add a line
'use diagnostics;' That will tell you where that error message is
coming from. Hint: it's not coming from AIM, but from Perl.
--
Klein bottle for rent - inquire within.
------------------------------
Date: Tue, 06 Nov 2001 21:57:22 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Failed scripts leave Perl behind
Message-Id: <3BE8A312.52064B48@earthlink.net>
Ralph Snart wrote:
>
> Ken wrote:
> >Thanks for your thoughts. Although I have this urge to drop Perl and
> >go to PHP, Python, or even VBScript I suspect all of these languages
> >may suffer the same fate. Any script is activated when its URL is
> >touched. But that touch lasts only a momnet. Its just not possible to
> >tell when a user has lost interest.
>
> apache kills the perl script when you leave the page in your browser.
[snip]
> here is my test script:
>
> #!/usr/bin/perl
>
> print "Content-type: text/plain\n\n";
> print "foo\n" while 1;
It's not apache that's killing your script, it's the SIGPIPE which gets
raised when you try to print to a closed socket.
Try this from the shell:
(sleep 1; echo foo) | ( exec 0<&-; sleep 2 )
[untested]
The two sides execute in parallel; the sleep 1 ensures that the echo on
the left occurs after the exec on the right, but before the sleep 2 on
the right finishes. The exec closes fd 0, so that the echo ends up
trying to write to a closed pipe. The result is a SIGPIPE, which kills
the command.
--
Klein bottle for rent - inquire within.
------------------------------
Date: Tue, 06 Nov 2001 22:07:01 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Failed scripts leave Perl behind
Message-Id: <3BE8A555.23206624@earthlink.net>
Ken wrote:
>
> Thanks for your thoughts. Although I have this urge to drop Perl and
> go to PHP, Python, or even VBScript I suspect all of these languages
> may suffer the same fate. Any script is activated when its URL is
> touched. But that touch lasts only a momnet. Its just not possible to
> tell when a user has lost interest.
Actually, it is possible to tell when a user has lost interest... at
least, on unix it is. Simply have the program produce some output every
once in a while -- a blank line, for example -- and the program will die
when the user hits the stop button on their browser, due to SIGPIPE
being raised. You can even, if you want, add a $SIG{PIPE} handler, so
your script can exit cleanly instead of being killed by the signal.
Windows doesn't have unix signals... Perl emulates a few signals -- for
example, it emulates SIGINT so you can catch control-C -- but not all.
There might not be any kind of Windows Perl SIGPIPE emulation -- if not,
then you're probably out of luck... I don't know of any other way to
detect, from the writing end, that a socket has closed [which is what
you need to do to detect that the user has hit 'stop' on their browser].
--
Klein bottle for rent - inquire within.
------------------------------
Date: Wed, 07 Nov 2001 03:45:50 GMT
From: garry@ifr.zvolve.net (Garry Williams)
Subject: Re: Failed scripts leave Perl behind
Message-Id: <slrn9uhbje.58v.garry@zfw.zvolve.net>
On Tue, 06 Nov 2001 22:07:01 -0500, Benjamin Goldberg
<goldbb2@earthlink.net> wrote:
> I don't know of any other way to
> detect, from the writing end, that a socket has closed [which is what
> you need to do to detect that the user has hit 'stop' on their browser].
Set the socket non-blocking. Read from the socket. A return of zero
indicates the socket is closed. A return of -1 with EWOULDBLOCK
indicates the socket is still "alive". See read(2).
--
Garry Williams
------------------------------
Date: 6 Nov 2001 15:36:36 -0800
From: clayk@acu.edu (Keith Clay)
Subject: getting just the variable names from inputs in a form
Message-Id: <8947fc5.0111061536.70988ec@posting.google.com>
Folks,
I am trying to get the variable names on a form in an HTML document.
I want to be able to validate that the variable names are valid before
it is published so I am reading the file directly off disk.
keith
------------------------------
Date: Tue, 6 Nov 2001 17:01:47 -0800
From: "Greg Muth" <gamu829@yahoo.com>
Subject: Re: getting just the variable names from inputs in a form
Message-Id: <tuh200cqldhqdf@corp.supernews.com>
If you have CGI.pm, this should do it:
use CGI;
my $cgi = new CGI;
my @fields = $cgi->param();
# @fields is a list/array of all the fields from the form
GM
"Keith Clay" <clayk@acu.edu> wrote in message
news:8947fc5.0111061536.70988ec@posting.google.com...
> Folks,
>
> I am trying to get the variable names on a form in an HTML document.
> I want to be able to validate that the variable names are valid before
> it is published so I am reading the file directly off disk.
>
> keith
------------------------------
Date: Wed, 07 Nov 2001 04:28:10 GMT
From: laporte1@charter.net (Scooby)
Subject: Help Installing Modules (CPAN) problems
Message-Id: <3be8b1fd.11742785@news.charter.net>
Can someone Please help a very frustrated CPAN newbee.
I need to install the following modules on my Red Hat 7.1
linux box in order to get a script to run called "dnsping". The
script calls for the following modules.
MD5, Crypt::PasswdMD5, LWP::Simple, URI::Escape.
Every time I try running the scipt I get this error
[root@falcon scripts]# ./dnsping
Can't locate Crypt/PasswdMD5.pm in @INC (@INC contains:
/usr/lib/perl5/5.6.0/i386-linux /usr/lib/perl5/5.6.0
/usr/lib/perl5/site_perl/5.6.0/i386-linux /usr/lib/
perl5/site_perl/5.6.0 /usr/lib/perl5/site_perl .) at ./dnsart_connect
line 54.BEGIN failed--compilation aborted at ./dnsart_connect line 54.
Below is a snipit from the script dnsping found at
www.dnsart.com. The script is supposed to update a central dns server
of any ip changes that occur on a linux box using a dynamic ip
connection to the internet.
##################################################
#
# Art of DNS FreeBSD / Linux client
# Copyright (C) 2001 ZeroHype Technologies Inc.
# support@dnsart.com
# 22-Jan-2001
#
# Requires the following modules (available from CPAN):
#
# Crypt::PasswdMD5 (relies on Digest::MD5)
# LWP::Simple
# URI::Escape
#
# The easiest way to get these modules is:
# perl -MCPAN -eshell
# then at the cpan> prompt type:
# install MD5
# install Crypt::PasswdMD5
# install LWP::Simple
# install URI::Escape
# for whatever modules you are missing
#
# Usage:
# dnsping [hostname] [password]
# where hostname and password can both be
# hardcoded in the program file. (See above)
#
# Revision History:
#
# v1.0.1 22 Jan 2001 (JasonW)
# - Added support to connect on
# alternate port, to bypass HTTP proxies.
#
# v1.0.0 09 Jan 2001 (JasonW)
# - Initial version
#
##################################################
Note: I have followed the instructions and configured CPAN using
#perl-MCPAN -e shell, Then I used the defaults to configure cpan.
The problem is that I can't get CPAN to acutally work. I have tried
to do installs for the required modules and I keep getting these
errors
***************************************************
this error occurs when I start CPAN
***************************************************
#perl -MCPAN -e shell
Use of uninitialized value in pattern match (m//) at
/usr/lib/perl5/5.6.0/Term/Cap.pm line 284.
cpan shell -- CPAN exploration and modules installation (v1.52)
****************************************************
****************************************************
Then If I try to install a module I get this error
****************************************************
cpan>install Crypt::PasswdMD5
Please, install Net::FTP as soon as possible. CPAN.pm installs it for
you if you just type
install Bundle::libnet
****************************************************
I have tryed to install Bundle::libnet, and I just keep getting the
same error asking me to install Bundle::libnet. I even tryed
reconfigureing CPAN by doing this
cpan>o conf init
That allowed me to get to the point where it asked me about proxy's
etc, and then the question started again.
Please, install Net::FTP as soon as possible. CPAN.pm installs it for
you if you just type
install Bundle::libnet
Could someone please help me to get this CPAN installer
working, or could you tell me how to actually install the modules
manually vs using CPAN if it can't be used?
Please feel free to email me at "laporte1@charter.net"
thank you
Dave LaPorte
------------------------------
Date: Tue, 06 Nov 2001 20:15:49 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Help modifying a sort routine
Message-Id: <3BE88B45.9BC4E8D0@earthlink.net>
Mark Bright wrote:
>
> Hi all,
>
> I was wondering if anyone can help me with this sort routine.
> I am currently running the following sub:
>
> sub sort_link {
> # --------------------------------------------------------
> #
> my (@unsorted) = @_;
> my ($num) = ($#unsorted+1) / ($#db_cols+1);
> my (%sortby, $hit, $i, @sorted);
>
> for ($i = 0; $i < $num; $i++) {
> $sortby{$i} = $unsorted[$db_sort_links + ($i * ($#db_cols+1))];
> }
> foreach $hit (sort {
> return lc($sortby{$a}) cmp lc($sortby{$b});
> } (keys %sortby)) {
> $first = ($hit * $#db_cols) + $hit;
> $last = ($hit * $#db_cols) + $#db_cols + $hit;
> push (@sorted, @unsorted[$first .. $last]);
> }
> return @sorted;
> }
>
> This sorts all links in my database alphabetically, what I want to do is
> have the links sorted alphabetically but starting at a particular letter.
> ie. if the trigger is "C" the database is sorted starting at "C" and ending
> at "B" and if the trigger is "M" links are listed starting at "M" and ending
> at "L" etc.
>
> The trigger I get from sub rotate_alphabet which returns $newtrigger where
> @alpha[$newtrigger] is the letter for the links to be sorted from for
> that day.
In other words, you want it so that if the trigger is M, then items
which
start out in the range A..Z end up sorted to M..Z,A..L ... rotated.
I can do that, I guess.
sub sort_rotated {
my ($rotate_to) = shift =~ m/([a-zA-Z])/;
$rotate_to = "a" unless defined $rotate_to;
(my $rotate_from = lc $cycle_start) =~ tr/a-z/za-y/;
my $index = int $db_sort_links;
my $fix = eval qq[ # eval is needed since tr doesn't interpolate.
sub {
my \$x = lc \$_->[$index];
substr(\$x,0,1) =~ tr/$rotate_to-za-$rotate_from/a-z/;
\$x;
}
];
my @unsorted;
push @unsorted, [splice @_, 0, @db_cols] while @_;
return
map @{$_->[1]},
sort { $a->[0] cmp $b->[0] }
map [ &$fix, $_ ],
@unsorted;
}
NB: This code is untested.
Call the function as @data = sort_rotated("M", @data).
The function would have been slightly easier to write if the data were a
list of lists, rather than a flat list, but oh well... you can see where
I turn it into a LoL in @unsorted, and then flatten it back out with map
@{$_->[1]}.
The part below that is a perfectly ordinary Swartzian transform.
The part above that is dynamic creation of the function used in the
transform, and is needed mainly since tr/// doesn't do interpolation.
--
Klein bottle for rent - inquire within.
------------------------------
Date: Tue, 06 Nov 2001 19:27:21 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Help with a tough algorithm
Message-Id: <3BE87FE8.6AB06D0E@earthlink.net>
Tommy Butler wrote:
>
> Can somebody help me out with an algo?
>
> I'm trying to get a six-character string *in stepped sequence* from
> the array of possible unique six-character strings for the character
> class of [a-zA-Z0-9_].
[snip]
> The way I've been planning to track the current position of the
> algorithm in the array between sessions is to use a simple flat-file
> database containing only the integer representative of the array index
> where the algo left off after the previous cgi-session ended.
Your problem statement is a bit confusing. I *think* you are asking us
how to do one of two things [I'm not sure which you're asking].
Possibility one:
How do I count, in base 63, from aaaaaa to ______ [that is, in decimal
from 0..63**6-1, but outputting in base 63]... that is, unique meaning
that no number is printed twice.
This is relatively simple.
use Fcntl qw(:flock);
open( my($counter), "<+", "counter" ) or die $!;
flock $counter, LOCK_EX or die $!;
$_ = read( $counter, (my $buffer = "\0" x 6), 6 );
$_ == 0 || $_ == 6 or die $!;
seek( $counter, 0, 0 ) or die $!;
for( 0..5 ) {
last if ++vec( $buffer, $_, 8 ) < 63;
vec( $buffer, $_, 8 ) = 0;
}
print $counter $buffer or die $!;
close $counter or die $!;
$buffer =~ tr/\000-\076/a-zA-Z0-9_/;
print scalar(reverse($buffer)), "\n";
Possibility two:
Like the above, but with the requirement that no digits be repeated
within any 6-digit string.
for( 0..5 ) {
last if ++vec( $buffer, $_, 8 ) < (63-$_);
vec( $buffer, $_, 8 ) = 0;
}
print $counter $buffer or die $!;
close $counter or die $!;
my @x = ('A'..'Z','a'..'z',0..9,"_");
print reverse map splice(@x, vec($buffer, $_, 8), 1), 0..5;
print "\n";
NB: This code is untested.
If I'm misinterpreting 'unique' in your requirements, please say so.
--
Klein bottle for rent - inquire within.
------------------------------
Date: 6 Nov 2001 18:48:04 -0800
From: rra@excite.com (Rashyid)
Subject: Help with simple while loop
Message-Id: <79c1319c.0111061848.2963fbd7@posting.google.com>
Hi heres a 'lil piece of code,
do {
open(IN, "/home0/script/update_proc_out.sql");
foreach $item (<IN>){ # Visit each item in turn
# and call it $item
if($item =~ /procs/){
foreach $line ($item){
if($line =~ /procs/){
chomp($line);
print "$line\n";
if ($line = ' procs 0'){
print "end";
$flag ="false";
}
}
}
}
}
close(IN);
}
while ( $flag != 'false')
#end
What i need it to do is to go through an input file and get a line
which states 'procs' and then a number.. I need it to print out the
number until it becomes 'procs 0'. The thing is the if statement gets
ignored when there is a procs 0 in my input file. Anybody can help me
here?
RRA..
------------------------------
Date: Wed, 07 Nov 2001 04:00:51 GMT
From: "E.Chang" <echang@netstorm.net>
Subject: Re: Help with simple while loop
Message-Id: <Xns9151EB1EC3AFFechangnetstormnet@207.106.92.86>
rra@excite.com (Rashyid) wrote in
news:79c1319c.0111061848.2963fbd7@posting.google.com:
> Hi heres a 'lil piece of code,
This looks suspiciously like a homework exercise. Here are a few
comments, but you need to figure out what to do about them.
Was $flag initialized up here somewhere?
> do {
You are opening only one file, so ther is no point to a loop here.
> open(IN, "/home0/script/update_proc_out.sql")
Always check the return from open - look for examples using "or die
...".
> foreach $item (<IN>){ # Visit each item in turn
> # and call it $item
Your variables should be lexically scoped using "my".
#Slurp the entire file into an array
#of lines. Iterate over the array.
Why not call it $line, since it's a line, not an "item", (whatever that
means).
> if($item =~ /procs/){
> foreach $line ($item){
Huh? $item is already one single line from the file. There's nothing
more to iterate over. You're basically making a one-element list and
repeating your test.
> if($line =~ /procs/){
You already know it matches the pattern - it's just $item again.
> chomp($line);
> print "$line\n";
One line giveth and the other taketh away, or something like that.
> if ($line = ' procs 0'){
"=" is the asignment operator. You want to test for string equality.
> print "end";
> $flag ="false";
Do you want to merely print "end" or actually terminate the loop here.
Look up the functions related to control flow of a program (in the
perlfunc manpage, which you can find at perldoc.com).
> }
> }
> }
> }
> }
> close(IN);
>
> }
> while ( $flag != 'false')
By the time you reach this test, the foreach loop has finished going
through the entire array of lines. $flag serves no purpose at this
point.
>#end
>
> What i need it to do is to go through an input file and get a line
> which states 'procs' and then a number.. I need it to print out the
> number until it becomes 'procs 0'. The thing is the if statement gets
> ignored when there is a procs 0 in my input file. Anybody can help me
> here?
You're making the problem too complicated, with twice as many loops and
conditionals than you really need.
--
EBC
------------------------------
Date: Wed, 07 Nov 2001 03:54:54 GMT
From: garry@ifr.zvolve.net (Garry Williams)
Subject: Re: Help: simple perl question on Windows
Message-Id: <slrn9uhc4e.58v.garry@zfw.zvolve.net>
On 6 Nov 2001 07:00:09 -0800, Araxes Tharsis <pnrmaia@hotmail.com>
wrote:
> I want to run the following script on Windows 2000, receiving input
> from the file employees.txt. In UNIX it is:
> MyScript.pl < employees.txt
> But it is not working in Windows.
Hmmm. I guess I have to guess what that means. It's really no help
to say "it is not working".
> $i = 0;
> while(<STDIN>)
while (<>)
> {
> m#\w+\s+(\w+)#;
> print("$1\n");
> ++$i
> }
> print("$i records found.");
C:\> MyScript.pl employees.txt
You are probably fighting the lame Windows shell. Try bash, if you
want something sane. (Install Cygwin.)
Enable warnings. Enable strictures.
--
Garry Williams
------------------------------
Date: Tue, 06 Nov 2001 22:35:30 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: hi
Message-Id: <3BE8AC02.DEFE1BDF@earthlink.net>
hugo wrote:
>
> Hi
>
> I have a perl file with text boxes that users can fill in. The
> contents of the text boxes is stored in a mysql database. This all
> works fine, except when someone puts a apostrophe ' character in a
> text box e.g., something like:
>
> Company's web site.
>
> When you have something with a ', all entries from all text boxes on
> the perl page are emptied out of mysql, presumably because the '
> character messes with the INSERT statement and terminates it early.
> Note that the contents of the text boxes are retrieved with perl's
> param function using CGI.pm and stored in variables. Subsequently,
> these variables are used in the mysql INSERT statement when a call is
> made to the mysql database.
Doctor, it hurts when I do this.
Don't interpolate the data from the CGI query directly into the mysql
INSERT statement. Use placeholders instead.
my @fields = qw(field1 field2 field3);
my @places = ("?") x @fields;
$dbh->do( do { local $" = ", "; qq[
INSERT INTO mytable (@fields) VALUES (@places)
] }, undef, map { $cgi_query->param($_) } @fields );
> How can I have people include the ' character without it causing
> problems for mysql?
If you really and truly feel the need to mix your cgi-query information
with the constructed sql statement [and I would advise against it], you
would use $dbh->quote to munge the data so it could be interpolated
safely.
my @fields = qw(field1 field2 field3);
my @values = map {
my $value = $cgi_query->param($_);
my $escaped = $dbh->quote($value);
"'" . $escaped . "'";
} @fields;
$dbh->do( do { local $" = ", "; qq[
INSERT INTO mytable (@fields) VALUES (@values)
] } );
By the way, Mark Goodge responded to your post saying that simply
replacing all ' with \' would work... MAYBE this will, for mysql [I
don't know what mysql does for quoting], but I would seriously adivse
against doing this. Different databases use different escaping. Many
escape quotes by doubling them. The quote() method of the DBI object
*will* get it right, regardless of what quoting method the database
uses. If you change databases, and you are quoting yourself with s///,
it's entirely possible that you'll end up using the wrong quoting method
for the new driver, and you'll be pulling your hair out wondering what's
going wrong. Just use $dbh->quote and you'll make your life in the
future easier. [That is, if you do need to interpolate -- I advise
placeholders, which lets you avoid the issue of quotes].
--
Klein bottle for rent - inquire within.
------------------------------
Date: Wed, 07 Nov 2001 03:11:14 GMT
From: "spamfree" <spamfree@go-away.net>
Subject: How to assign initial value to variable?
Message-Id: <mD1G7.3931$3N6.574743@news1.cableinet.net>
#!/usr/bin/perl -Tw
use diagnostics;
use CGI qw(:standard);
use CGI::Carp qw(fatalsToBrowser);
Use of uninitialized value at
/home/sites/site13/web/cgi-bin/pre-register/pre-register.pl line 139 (#1)
(W) An undefined value was used as if it were already defined. It was
interpreted as a "" or a 0, but maybe it was a mistake. To suppress this
warning assign an initial value to your variables. [Wed Nov 7 03:05:59 2001]
pre-register.pl: Use of uninitialized value at
/home/sites/site13/web/cgi-bin/pre-register/pre-register.pl line 139.
<cut>
sub check_data{
if ($firstname =~ tr/a-zA-Z\n\t //c) {
$errormessage = "Special characters are forbidden. You used one in the
firstname field. ";
&errorpage;
exit;
}
{ $errormessage = 'The FIRSTNAME field is restricted to Max = 50
characters including spaces!' if length $firstname > 50;
&errorpage;
exit;
}
#------------------------------------------------------------------
#The above code checks and displays errormessage + errorpage (EOF)
#The next checks and displays errorpage only?
#
#------------------------------------------------------------------
if ( $surname =~ tr/a-zA-Z\n\t //c) {
$errormessage = "Special characters are forbidden. You used one in the
surname field. ";
&errorpage;
exit;
}
{ $errormessage = 'The SURNAME field is restricted to Max =
50 characters including spaces!' if length $surname > 50;
&errorpage;
exit;
}
sub errorpage{
print "Content-type: text/html", "\n\n";
print <<EOF; #Line 139
<html>
<head>
<title>ERROR!</title>
</head>
<body bgcolor="#FFFFFF">
<h1>We are sorry!</h1>
<p>The form was not filled in correctly.</p>
Here is the problem: <b>$errormessage</b>
<p>
Please use the "back button" of your browser to return to the form and
correct the mistake.
<p>
<font color="656565"><i><b>admin\@mydomain.com</b></i></font>
</body>
</html>
EOF
}
------------------------------
Date: Tue, 6 Nov 2001 17:51:08 -0600
From: Mark Sidarous <sidarous@isr6132.urh.uiuc.edu>
Subject: is there a function...
Message-Id: <Pine.LNX.4.33.0111061750170.23145-100000@isr6132.urh.uiuc.edu>
is there a function that drops a decimal point all the trailing characters
from a variable?
--
------------------------------
Date: Wed, 7 Nov 2001 09:31:35 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: is there a function...
Message-Id: <TQ_F7.20$2l6.128@wa.nnrp.telstra.net>
"Mark Sidarous" <sidarous@isr6132.urh.uiuc.edu> wrote in message
news:Pine.LNX.4.33.0111061750170.23145-100000@isr6132.urh.uiuc.edu...
> is there a function that drops a decimal point all the trailing characters
> from a variable?
Do you mean for 2.45644 just gives you 2? (the integer portion).
You want 'int'
perldoc -f int
Wyzelli
--
@x='074117115116032097110111116104101114032080101114108032104097099107101114
'=~/(...)/g;
print chr for @x;
------------------------------
Date: Wed, 07 Nov 2001 00:22:13 GMT
From: Michael Slass <mikesl@wrq.com>
Subject: Re: is there a function...
Message-Id: <m33d3rmnv2.fsf@thneed.na.wrq.com>
"Wyzelli" <wyzelli@yahoo.com> writes:
>
>Wyzelli
>--
>@x='074117115116032097110111116104101114032080101114108032104097099107101114
>'=~/(...)/g;
>print chr for @x;
This signature seems to work because ~=/(...)/g somehow splits the
string of digits into three-digit chunks. Where should I look in
the manual to see how this works?
Thanks.
-Mike
------------------------------
Date: Wed, 7 Nov 2001 10:15:37 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: is there a function...
Message-Id: <8u%F7.24$2l6.233@wa.nnrp.telstra.net>
"Michael Slass" <mikesl@wrq.com> wrote in message
news:m33d3rmnv2.fsf@thneed.na.wrq.com...
> "Wyzelli" <wyzelli@yahoo.com> writes:
>
> >
> >Wyzelli
> >--
>
>@x='07411711511603209711011111610410111403208010111410803210409709910710111
4
> >'=~/(...)/g;
> >print chr for @x;
>
>
> This signature seems to work because ~=/(...)/g somehow splits the
> string of digits into three-digit chunks. Where should I look in
> the manual to see how this works?
perlre
. in a regex matches 'anything' (with some conditions - see perlre)
so three . matches three 'anythings'
that is captured by the parens into $1
the g modifier forces 'global' mode which keeps on matching and returning as
long as possible and returning each match
by assigning to an array, each match is captured.
So it is just a matter of playing with the contents of the string to
construct the phrase you want...
Wyzelli
--
push@x,$_ for(a..z);push@x,' ';
@z='092018192600131419070417261504171126070002100417'=~/(..)/g;
foreach $y(@z){$_.=$x[$y]}y/jp/JP/;print;
------------------------------
Date: Wed, 07 Nov 2001 01:46:31 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: is there a function...
Message-Id: <slrn9uh204.cu6.tadmc@tadmc26.august.net>
Michael Slass <mikesl@wrq.com> wrote:
>"Wyzelli" <wyzelli@yahoo.com> writes:
>
>>
>>Wyzelli
>>--
>>@x='074117115116032097110111116104101114032080101114108032104097099107101114
>>'=~/(...)/g;
>>print chr for @x;
>
>
>This signature seems to work because ~=/(...)/g somehow splits the
>string of digits into three-digit chunks. Where should I look in
>the manual to see how this works?
perldoc perlop
--------------------------------------------------------------
The C</g> modifier specifies global pattern matching--that is,
matching as many times as possible within the string. How it behaves
depends on the context. In list context, it returns a list of the
substrings matched by any capturing parentheses in the regular
expression.
--------------------------------------------------------------
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 06 Nov 2001 20:28:39 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Leftmost SHORTEST
Message-Id: <3BE88E47.3F5A5012@earthlink.net>
Zilt wrote:
[snip]
> To rephrase, is there a gawk equivalent for /start_expr.*?end_expr/ ?
>
> Thanks!
What does this have to do with perl?
--
Klein bottle for rent - inquire within.
------------------------------
Date: Tue, 06 Nov 2001 20:48:52 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Leftmost SHORTEST
Message-Id: <3BE89304.BB6DDE23@earthlink.net>
Zilt wrote:
[snip]
> As far as
> I know, there's no way to NOT match an expression in gawk, e.g.
> /BEGIN(^END)*END/ would not work.
Ignoring the problem of this being a Perl newsgroup, not a gawk one, one
way of doing this in a non-greedy manner is as follows:
sub re_not {
my ($x) = @_;
return "(?:" . join( '|', reverse map {
my $y = chop $x;
"\Q$x\E[^\Q$y\E]";
}, 1 .. length $x) . ")*";
}
my $re = "BEGIN" . re_not("END") . "END";
$stuff =~ /$re/;
Or if you only do it in one or two places, and don't want to have it
constructed by a function:
$stuff =~ /BEGIN(?:[^E]|E[^N]|EN[^D])*END/;
It's highly probable that this kind of RE will work with gawk, too,
though of course you would have to use (), not (?:).
--
Klein bottle for rent - inquire within.
------------------------------
Date: Wed, 07 Nov 2001 03:07:11 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: NOTICE: Perlfaq updates
Message-Id: <zz1G7.502$X3.190510592@news.frii.net>
The current round of postings from the PerlFAQ Server represent
the most recent versions in the CVS archive at www.perl.org. As
always I count on your comments and fixes in helping the FAQ to
become a better and more useful document. Thanks to all who helped
out with this, You know who you are. Special thanks to Nat Torkington
and Ask Bjoern Hansen and all who make www.perl.org go.
If you feel so inclined, take a look at these FAQ postings with an
eye to what improvement can be made and any topics that have become
FAQ that are not well served. Feedback may be provided in at least
these four ways: You may post a follow-up to the posting. You may
send an e-mail reply to the posting address (faq@denver.pm.org).
You may join the perl-documentation list and ask to be given direct
access to the CVS archive. You may follow the directions in the
FAQ itself. I'm sure that there are other, more creative ways that
you may find but these are the ones that came quickly to mind.
Let's see, there are currently 301 sections, at 1 every 6 hours...
$ perl -le 'print scalar(localtime(time + 301*3600*6))'
Mon Jan 21 01:46:35 2002
I excited to see how much better the FAQ will be by next year!
CrF
--
This space intentionally left blank
------------------------------
Date: Wed, 07 Nov 2001 05:03:51 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: NOTICE: Perlfaq updates
Message-Id: <x71yjbuq6s.fsf@home.sysarch.com>
>>>>> "CF" == Chris Fedde <cfedde@fedde.littleton.co.us> writes:
CF> If you feel so inclined, take a look at these FAQ postings with an
CF> eye to what improvement can be made and any topics that have become
CF> FAQ that are not well served. Feedback may be provided in at least
CF> these four ways: You may post a follow-up to the posting. You may
CF> send an e-mail reply to the posting address (faq@denver.pm.org).
CF> You may join the perl-documentation list and ask to be given direct
CF> access to the CVS archive. You may follow the directions in the
CF> FAQ itself. I'm sure that there are other, more creative ways that
CF> you may find but these are the ones that came quickly to mind.
chris,
thanx for the FAQ bot and for editing it with the feedback and
such. will this updated version be the one to go into 5.8? also what
about getting places like perldoc.com to show the newest FAQ text?
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
-- Stem is an Open Source Network Development Toolkit and Application Suite -
----- Stem and Perl Development, Systems Architecture, Design and Coding ----
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: 6 Nov 2001 20:22:06 -0800
From: mgaffi@acxiom.com (mario)
Subject: Re: One for the Perl Wizards...
Message-Id: <9b89f882.0111062022.1bb0e325@posting.google.com>
Martien Verbruggen <mgjv@tradingpost.com.au> wrote in message news:<slrn9ueot5.flu.mgjv@martien.heliotrope.home>...
> On Tue, 06 Nov 2001 01:48:17 GMT,
> Tad McClellan <tadmc@augustmail.com> wrote:
> > Martien Verbruggen <mgjv@tradingpost.com.au> wrote:
> >
> >
> >>Don't put multiple comments on one line.
> >
> >
> > s/comments/statements/; # is what I'm sure Martien meant
>
> Indeed. Thanks.
>
> Martien
I must have been imagining! but I cannot recreate the problem now. All
i can think might have happened is that during my previous testing the
system (dec-osf1) was low on memory resources and using the index()
function may have caused the perl interpreter to run 'differently'.
Thanks all for the usefull hints.
Mario
------------------------------
Date: Wed, 07 Nov 2001 03:19:00 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: Posting manual pages to clpm?
Message-Id: <EK1G7.503$X3.203676160@news.frii.net>
What does everyone think about posting sections from the core manual
pages?
My thought is to post a section of the manual page once every 12
hours or so. A "section" might be the doc for one of the functions,
or an operator. The goal is two fold. First is to get these things
out there so that programmers have an opportunity to trip over
interesting features that they did not know about. Second is to
allow the gurus to comment on the accuracy and clarity of the prose
and code. Comments could be used by the documentation project to
improve the core manual.
Ideas, comments, threats?
--
This space intentionally left blank
------------------------------
Date: Wed, 7 Nov 2001 14:28:48 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: Posting manual pages to clpm?
Message-Id: <ub3G7.40$2l6.460@wa.nnrp.telstra.net>
"Chris Fedde" <cfedde@fedde.littleton.co.us> wrote in message
news:EK1G7.503$X3.203676160@news.frii.net...
> What does everyone think about posting sections from the core manual
> pages?
>
> My thought is to post a section of the manual page once every 12
> hours or so. A "section" might be the doc for one of the functions,
> or an operator. The goal is two fold. First is to get these things
> out there so that programmers have an opportunity to trip over
> interesting features that they did not know about. Second is to
> allow the gurus to comment on the accuracy and clarity of the prose
> and code. Comments could be used by the documentation project to
> improve the core manual.
>
> Ideas, comments, threats?
I think this is a good thing. Much of the documentation would benefit from
wide 'peer review'.
It may also stimulate some conversations such as 'I didn't understand
that...'
I would be willing to comment on sections of the documentation from time to
time if they appeared here.
Such postings can always be killfiled by those who want to avoid the
clutter.
Wyzelli
--
($a,$b,$w,$t)=(' bottle',' of beer',' on the wall','Take one down, pass it
around');
for(reverse(1..100)){$s=($_!=1)?'s':'';$c.="$_$a$s$b$w\n$_$a$s$b\n$t\n";
$_--;$s=($_!=1)?'s':'';$c.="$_$a$s$b$w\n\n";}print"$c*hic*";
------------------------------
Date: 6 Nov 2001 20:57:49 -0800
From: realnewbie2000@yahoo.com (Real Newbie)
Subject: Re: Problem with make while installing Perl 5.6.1 on Solaris 8
Message-Id: <a2b38b4d.0111062057.21f2c535@posting.google.com>
Got it. The problem was with the gcc 3.0.1 compiler - which is somwhow
different. A downgrade to gcc 2.95.3 solved the problem.
Rgds,
grotunda@earthlink.net (Greg Rotunda) wrote in message news:<28f9e19.0111060612.28836c4d@posting.google.com>...
> Hi,
> I got the exact same thing with pretty much the same conditions... I'm
> going to check with our resident guru and I'll post again...
------------------------------
Date: Tue, 06 Nov 2001 21:03:23 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: range operator and look ahead
Message-Id: <3BE8966B.8D1DE512@earthlink.net>
Brandon Metcalf wrote:
>
> I'm trying to figure out how to use the range operator (or other
> method) to accomplish what the code does below in order to avoid
> reading the entire file into memory at once. Basically, the code
> inserts a string of text after a certain block of text but before the
> next block starts indicated by the string Class.
How about this:
local $/ = ""; # paragraph mode for slightly increased speed.
my $foundit = 0;
while( <FILE_R> ) {
if( /Class/ && $foundit ) {
print FILE_W $text;
$foundit = 0;
}
print FILE_W;
$foundit = 1 if /Class $str/;
}
print FILE_W $text if $foundit;
--
Klein bottle for rent - inquire within.
------------------------------
Date: Tue, 06 Nov 2001 23:18:06 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: removing a file extension from list data.
Message-Id: <3BE8B5FE.54D5B830@earthlink.net>
Jon Fanti wrote:
>
> Hi, I have a script that very simply pulls fields from a filename and
> puts them into a list for me. The only problem with this is that the
> last field also palls the file extension!
>
> Here is the script (so far):
[snip]
> foreach (grep {/\.mp3?$/i } readdir(DIRHANDLE))
foreach (grep {s/\.mp3?$//i } readdir(DIRHANDLE))
# grep with side effects can be useful.
> {
> (my $artist,my $title) = (split /$EOFld/) [1,2];
my ($artist, $title) = (split /$EOFld/) [-2,-1];
> chomp ($title);
# no chomp needed, since readdir doesn't add newlines.
> print "Artist: $artist\n";
> print "Title: $title\n";
> }
--
Klein bottle for rent - inquire within.
------------------------------
Date: Wed, 07 Nov 2001 02:11:52 GMT
From: "Mike Mackay [Ultrafusion]" <newsgroup_mike@ultrafusion.co.uk>
Subject: Sending Data to a Printer?
Message-Id: <IL0G7.3692$3N6.536959@news1.cableinet.net>
Hi,
Is it at all possible to send the output of a perl programme, for
example maybe some contents from a database, to a printer?
I'm using Win98 with ActiveState Perl....incase that makes a difference,
which I'm sure it does.
Regards,
Mike Mackay.
------------------------------
Date: Wed, 7 Nov 2001 12:16:05 +0800
From: "Dennis" <hkdennis2k@yahoo.com.hk>
Subject: Re: simple perl question on Windows
Message-Id: <9sac4c$gfp1@rain.i-cable.com>
type employees.txt | myscript.pl
or
change
while(<STDIN>) and MyScript.pl < employees.txt
to
while(<>) and MyScript.pl employees.txt
--
Dennis
======
Homepage(chinese)
http://hkdennis2k.virtualave.net
------------------------------
Date: Wed, 7 Nov 2001 09:44:16 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: strange behavior from cgi inside protected directory
Message-Id: <M0%F7.23$2l6.47@wa.nnrp.telstra.net>
"textnews.casema.net" <kirsthul@casema.net> wrote in message
news:RYVF7.306$xK2.957@pollux.casema.net...
> Hello,
> I'm using the 'ennyform' cgi scripts from www.dtp-aus.com. They work
> fine when used in POST-ing a 'normal' html form: on using the 'back
> button' (or backspace key) on a cgi-output page it returns the
> original values of the filled-in form fields.
> However, if the same html page is behind a password protected
> directory, the back-button returns an *empty* (reset??) form.
>
> This behaviour applies to IE5, NS and Mozilla but *not* to Konqueror.
> The webserver is a WN 2.2.9, using authwn as authorisation module.
>
> Has anyone a clou and/or a work-around??
> Thanks.
Here is a sample "Y2K" compliance from one of the programs within that
package:
if($year>99) {$year=2000+($year-100);}else {$year="19$year";}
*Hint *
$year += 1900;
Anyone want to comment on the apparent quality?
Wyzelli
--
push@x,$_ for(a..z);push@x,' ';
@z='092018192600131419070417261504171126070002100417'=~/(..)/g;
foreach $y(@z){$_.=$x[$y]}y/jp/JP/;print;
------------------------------
Date: Wed, 07 Nov 2001 03:11:13 GMT
From: "spamfree" <spamfree@go-away.net>
Subject: Re: Untainting globally with regular expression?
Message-Id: <lD1G7.3930$3N6.574819@news1.cableinet.net>
<snipped>
Much wiser now and happier for it!
Thanks
--
millside
_____________
------------------------------
Date: Tue, 06 Nov 2001 16:41:47 -0600
From: Michael Carman <mjcarman@home.com>
Subject: Re: using a variable in a subroutine name
Message-Id: <3BE8672B.1D651035@home.com>
Mark Jason Dominus wrote:
>
> In article <3BE83084.ACC43E8D@home.com>,
> Michael Carman <mjcarman@home.com> wrote:
> >
> >Ack! What you're trying to do is use a symbolic reference. Trust
> >me, you don't really want to do that.
>
> I'm not clear on why not. So far three people have said "you don't
> want to do that" without explaining what the problem might be.
>
> What's the problem?
I'm not sure how to take that, Mark. Are you implying that
a) I should have gone into more detail, as you do in
http://perl.plover.com/varvarname.html
b) I should have said that it won't work under 'use strict',
which all non-trivial programs should have.
c) You don't think that symrefs are a bad thing when used to
call subroutines?
> > my %send = (
> > email_zip => \&_send_email_zip,
> > email_txt => \&_send_email_txt,
> > cp_zip => \&_send_cp_zip,
> > cp_txt => \&_send_cp_txt,
> > );
>
> I think this comes under the heading of what Michael Schwern likes to
> call "Monkey Code". You have a table with four entries that encodes
> essentially no information. What's the benefit here?
>
> This is a serious question, by the way.
Fair enough. I don't think the hash is necessary, either. My first
thought was to put the subrefs directly into the loop:
foreach my $x (\&_send_email_zip, \&_send_email_txt,
\&_send_cp_txt, \&_send_cp_txt) {
# ...
}
but I felt that that might be unclear to the OP and that using a hash as
a dispatch table might be more easier to understand.
-mjc
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
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.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.
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 V10 Issue 2081
***************************************