[11603] in Perl-Users-Digest
Perl-Users Digest, Issue: 5203 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Mar 22 23:07:18 1999
Date: Mon, 22 Mar 99 20:00:21 -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 Mon, 22 Mar 1999 Volume: 8 Number: 5203
Today's topics:
AnyDBM_File vs. size <nessus@shell5.ba.best.com>
Re: array question (Mark P.)
CGI.pm questions melLA@west.net
Re: CGI.pm questions (Sam Holden)
Re: CGI.pm questions (Sam Holden)
Re: CGI.pm questions ffchopin@worldnet.att.net
choping off whitespace (Damon61)
Copying a file <pedrogarrett@mediaone.net>
Re: Copying a file (Alastair)
Dropped TCP Connection <lchang2@yahoo.com>
Re: Environment strings (ICG's)
Re: Environment strings <bret@bordwell.com>
Re: Executing another SCRIPT on a different SERVER (ICG's)
Re: Extreme Newbie here needs help <cassell@mail.cor.epa.gov>
Re: Extreme Newbie here needs help <info@blue.uk.com>
Re: Extreme Newbie here needs help <gwynne@utkux.utk.edu>
Re: Forwarding to home directory using Net::FTP <rmcvay@acm.org>
Re: HTML in email <silver+web@wirebird.com>
Re: integer size limit for modulus <cassell@mail.cor.epa.gov>
Perl WIN32 - How to return a DOS ErrorLevel? <bmoore3@standard.com>
regular expression with "*" <zlhu@iastate.edu>
Re: regular expression with "*" (Larry Rosler)
Re: removing ASCII chars < 32 <rick.delaney@home.com>
Re: removing ASCII chars < 32 <rick.delaney@home.com>
Re: removing ASCII chars < 32 (Brendan O'Dea)
Re: sendmail won't run on www ? (ICG's)
Re: String chopping <dickens@dreamgear.com>
Re: Want to learn Perl (ICG's)
Re: while (<@array>) ... fails when @array has 1000+ el (Alastair)
Re: while (<@array>) ... fails when @array has 1000+ el <ebohlman@netcom.com>
Re: Why don't wildcards expand on cmd line- win32 v5.00 <ebohlman@netcom.com>
Win32:EventLog and problems capturing data (Craig Vitter)
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 23 Mar 1999 01:52:20 GMT
From: "J. David Eisenberg" <nessus@shell5.ba.best.com>
Subject: AnyDBM_File vs. size
Message-Id: <36f6f3d4$0$211@nntp1.ba.best.com>
I have a text file with some 27000 records in it.
Each file begins with an eight-digit (unique) number.
When, on my PC running Linux and perl 5.005_02, I create a database
using the eight-character digit string as key and the
entire line as a value, the 4 megabyte file grows to about
7 megabytes; not a big problem. (The resultant file is
called "mydata.db")
When I transfer the perl code and original text file to
a different Unix system (I think it's sgi) and run perl
5.005_02, the program generates about 3000 records before
it dies, as the resulting file ("mydata.pag") is over 90
megabytes and I'm out of room. There's also a file called
"mydata.dir" I could expect a small difference in resultant
file sizes, but this is way out of proportion.
Any hints would be greatly appreciated.
--
J. David Eisenberg http://www.best.com/~nessus
------------------------------
Date: Tue, 23 Mar 1999 01:56:25 GMT
From: mag@imchat.com (Mark P.)
Subject: Re: array question
Message-Id: <36f6f3e8.345966613@news.ionet.net>
What the script does is allow an upload to the server, but I
want to have control over the type of file uploaded. The easiest way
would be to make an array of file extensions and then do a match. The
problem I'm running into is this bit of code isn't doing a match.
I'm going to play around with it. First I'll print out the
array and what I'm getting from the input file so I can see just
whats going on. Then maybe I can figure this out.
On Mon, 22 Mar 1999 10:13:56 -0800, "David L. Cassell"
<cassell@mail.cor.epa.gov> wrote:
>Mark P. wrote:
>>
>> I'm trying to do a match of file extensions listed in an array with an
>> uploaded file, but my stuff aint working. Can someone see whats going
>> wrong here?
>>
>> $query -> import_names('Q');
>> $file_extension = $Q::file_to_upload-01;
>> $file_extension =~ /\.(.*)$/is;
>> if ($file_extension) {
>> foreach $extension (@extension) {
>> if ($file_extension =~ m/$extension/i) {
>> $check_extension = 1;
>> last;
>> }
>> }
>> }
>> else {
>> $check_extension = 1;
>> }
>> if ($check_extension != 1) { &error2; }
>
>We'd like to help. Really. But it's hard when you don't tell us
>what your code is *supposed* to do. I can see a few things that
>might be related to your problem. One is that your first regex
>is greedy. If your file is named my.cool.file.txt the regex
>will return 'cool.file.txt' instead of 'txt'. Change the
>(.*) to (.*?) . The 's' on the end is probably not needed either.
>
>As for other problems, I can't tell from here.
>
>David
>--
>David L. Cassell, OAO cassell@mail.cor.epa.gov
>Senior computing specialist
>mathematical statistician
------------------------------
Date: Tue, 23 Mar 1999 02:05:14 GMT
From: melLA@west.net
Subject: CGI.pm questions
Message-Id: <36f6f636.4331452@news.west.net>
Hi,
I'm in the process of chucking my Perl 4 form-processing routines and
start from scratch using the magnificent CGI.pm routines. I just read
the entire CGI.pm documentation and have some questions in that
regard.
How does CGI.pm handle the function of ReadParse other than providing
a backward-compatible module for it? All the form building examples in
CGI.pm consisted of a form being built, then queried for parameters on
the same document. Does the param() subroutine parse the input buffer
for parameters as ReadParse does? Could I use param() on forms that
I've already built the old-fashioned way?
Near the end of CGI.pm Lincoln Stein makes disparaging remarks about
the module and suggests that it be dissed in favor of CGI::* modules.
But I examined some of those such as CGI::Request, CGI::Form,
CGI::Cookie, and CGI::Carp and found that CGI::Cookie "uses" CGI. What
was the point of recommending a module that depends on CGI.pm?
Besides, the other modules use additional modules that CGI doesn't
need. I'm afraid to use some of those CGI::* modules because I may not
be able to install their extra required modules on my "make"-less
ISP's server. Getting rid of CGI.pm means importing Exporter,
overload, URI::Escape, and CGI::BasePlus. If any of those modules
require the make program, I can't install them.
Finally, I can't figure out what CGI::Carp does that the cgiDie("Error
msg $!\n") can't do, if all I want to do is send an error message to
the browser.
I need guidance on these CGI.pm issues.
Thanks,
Milt
(remove all CAPS from my e-addr)
x-no-archive: yes
------------------------------
Date: 23 Mar 1999 02:17:32 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: CGI.pm questions
Message-Id: <slrn7fduds.500.sholden@pgrad.cs.usyd.edu.au>
On Tue, 23 Mar 1999 02:05:14 GMT, melLA@west.net <melLA@west.net> wrote:
>Hi,
>
>How does CGI.pm handle the function of ReadParse other than providing
>a backward-compatible module for it? All the form building examples in
>CGI.pm consisted of a form being built, then queried for parameters on
>the same document. Does the param() subroutine parse the input buffer
>for parameters as ReadParse does? Could I use param() on forms that
>I've already built the old-fashioned way?
CGI.pm does the ReadParse automatically. You can use param() on forms created
any way you like.
>Finally, I can't figure out what CGI::Carp does that the cgiDie("Error
>msg $!\n") can't do, if all I want to do is send an error message to
>the browser.
CGI::Carp causes croak, confess, carp, warn, and die to output to the browser
instead of to the server logs. That means that messages generated by perl
itself, or by other modules will also go to the browser.
--
Sam
You are bordering on ridiculous if you think you need to support your
premises. Such an argument is an infinite regression.
--George Reese in <wv0O1.1521$Ge.4809664@ptah.visi.com>
------------------------------
Date: 23 Mar 1999 03:02:26 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: CGI.pm questions
Message-Id: <slrn7fe122.6eo.sholden@pgrad.cs.usyd.edu.au>
On 23 Mar 1999 02:17:32 GMT, Sam Holden <sholden@pgrad.cs.usyd.edu.au> wrote:
>
>CGI::Carp causes croak, confess, carp, warn, and die to output to the browser
>instead of to the server logs. That means that messages generated by perl
>itself, or by other modules will also go to the browser.
I lied it sends it to the error log with a nice time stamp...
--
Sam
Basically, avoid comments. If your code needs a comment to be
understood, it would be better to rewrite it so it's easier to
understand. --Rob Pike
------------------------------
Date: 23 Mar 1999 03:43:04 GMT
From: ffchopin@worldnet.att.net
Subject: Re: CGI.pm questions
Message-Id: <36f70ba6.8501871@netnews.worldnet.att.net>
On 23 Mar 1999 03:02:26 GMT, sholden@pgrad.cs.usyd.edu.au (Sam Holden)
wrote:
>On 23 Mar 1999 02:17:32 GMT, Sam Holden <sholden@pgrad.cs.usyd.edu.au> wrote:
>>
>>CGI::Carp causes croak, confess, carp, warn, and die to output to the browser
>>instead of to the server logs. That means that messages generated by perl
>>itself, or by other modules will also go to the browser.
>
>I lied it sends it to the error log with a nice time stamp...
Use the errorsToBrowser feature of CGI.pm to send errors to the
browser. I forget the syntax offhand, but I think it is just:
use cgi(errorsToBrowser)
If I am mistaken, please post a follow-up.
Jason Simms
------------------------------
Date: 23 Mar 1999 03:40:07 GMT
From: damon61@aol.com (Damon61)
Subject: choping off whitespace
Message-Id: <19990322224007.00961.00000576@ng-ch1.aol.com>
Can someone please tell me how to chop off the leading and trailing whitespace
of a string. It seems so simple, but i'm having trouble. Any help is greatly
appreciated.
Thanks,
Damen C.
------------------------------
Date: Mon, 22 Mar 1999 17:19:10 -0800
From: "Pedro Garrett" <pedrogarrett@mediaone.net>
Subject: Copying a file
Message-Id: <h_BJ2.3348$de1.1956@cmnws01.we.mediaone.net>
Here's a simple question. Is there a Perl function to copy a file?
------------------------------
Date: Tue, 23 Mar 1999 01:23:39 GMT
From: alastair@calliope.demon.co.uk (Alastair)
Subject: Re: Copying a file
Message-Id: <slrn7fdrcs.gb.alastair@calliope.demon.co.uk>
Pedro Garrett <pedrogarrett@mediaone.net> wrote:
>Here's a simple question. Is there a Perl function to copy a file?
The File::Copy module ;
perldoc File::Copy
HTH.
--
Alastair
work : alastair@psoft.co.uk
home : alastair@calliope.demon.co.uk
------------------------------
Date: Mon, 22 Mar 1999 17:23:49 -0800
From: Leo Chang <lchang2@yahoo.com>
Subject: Dropped TCP Connection
Message-Id: <36F6ED25.F96D04ED@yahoo.com>
I'm writing an http server in perl using non-blocking sockets. To make
the
socket non-blocking, I used fcntl and bitwise-ORed the existing
socket_flags
with O_NONBLOCKING. I'm looping through and (using IO::Select) checking
for
can_read and accepting connections if $sel->can_read(0) returns true.
The
socket is an IO::Socket::INET.
When I stress-test the server using a Windows tool called Socrates, I'm
seeing some dropped connections. (The server is on a Linux box, kernel
2.0.36, perl version 5.005_02, dual-Pentium Xeon machine.) Socrates
sees no
dropped connections when it hits Apache.
My first suspicion was the listen queue size, but I set that to be
larger
than the number of clients being simulated (20) by Socrates, and it
didn't
solve the problem. I had some suspicion that it might be a SO_LINGER or
a
TCP_NODELAY problem, but I'm not sure those will help. Also, I haven't
seen
any perl examples of a proper call to setsockopt to set those options.
Can anyone help or direct me to help?
Thanks.
-Leo
----
Leo Chang
Lchang@jumpsmart.com
------------------------------
Date: 23 Mar 1999 02:20:05 GMT
From: postmaster@uu.net (ICG's)
Subject: Re: Environment strings
Message-Id: <7d6tol$4tp@bgtnsc03.worldnet.att.net>
Okay, my turn.
Having read the previous responses, I agree that this is gonna be a stab in
the dark. When you go back to the site (after the six hours or so that you
mentioned), have you been somewhere else? Possibly have a different IP?
When you "immediately" go back to the site, to continue playing ( I ain't
gonna touch it) the game, are you still using the same "hit" on the site that
you originally used? If so, then the ENV variables are going to be the same.
You are basically in the same client/server session.
Keep in mind, that this assumes that you haven't been monkeying around with
the ENV variables in your program.
Now, to get a more coherent response from the group, I recommend that you post
the unruly code so that others may beat it into submission, or at least tell
you how.
In article <36F44E82.25CC@bordwell.com>, bret@bordwell.com wrote:
>This is a re-post, in hopes to get an answer....
>
>Hello world!
>
>Does anyone know of problems with the environment strings being kept
>and re-used after the process has finished running?
>
>I know, that sounds real cryptic... here's my problem:
>
>I'm writing an E-Mail game using HTML with two list selects, and a
>submit btn.
>After parsing the form, and getting the 'post'ed vars, everything goes
>smoothly.
>Subsequent plays made one after the other (I'm playing the game with
>myself), .... <<stuff deleted to preserve BW>>
------------------------------------------------------------
Not the postmaster. I hate SPAM.
Mark H. Mogk breeze <at> granis.net
------------------------------
Date: Mon, 22 Mar 1999 22:07:10 -0500
From: Bret Bordwell <bret@bordwell.com>
Subject: Re: Environment strings
Message-Id: <36F7055E.F0@bordwell.com>
Jonathan Stowe wrote:
> Give *US* a break - there might be some pretty clever people here but
> I am absolutely certain that none of them would list amongst their
> skills the remote viewing of other peoples code ...
>
> Seeing what happens is one thing but you could have written this in
> RPG/III as far as we know. Please post the bit of code you are having
> difficulty with.
1ST My apologies, the 'Give Me A Break' should have had a =) after it,
it was typed with a smile.
Yes, I understand your not a mind reader, or remote code reader... just
hoping that this may have been
a commen problem that I should be calling something like flush, or
whatever.
Below is the best I could truncate the code, since I don't know where
the offending piece is.
My guess is in what sets Config{'CurrentPlay'} and what sets
Config{'Turn'}, both in update_db.
Thanks
Bret
#!/usr/bin/perl
use CGI::Carp qw(fatalsToBrowser);
&get_date;
&parse_form;
&check_required;
&check_db;
&make_play;
&update_db;
&build_board;
&return_html;
&send_mail;
sub Is_3{
# removed for readability, no errors here
}
sub get_date {
# exact same code as FormMail from Mats script archive
}
sub parse_form {
%Config = ('Name1','', 'EMail1','',
'Name2','', 'EMail2','',
'CurrentPlay','', 'Turn','2',
'ColumnX','', 'PlayX','',
'GameUnique','', 'DateLastPlayed','',
'Reserved','',
'GameData','0000000000000000000000000000000000000000000000000',
'LastGameData','', 'required','', \
'print_blank_fields','', 'missing_fields_redirect','');
# remaining code exact same code as FormMail from Mats script archive
}
sub check_required {
# exact same code as FormMail from Mats script archive
}
sub check_db{
local($CurrentPlay);
dbmopen (%GAMES, "$basedir/$datafile",0666)
or die "Cant Open Game Data Base, Please Try Again: ";
if ($Config{'GameUnique'} eq '') { #must be a new game
$Config{'GameUnique'} = GetUnique;}
else{ @GameRecord = split(':', $GAMES{ $Config{'GameUnique'} });
$Config{'Name1'} = $GameRecord[0];
$Config{'EMail1'} = $GameRecord[1];
$Config{'Name2'}= $GameRecord[2];
$Config{'EMail2'}= $GameRecord[3];
$CurrentPlay = $GameRecord[4];
$Config{'Turn'} = $GameRecord[5];
$Config{'DateLastPlayed'} = $GameRecord[6];
$Config{'GameData'} = $GameRecord[7];
$Config{'LastGameData'} = $GameRecord[8];
if ($Config{'CurrentPlay'} != $CurrentPlay){
dbmclose(%Games);
&error('NotYourTurn');
}
}#end else
}
sub make_play {
# Local variables used in this subroutine
initialized. #
local(@GameArray,$P);
$x = $Config{'ColumnX'} ;
if ($x != '') # This is to insure this routine is not called on
first run!
{
$x = $Config{'ColumnX'} - 1 ;
$P = $x;
@GameArray = split(//,$Config{'GameData'});
while($GameArray[$x] == '0' && $x < 49)
{
$P = $x;
$x += 7;
}
if ($Config{'PlayX'} == 3 && !Is3($P))
{
&error('three_not_allowed');
}
if ($Config{'Turn'} eq '2')
{ # Toggle game pieces to yellow if player2 is making play.
$Config{'PlayX'} += 3;
}
$GameArray[$P] = $Config{'PlayX'};
$Config{'GameData'} = join '', @GameArray;
}
}
sub update_db{
local($x,@GA,$plays);
@GA = split(//,$Config{'GameData'});
$plays = 0;
for ($x = 0; $x < 49; $x++){
if ($GA[$x]){$plays++;}
}
$Config{'CurrentPlay'} = $plays;
$Config{'Turn'} = (3 - $Config{'Turn'});
$Config{'DateLastPlayed'} = time;
$GAMES{$Config{'GameUnique'}} = "$Config{'Name1'}:" .
"$Config{'EMail1'}:" .
"$Config{'Name2'}:" .
"$Config{'EMail2'}:" .
"$Config{'CurrentPlay'}:" .
"$Config{'Turn'}:" .
"$Config{'DateLastPlayed'}:" .
"$Config{'GameData'}:" .
"$Config{'LastGameData'}";
dbmclose(%Games);
}
sub build_board{
local($print_config,$key,$sort_order,$sorted_field,$env_report,@GameArray,$YandX,$IsRed,$TempStr);
@GameArray = split(//,$Config{'GameData'});
$header = "<html>\n";
$header .= "<head>\n";
$header .= "<TITLE>Seven</TITLE>\n";
$header .= "</HEAD>\n";
# REMOVED FOR READABILITY, NO ERRORS HERE
$header .= "<BODY TEXT=\"#000000\" LINK=\"#000080\"
VLINK=\"#008080\" BGCOLOR=\"#ffffff\" topmargin=0 leftmargin=0>\n";
$boardsection .= "</body>\n";
$boardsection .= "</html>\n";
$boardsection .= "</HTML>\n";
}
sub return_html {
print "Content-type: text/html\n\n";
print "<BASE HREF=\"http://www.bordwell.com/sevenhtml/images/\">\n";
print $header;
print $topsec1;
print $topsec2;
print $topsec3
print $topsec4
print $topsec5
print $boardsection;
}
sub send_mail {
# Open The Mail Program
open(MAIL,"|$mailprog -t");
print MAIL "Content-Type: text/html\n";
if ($Config{'Turn'} eq '1' )
{
print MAIL "To: $Config{'Name1'} <$Config{'EMail1'}>\n";
print MAIL "From: $Config{'Name2'} <$Config{'EMail2'}>\n";
}
else
{
print MAIL "To: $Config{'Name2'} <$Config{'EMail2'}>\n";
print MAIL "From: $Config{'Name1'} <$Config{'EMail1'}>\n";
}
print MAIL "Subject: It is your turn in Seven\n";
print MAIL "<BASE
HREF=\"http://www.bordwell.com/sevenhtml/images/\">\n";
# REMOVED FOR READABILTY, NO ERRORS HERE
close (MAIL);
# NOTE: This next lines are stupid, it's as if the server has a
memory, and needs to be re-set
$Config{'GameUnique'} = '';
$Config{'CurrentPlay'} = '';
}
sub check_email {
# REMOVED FOR READABILTY, NO ERRORS HERE
}
sub error {
# REMOVED FOR READABILTY, NO ERRORS HERE
}
------------------------------
Date: 23 Mar 1999 02:41:57 GMT
From: postmaster@uu.net (ICG's)
Subject: Re: Executing another SCRIPT on a different SERVER
Message-Id: <7d6v1l$nf6@bgtnsc03.worldnet.att.net>
In article <7cud2e$41c$1@client2.news.psi.net>, abigail@fnx.com wrote:
>Dale Sutcliffe (dales@enhanced-performance.com) wrote on MMXXVI September
>MCMXCIII in <URL:news:36F19392.B5309942@enhanced-performance.com>:
>|| How would I execute and pass information to another script on different
>|| server?
>
>Start up a socket connection to the other server.
>
>
>
>Abigail
BINGO!! Abigail is the bomb.
Make a port 80 call (or whatever port it's on) to the script in question. put
the info on the trailing end link it were part of a GET, PATH, or USER
PROVIDED VARIABLE. Capture the incoming HTML from the call, parse and do with
it what you want.
EXAMPLE:
#!/usr/bin/perl
use IO::Socket;
# ($host can be an IP address)
$host = 'www.somebody.net';
# (you can tack on whatever varable info you want to pass on the back of the
# document name.)
# $basedoc = '/cgi-bin/thescript';
# $myvar = "?something I assign to it";
# $document = $basedoc.$myvar;
# Note: I'm returning to the unadulterated version of $document, use the
# above if you want.
$document = '/cgi-bin/thescript';
$remote = IO::Socket::INET->new( Proto => "tcp",
PeerAddr => $host,
PeerPort => "http(80)",
);
unless ($remote) { die "cannot connect to http daemon on $host" }
$remote->autoflush(1);
print $host," ",$document;
print $remote "GET $document HTTP/1.0\n\n";
while ( <$remote> ) { print }
close $remote;
Now, what exactly you do with the result of the request depends on what it
gives you, or what you asked for. My opinion? This is gonna be a dog slow
way of doing it, and you will probably have to debug for a while to get it
right. I use something similar to this to scarf GIFs off of satellite imagery
pages so I can make my own animated GIFs. I haven't figured out how to
automate that yet. (getting them yes, putting them together, no. I may use
that fancy free Java based image viewer but haven't decided) Anyway, enough of
my tripe. Good luck!
------------------------------------------------------------
Not the postmaster. I hate SPAM.
Mark H. Mogk breeze <at> granis.net
------------------------------
Date: Mon, 22 Mar 1999 17:09:03 -0800
From: "David L. Cassell" <cassell@mail.cor.epa.gov>
Subject: Re: Extreme Newbie here needs help
Message-Id: <36F6E9AF.71957B15@mail.cor.epa.gov>
Spencer wrote:
> Hello,
>
> This may seem like a very stupid question but here goes.
Don't worry about that. We all had to start learning about Perl
somewhere. Except for Larry. [that's an in-joke :-]
> I am a college
> student and like to develop basic static web pages and have developed
> one for my fathers company but i would like to add more to it with CGI
> scripting. I was told that I could do this with the perl programming
> language ao I went out and bought the book Learning Perl by O`Reily
> publishing compnay. Igot the book and started to read it but I am kinda
> lost.
That can happen too. Most programming texts assume some sort of background
programming. That sounds sort of circular, doesn't it?
> First question, do I have to have a program or something to write with
> the perl language.
Nope. Any text editor will do. If you pick up something like nvi or
Emacs or PFE (the programmer's file editor), it will even do syntax
coloring and other nice stuff for you. But Perl doesn't require the
complex compile-debug-edit-repeat cycle of some languages.
> If so what program is it that I need.
>
> Second question is, I am using windows 95, is perl only for unix and
> servers and stuff.
While Perl is unix-oriented at heart, it runs just great on win 95,
win 98, and win NT. Go to www.activestate.com and get their ActivePerl
(build 509). Download it, and it will install itself as cleanly as any
other windows program. Then you can read all the docs and help files
that come with it, either using 'perldoc' at the MS-DOS prompt, or
using your preferred web browser to read the online docs (which the
install will politely drop where you want in your Start menu). There
is lots of information on using Perlscript within your CGI scripts too.
> Any help would be greatly appreciated.
Let me add that - while I think 'Learning Perl' is an excellent start,
you may find it operates at a level you're not ready for. That's
okay too. I have been told [note: this is hearsay, so take it as such]
that the SamsNet 'Learning *whatever* in 7*n Days' books for Perl and
Web programming may be a good start. I have also heard that the
Perl For Dummies book is chockful of errors and bad advice, so skip that
one.
When you're ready to write Perl code for a website, make sure you learn
about the CGI.pm module. It is the best way to write your code, and
it encapsulates a lot of pieces you might otherwise waste time re-
inventing.
> Thanks
> Aaron Spencer
HTH,
David
--
David L. Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Tue, 23 Mar 1999 01:20:06 -0000
From: "Matt" <info@blue.uk.com>
Subject: Re: Extreme Newbie here needs help
Message-Id: <7d6q2v$pr0$1@starburst.uk.insnet.net>
Hi
Welcome to the perl language.
I started with a great book called:
Creating cool web pages with perl by Jerry Muelver published by IDG books.
Very good book and very inteligent, despite the title.
You can visit Jerry's web site at www.hytext.com
I would advise alot of experimenting, you can get the software you need from
www.activestate.com they handle the perl interpreter for windows95 etc...
Good Luck, and stick with it,
Regards
Matt
Spencer wrote in message <36F6EC3A.218C@vci.net>...
>Hello,
>
>This may seem like a very stupid question but here goes. I am a college
>student and like to develop basic static web pages and have developed
>one for my fathers company but i would like to add more to it with CGI
>scripting. I was told that I could do this with the perl programming
>language ao I went out and bought the book Learning Perl by O`Reily
>publishing compnay. Igot the book and started to read it but I am kinda
>lost.
>
>First question, do I have to have a program or something to write with
>the perl language.
>
>If so what program is it that I need.
>
>Second question is, I am using windows 95, is perl only for unix and
>servers and stuff.
>
>Any help would be greatly appreciated.
>
>Thanks
>Aaron Spencer
------------------------------
Date: Mon, 22 Mar 1999 21:22:56 -0500
From: "Robert Gwynne" <gwynne@utkux.utk.edu>
Subject: Re: Extreme Newbie here needs help
Message-Id: <7d6u70$im0$1@gaia.ns.utk.edu>
Jon Orwant's Perl 5 Interactive Course is a thorough and well designed book
for learning Perl from the ground up. You don't have to know how to program
to get started.
---------------------------
Bob Gwynne
gwynne@utkux.utk.edu
Speech Comm
University of Tennessee, Knoxville
JAPN (Just Another Perl Newbie)
------------------------------
Date: Tue, 23 Mar 1999 01:17:59 GMT
From: Ray McVay <rmcvay@acm.org>
Subject: Re: Forwarding to home directory using Net::FTP
Message-Id: <36F6E43D.77D7E58C@acm.org>
"Kevin S (xS)" wrote:
>
> Well I feel like an idiot. My code was screwy and was always logging as
> anonymous. I had an if tag which was never called that logged in with an
> actual login. Thats why it went to root dir. You were 100% correct.
Hahaha! Been there, done that for sure! Glad you got it working.
--
Ray
+--------------------------------------------------+
+ I've gone to look for myself. If I should return +
+ before I get back, keep me here!! - Bill the Cat +
+--------------------------------------------------+
------------------------------
Date: 23 Mar 1999 02:07:47 GMT
From: Karen J. Cravens <silver+web@wirebird.com>
Subject: Re: HTML in email
Message-Id: <8D91C9940phoenyx@news.southwind.net>
"Brian" brian@removethisnet-weaver.com wrote in
<7d3tcg$cgi$1@winter.news.rcn.net>:
> print MAIL "From: $in{'author'}\n";
> print MAIL "Subject: Article Submission\n\n";
> print MAIL "Content-Type: \"text/html;\"\n\n";
You'll also want to add the header:
Mime-Version: 1.0
------------------------------
Date: Mon, 22 Mar 1999 17:16:04 -0800
From: "David L. Cassell" <cassell@mail.cor.epa.gov>
Subject: Re: integer size limit for modulus
Message-Id: <36F6EB54.7252DC5D@mail.cor.epa.gov>
dana watanabe wrote:
>
> Whenever i am using % with numbers above 2**32 i seem to be getting
> wrong information.
>
> I've tried this on a small handful of Un*x variants (solaris, freeBSD, linux)
> and had the same result on them all.
>
> To test the modulus i used:
>
> sub print_modulus {
> my $i=shift; $j=shift;
> printf "%.0f %% %.0f = %.0f\n",2**$i,2**$j+1,(2**$i)%(1+(2**$j));
> }
>
> $i=32; for (0..3) {print_modulus($i,$_)}
>
> and i got:
>
> 4294967296 % 1 = 0
> 4294967296 % 2 = 1
> 4294967296 % 4 = 3
> 4294967296 % 8 = 7
>
> Am i doing something wrong?
Not really. You've just gotten to the point where your
numbers are too big to fit in the storage allotted for
a signed integer on your machines. But Perl has a solution.
Of course. Download the Math::BigInt module from CPAN.
David
--
David L. Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Tue, 23 Mar 1999 03:05:48 GMT
From: "Brian Moore" <bmoore3@standard.com>
Subject: Perl WIN32 - How to return a DOS ErrorLevel?
Message-Id: <F911xn.89@standard.com>
I know it seems simple, but having gone through the PERL for Win32 docs, I
find nothing about returning the most basic of Windows cmd values, the
ERRORLEVEL.
I'm trying to use my Perl script within an existing (and complicated) DOS
batch program, and have the batch program make decisions based on the Perl
script results. So I want the Perl script to return a DOS ERROLEVEL (this
is the only way I know to reference results within a cmd shell, without
having to write a file). Any help is appreciated...
Brian Moore
bmoore3@standard.com
------------------------------
Date: Mon, 22 Mar 1999 21:00:16 -0600
From: Zhiliang Hu <zlhu@iastate.edu>
Subject: regular expression with "*"
Message-Id: <36F703BF.59DCCB5B@iastate.edu>
May be this is too simple to believe:
I wanted to catch any string of words comtaining an asterisk (*) in a
CGI program. I did the following:
While this worked for a simple asterisk (*) only:
if ($FORM{terms} eq "\*") { (some trapping codes) } else { (some
task codes) }
The following didn't work when more combinations were considered:
1. if ($FORM{terms} eq "\w*\*\w*") { (some
trapping codes) } else { (some task codes) }
2. if ($FORM{terms} eq "\w\s*\*\w\s*") { (some trapping
codes) } else { (some task codes) }
3. if ($FORM{terms} eq "[a-zA-Z+]*\*[a-zA-Z+]*") { (some trapping
codes) } else { (some task codes) }
4. if ($FORM{terms} eq "[a-zA-Z+]*\*[a-zA-Z+]*") { (some trapping
codes) } else { (some task codes) }
5. if ($FORM{terms} eq ".*\*.*") { (some
trapping codes) } else { (some task codes) }
and when I simply tested with an "m*" -- none of them worked (matched).
I wonder why? Could anyone suggest one that works so I can see why mine
is deficient?
Thanks!
Zhiliang
------------------------------
Date: Mon, 22 Mar 1999 19:42:19 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: regular expression with "*"
Message-Id: <MPG.1160ad7a4a80f28f9897a8@nntp.hpl.hp.com>
[Posted and a courtesy copy sent.]
In article <36F703BF.59DCCB5B@iastate.edu> on Mon, 22 Mar 1999 21:00:16
-0600, Zhiliang Hu <zlhu@iastate.edu >says...
> May be this is too simple to believe:
It is.
> I wanted to catch any string of words comtaining an asterisk (*) in a
> CGI program. I did the following:
>
> While this worked for a simple asterisk (*) only:
>
> if ($FORM{terms} eq "\*") { (some trapping codes) } else { (some
> task codes) }
That is because it asks if the test string is equal to the string
consisting only of '*'. (The backslash is irrelevant and misleading,
because '*' has no special properties in a string.)
> The following didn't work when more combinations were considered:
>
> 1. if ($FORM{terms} eq "\w*\*\w*") { (some
> trapping codes) } else { (some task codes) }
You are confusing the comparison of two strings for equality with the
matching of a regex against a string.
Replace 'eq "\w*\*\w*"' by '=~ /\w*\*\w*/' and try again (preferably
after reading the document 'perlre'). In particular, you will find that
your regex could as well be written simply as /\*/ -- until you
understand why, read perlre or an introductory chapter on pattern
matching again.
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personl/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Tue, 23 Mar 1999 02:09:32 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: removing ASCII chars < 32
Message-Id: <36F6F9D3.C8448D71@home.com>
[posted & mailed]
Abigail wrote:
>
> Bart Lateur (bart.lateur@skynet.be) wrote on MMXXIX September MCMXCIII
> in <URL:news:36f71c73.7597555@news.skynet.be>:
> ""
> "" $string =~ tr/\t\n / /s;
>
> That doesn't do what you think it does. There's no interpolation with
> tr.
Did you try that? What exactly do _you_ think it does?
--
Rick Delaney
rick.delaney@home.com
------------------------------
Date: Tue, 23 Mar 1999 02:15:37 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: removing ASCII chars < 32
Message-Id: <36F6FB41.2AB5FD8C@home.com>
[posted & mailed]
Ala Qumsieh wrote:
>
> bart.lateur@skynet.be (Bart Lateur) writes:
>
> > $string =~ s/\000-\037//d;
>
> TYPO. s/// has no 'd' modifier. I believe you meant:
>
> $string =~ s/\000-\037//g;
I believe you meant
$string =~ s/[\000-\037]//g;
I'm pretty sure Bart meant
$string =~ tr/\000-\037//d;
--
Rick Delaney
rick.delaney@home.com
------------------------------
Date: 23 Mar 1999 12:22:13 +1100
From: bod@compusol.com.au (Brendan O'Dea)
Subject: Re: removing ASCII chars < 32
Message-Id: <7d6qc5$egd$1@duende.compusol.com.au>
In article <7d606k$2p7$2@client2.news.psi.net>,
Abigail <abigail@fnx.com> wrote:
>Bart Lateur (bart.lateur@skynet.be) wrote on MMXXIX September MCMXCIII in
><URL:news:36f71c73.7597555@news.skynet.be>:
>"" Note that this will delete newlmines and tabs as well. Maybe you'd like
>"" these to be converted to (single) spaces instead. Then, do the next
>"" before the above:
>""
>"" $string =~ tr/\t\n / /s;
>
>
>That doesn't do what you think it does. There's no interpolation with tr.
While there is no $ or @ interpolation with tr, it is documented (in
perlop) to handle these sequences:
\t \n \r \f \b \a \e \033 \x1b \c[
So:
$string = "A\t\tB\nC D";
$string =~ tr/\t\n / /s;
# $string eq 'A B C D'
works fine. These of course don't:
$ws = '\t\n '; $string =~ tr/$ws/ /s;
$string =~ tr/\s/ /s;
Regards,
--
Brendan O'Dea bod@compusol.com.au
Compusol Pty. Limited (NSW, Australia) +61 2 9809 0133
------------------------------
Date: 23 Mar 1999 03:12:18 GMT
From: postmaster@uu.net (ICG's)
Subject: Re: sendmail won't run on www ?
Message-Id: <7d70qi$nf6@bgtnsc03.worldnet.att.net>
In article <36F11072.EE7C193E@cedarnet.org>, Steve Wells <wells@cedarnet.org> wrote:
>
>> I am testing a small script to send out email via sendmail.
>> The script runs fine under bash. But when I called the script
>> via www <A href="/cgi-bin/m.pl">, the apache server returned
>> premature end of script headers.
>>
>> Script Listing:
>>
>> #!/usr/local/bin/perl
>>
>> $mailprog = "/usr/sbin/sendmail";
>>
>> open(MAIL,"|$mailprog -t");
>> print MAIL "To: <root\@abc.com>\n";
>> print MAIL "From: <mlc>\n";
>> print MAIL "Subject: Nothing\n\n";
>> print MAIL "Reply-To: <mlc>\n";
>> print MAIL "That's all folk!\n\n";
>> close(MAIL);
>>
>> Apparently, the script failed on the line open().
>> Any suggestion would be much appreciated.
>
>John,
> Your script returned "Premature end of script headers"
>
> That's the problem. It probably sent the mail but you
> didn't tell it to send anything back to the server.
>
> Add this to you program and it should work:
> print "Content-type: text/plain\n\nMail Sent.\n";
>
Dunno about that. But I use the following and it works fine
open (SENDMAIL, "|/usr/lib/sendmail -t");
print SENDMAIL "From: ", $FORM_DATA{"email"},"\n";
print SENDMAIL "To: <destination\@somedomain.net> ","\n";
print SENDMAIL "Bcc: <destination\@somedomain.net>","\n";
..Print a bunch of stuff to it...
close (SENDMAIL);
>STEVE
------------------------------
Date: Mon, 22 Mar 1999 21:11:19 -0500
From: "Jeff Dickens" <dickens@dreamgear.com>
Subject: Re: String chopping
Message-Id: <7d6sfo$dh8$0@dosa.alt.net>
or you could use split.
The number of ways you can do this is a great example of how versatile perl
is...
Greg Griffiths wrote in message <36F6B116.F6F2DB75@surfaid.org>...
>Dear All,
> I have what is probably a trivial one for you all. I have an ID number
>followed by a delimeter and then a string, for example :
>
>123. Joe Bloggs
>5} Hello World12
>
>....
------------------------------
Date: 23 Mar 1999 03:29:21 GMT
From: postmaster@uu.net (ICG's)
Subject: Re: Want to learn Perl
Message-Id: <7d71qh$nf6@bgtnsc03.worldnet.att.net>
In article <7crkdn$803$1@obsidian.us.dell.com>, "Spike White" <spike_YYwhiteYY@YYdellYY.com> wrote:
>Get the "Learning Perl" book by O'Reilly (the Llama book) and the
>"Programming Perl" book by O'Reilly (the Camel book). The first
>is a gentle intro, you can fly through it. The second is a meaty
>reference book (analogous to K&R in the C world).
Hmm. I guess I need to look at the Camel book, I started off with the Rat
book. Most of it was geared towards Perl CGI anyway.
>>I was looking for information on Websites or Books that may help me get
>>started learning Perl.
There is a Perl executable for Win95 and NT, actually, a couple of them.
Don't know where they are, but they're out there.
>>If anyone has comments on Java vs Perl please let me know, I know Java
>>is the hot topic, but it is still pretty slow over the net.
Java has it's uses. The hard part (well, sort of) is getting the code across
to the client and hoping there is nothing wrong with the client's
configuration. Then you're stuck with the speed of the client's computer.
At first, I hated the concept of Java. But it's usefull for neat little
tricks that are impossible in Perl. Perl on the other hand, can do things
that Java can't do. (such as fingering 3 separate network access servers,
doing a selective port scan across 15 IPs, manipulating the data and telling
you the state of all the critical systems and services in an ISP, and the
number of users <with logon names>)
--------------------------------------------------
Not the Postmaster, I hate SPAM
M. H. Mogk breeze <at> granis.net
------------------------------
Date: Tue, 23 Mar 1999 01:30:00 GMT
From: alastair@calliope.demon.co.uk (Alastair)
Subject: Re: while (<@array>) ... fails when @array has 1000+ elements
Message-Id: <slrn7fdrop.gb.alastair@calliope.demon.co.uk>
jmack@phl.lrpub.com <jmack@phl.lrpub.com> wrote:
>I have noticed the following odd behavior for perl 5.004_1 on a Sun
>Ultra2/Solris 2.6 (plenty of memory too). When I cycle through an array that
>has more than a 1000 elements, the while loop fails; if there are less than
>1000 elements, it works fine.
If I was you, I'd upgrade your Perl version because yours seems broken.
--
Alastair
work : alastair@psoft.co.uk
home : alastair@calliope.demon.co.uk
------------------------------
Date: Tue, 23 Mar 1999 01:41:47 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: while (<@array>) ... fails when @array has 1000+ elements
Message-Id: <ebohlmanF90y1n.Kr0@netcom.com>
jmack@phl.lrpub.com wrote:
: I have noticed the following odd behavior for perl 5.004_1 on a Sun
: Ultra2/Solris 2.6 (plenty of memory too). When I cycle through an array that
: has more than a 1000 elements, the while loop fails; if there are less than
: 1000 elements, it works fine.
: @array = ("foo","foo",... has 1000 or more elements);
: $mynum=0;
: while (<@array>) { # this loop just won't happen with 1000+ elements in @array
: print "$mynum\n"; # if @array had 999 or fewer elements, it works and
: $mynum++; # prints 0 - 999 or whatever the array length is }
What you're actually doing with that <@array> is passing the contents of
@array to the shell and asking it to treat it as a bunch of file names to
be checked for wildcards and expanded. Most shells have a limit on how
many names they can expand at a time, and you're running against it.
Now I very much doubt that that's what you really want to do. I'm
guessing you just want to iterate over the elements of the array, and a
simple foreach loop will do that. perldoc perlsyn would probably be
quite helpful here.
------------------------------
Date: Tue, 23 Mar 1999 01:45:54 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: Why don't wildcards expand on cmd line- win32 v5.005_02
Message-Id: <ebohlmanF90y8J.L86@netcom.com>
Michael P McGill <mpmcgill@bellatlantic.net> wrote:
: I have 5.005_02 ActiveState port on a system running Windows98. If I
: specify all the files I want to process on the command line, my program
: works great, but I don't think this is how it is supposed to be.
The 300-series ActiveState ports included code to automatically expand
wildcards on the command line. With the 500-series builds, that code is
omitted (since the builds are made from the standard Perl source, which
assumes that any wildcard expansion has already been done). However, you
can duplicate this behavior using the Wild.pm module; do a Dejanews
search on this group (looking for "Win32" and "wildcard") to see the gory
details.
------------------------------
Date: Tue, 23 Mar 1999 03:52:38 GMT
From: craig@vitter.com (Craig Vitter)
Subject: Win32:EventLog and problems capturing data
Message-Id: <7d6viv$dl2@dfw-ixnews12.ix.netcom.com>
Hello,
I am working on a script to capture all of the warning and error messages in
to send me any errors it finds on a nightly basis so I can keep tabs on what
to send me any errors it finds on a nightly basis so I can keep tabs on what
is happening with each of my boxes. I derived the important parts of the code
from examples in Dave Roth's book Windows NT Win32 Programming.
When I run the file it actually opens the event log, reads it, and e-mails me.
However it does not find any error or warning messages in the event log
(although I have specifically created error messages in there to find). It
does however calculate and correctly record the correct number of entries in
the event log.
The following is the code I am using to read the System part of the event log:
$SecPerDay = 7 * 24 * 60 * 60;
$Now = time();
$OneDayAgo = $Now - $SecPerDay;
$Event = new Win32::EventLog( "System", "" ) || die "Unable to open Event
Log\n";
$Event->GetNumber( $NumberOfEntries );
if( $Event->GetNumber( $Num ) )
{
$Flag = EVENTLOG_BACKWARDS_READ | EVENTLOG_SEEK_READ;
do
{
if( $Event->Read( $Flag, $Num, \%Hash ) )
{
if( $Hash{EventType} == EVENTLOG_ERROR_TYPE ||
$Hash{EventType} == EVENTLOG_WARNING_TYPE)
{
# Write errors found to our open text file
##########################################
print DB "$Hash{Source} on $Hash{Computer}
indicated an error".
"at". localtime( $Hash{TimeGenerated} ) .
".\n";
}
}
else
{
# Or tell us that no errors were found
######################################
print DB "The were no system errors or warnings found
in the Event Log for $date\n";
}
$Num = 0;
}
while( $OneDayAgo < $Hash{TimeGenerated} );
Win32::EventLog::CloseEventLog( $Event->{handle} );
}
print DB "\nTotal Number of Entries in System Event
Log:\t$NumberOfEntries\n\n\n";
Any ideas that you have would be greatly appreciated.
thanks,
Craig
------------------------------
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 5203
**************************************