[7300] in Perl-Users-Digest
Perl-Users Digest, Issue: 925 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Aug 26 16:07:19 1997
Date: Tue, 26 Aug 97 13:00:27 -0700
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, 26 Aug 1997 Volume: 8 Number: 925
Today's topics:
Re: && and associativity <rootbeer@teleport.com>
<> operator memory leak? (Gargle Zndflxtzyh)
Re: Calling another PERL script <rootbeer@teleport.com>
Re: create a file in a user directory by the WEB ? <rootbeer@teleport.com>
Re: Detect child timeout (alarm) in perl cgi??? <rootbeer@teleport.com>
Re: Executing Java App from Perl <rootbeer@teleport.com>
forking and perkTk (John E. de Valpine)
Re: having a Perl script time out <rootbeer@teleport.com>
Re: Help on Final Exam (Perl class) (Andrew Williams)
HELP!!! Using Perl to run Excel <loren_j_brown@ccm.jf.intel.com>
Re: Help: Making CGI using Perl <ramon@ramonc.icix.net>
Re: How do I break up a line <rootbeer@teleport.com>
Re: How to implement a settings file? <gwhassan@prodigy.net>
HTTP Requests with PERL <thomas@netpart.com>
Re: I'm looking for a perl logo... (Matthew Burnham)
Re: indexed Search Engine (Faust Gertz)
Re: install cron program through cgi <rootbeer@teleport.com>
Re: List of perl books, which one should I buy? (Faust Gertz)
Re: MAIL question (Matthew Burnham)
Re: Need advice on data storage and retrieval <gwhassan@prodigy.net>
Re: Need help: how to exit a subroutine if a test insid <bsugars@sunpub.com>
Re: NT problem with ARGV <rootbeer@teleport.com>
Re: Perl & Shadow Passwords authentitacion. <rootbeer@teleport.com>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 26 Aug 1997 11:27:44 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: denis@mathi.uni-heidelberg.de
Subject: Re: && and associativity
Message-Id: <Pine.GSO.3.96.970826112429.13463P-100000@julie.teleport.com>
On Mon, 25 Aug 1997 denis@mathi.uni-heidelberg.de wrote:
> next && ($abc eq "")
Perl lets you do some pretty weird things. This crosses the line. :-)
I think you may have meant one of these.
next if $abc eq '';
next unless $abc eq '';
There should never be any code following an unconditional last, next,
redo, exit, return, or die. Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 26 Aug 1997 20:26:26 +0200
From: joshu@diku.dk (Gargle Zndflxtzyh)
Subject: <> operator memory leak?
Message-Id: <5tv74i$7g9@alvis.diku.dk>
I'm trying to write a program that's supposed to run
for hours on end, but it globs up too much memory, and
to begin with I thought it was a memory leak in
my database-driver which is fairly beta, so I decided
to do a wrapper that restarts the program every hour.
But then another program that didnt use the database
exhibited the same problem...And after staring at my
code for hours to find circular references or hashes
that aren't deleted properly and so forth I've found
that this short code snippet can use up all my RAM
in quite a short while
(and Im working on an SGI IRIX machine with 128 megs of RAM):
=====================================
#!/usr/bin/perl
$ROOT = "/usr/local/data/";
for (;;) {
opendir DIR,$ROOT;
for (readdir DIR) {
open (FIL,$ROOT.$_);
while (<FIL>) {
}
close FIL;
}
closedir DIR;
}
=====================================
/usr/local/data on my machine is a directory containing about 20.000
files...So I can understand if the array from readdir DIR might
get a little big, but if I comment out the 4 lines inside
the innermost for-loop, the problem goes away (the process grows to about
4 megs and stays there).
And none of the files are bigger than about 100k (they're html-files).
So now I begin thinking, perhaps there's something wrong with my
perl binary...perhaps it wasn't compiled properly, but I find
the same problems on a Pentium Linux (But both perl-bins were
compiled by the same person). (I've also reproduced the error on
a HP-UX version 10).
The thing is, though, that if I use another directory containing
less files, It doesn't grow so violently, and when the ending
brace of the outermost for-loop is reached, the size shrinks again.
So it's not a complete bug. But can anyone tell me why I have
these problems?
Is there some kind of buffer thing that I don't know about, or
some cache...or is it something very simple that I've overlooked?
btw. This version of the program works fine (ie. doesn't grow in size):
======================================
#!/usr/bin/perl -w
$ROOT = "/usr/local/data/";
for (;;) {
opendir DIR,$ROOT;
for (readdir DIR) {
print "opening $_\n";
open (FIL,$ROOT.$_) or die $!;
# while (<FIL>) {
# }
$txt = `cat $ROOT$_`;
close FIL;
}
}
=====================================================
Please help me, any response will be accepted gladly.
thank you.
--
"Writing for a penny a word is ridiculous. If a man really wants
to make a million dollars, the best way would be to start his own
religion." Science Fiction writer L. Ron Hubbard.
====================== Anders Nielsen, joshu@diku.dk =========================
------------------------------
Date: Tue, 26 Aug 1997 11:12:35 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: John Grimm <nick@wireedm.com>
Subject: Re: Calling another PERL script
Message-Id: <Pine.GSO.3.96.970826111101.13463M-100000@julie.teleport.com>
On Mon, 25 Aug 1997, John Grimm wrote:
> How do I call another Perl script from another Perl script and pass
> arguments to it?
I usually use system...
$other_prog = 'foo';
@args = qw(fizz bin dingle narf);
system($other_prog, @args);
...if I don't turn the other script into a module, which is generally more
efficient. Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Tue, 26 Aug 1997 12:17:09 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: stef@slb.com
Subject: Re: create a file in a user directory by the WEB ?
Message-Id: <Pine.GSO.3.96.970826120133.13463V-100000@julie.teleport.com>
[ I see that you've posted this same question (in slightly different
forms) many times to this newsgroup and others over the past few weeks.
If the following answer isn't satisfactory to you, will you please let me
know what is wrong with it? I and others have tried to help you, but
something seems to be going wrong. Thanks! ]
On Mon, 25 Aug 1997, Stephane Richard wrote:
> I want to use the vacation program to give to the users the possibility
> to enable their vacation files with Netscape. .
> I need to create four files in their own directory.
> I have try to give to a script the permission of the user, for another
> the root permission I did a setuid in C program, but it doesn't work
(Saying "it doesn't work" is a very poor diagnostic.) This can be done
without much trouble with a set-id Perl script. I'd guess it would be
about two pages long.
The first difficulty is making sure that the script is secure against
accidental or malicious tampering. I recommend using warnings, taint
checks, and 'use strict'. The perlsec(1) manpage has good information, and
so does the web security FAQ.
The second difficulty is making sure that no one can impersonate another
user (to alter the other user's vacation files) accidentally or on
purpose. (This could happen by accident if somebody borrows my computer
just after I've updated my files. They use the 'back' button on my
browser, alter the form to have some of their information, then resubmit,
changing my information.) I'd probably solve this with a two-part form,
where the second displays the information and merely asks for the username
and password. (There are security risks there, too. Users should know not
to use this via an untrusted connection, since their password may be sent
in plaintext(!) over the net. You may wish to enforce this within your
script.)
Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Tue, 26 Aug 1997 12:36:42 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Bob Mariotti <bobm@cunix.com>
Subject: Re: Detect child timeout (alarm) in perl cgi???
Message-Id: <Pine.GSO.3.96.970826123451.13463Z-100000@julie.teleport.com>
On Tue, 26 Aug 1997, Bob Mariotti wrote:
> Can anyone explain the best way to detect a timeout or alarm of a
> called c program used with backticks???
> It seems that although the alarm/timeout works in the child, it
> appears to be undetectable in the calling process.
Make the called program print something noteworthy, such as "###
Terminated upon alarm timeout ###". Or, use the child's exitstatus (found
in the magical $? variable). Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Tue, 26 Aug 1997 12:20:10 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: lbj_ccsi@atl.mindspring.com
Subject: Re: Executing Java App from Perl
Message-Id: <Pine.GSO.3.96.970826121758.13463W-100000@julie.teleport.com>
On Mon, 25 Aug 1997 lbj_ccsi@atl.mindspring.com wrote:
> $return = system "D:\\VisualCafePro\\Java\bin\\java.exe NewAccount
> \"$name\" \"$password\" \"$domain\" \"$fullName\"";
Eek! :-) Try this, instead.
$return = system( 'D:/VisualCafePro/Java/bin/java.exe',
'NewAccount', $name, $password, $domain, $fullName );
Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 26 Aug 1997 14:59:16 GMT
From: jedev@visarc.com (John E. de Valpine)
Subject: forking and perkTk
Message-Id: <5tur04$gc4@fridge-nf0.shore.net>
Hi:
I am having difficulties forking processes after building up a tk interface in
perl. The tk widgets get assembled first and then when the run button is
clicked a fork is done. After the fork exits, the tk mainwindow dies with an
Xerror. I have searched for answers online and in the FAQ but nothing
explicitly treats this issue.
Perl 5.0 patch 3 sub 0
PerlTk 400.202
Linux Kernel 2.0.27
Here is an example:
#!/usr/bin/perl
use Tk;
make_gui();
sub make_gui {
$topwin = MainWindow->new;
$frame = $topwin->Frame->pack(-side => 'left');
$proc = $frame->Text(-width => 15, -height => 4)->pack(-side => 'top');
$data = $frame->Text(-width => 15, -height => 16)->pack;
$run = $topwin->Button(-text => 'Run', -command =>
sub{run($proc,$data)})->pack;
$quit = $topwin->Button(-text => 'Quit', -command => \&exit)->pack;
MainLoop();
}
sub run {
local($proc,$data) = @_;
print "$$\n";
print "$proc\n";
print "$data\n";
FORK:
if ($pid = fork) {
waitpid($pid,0);
} elsif (defined $pid) {
print "hello\n";
sleep(10);
exit;
} elsif ($! =~ /No more process/) {
sleep 5;
redo FORK;
} else {
die "Cannot Fork: $!\n";
}
}
Here is the output:
23404
Tk::Text=HASH(0x81de7ac)
Tk::Text=HASH(0x81de890)
hello
X Error of failed request: BadDrawable (invalid Pixmap or Window parameter)
Major opcode of failed request: 53 (X_CreatePixmap)
Resource id in failed request: 0x4000011
Serial number of failed request: 245
Current serial number in output stream: 246
Ultimately, I want the tk mainwindow to hold and update information about a set
of concurrently running forked process. Should I do this with PIPE() between
the parent and children?
Any suggestions would be greatly appreciated.
-Jack de Valpine
------------------------------
Date: Tue, 26 Aug 1997 11:00:37 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Aveek Datta <MoNoLiTH+@CMU.EDU>
Subject: Re: having a Perl script time out
Message-Id: <Pine.GSO.3.96.970826104907.13463K-100000@julie.teleport.com>
On Sun, 24 Aug 1997, Aveek Datta wrote:
> I have a Perl script that reads and writes to STDIN,
You can't write to STDIN! :-) Do you mean that it writes to STDOUT? Or do
you mean that another process is piped to your script?
> Now I'm having a problem as follows, which goes like
>
> while(<STDIN>)
> {
> do stuff;
> last if /^blah/);
> }
> some other stuff;
> exit;
>
> After a while of running this server, I find a lot of processes hanging
> for hours, even though the actual script takes a few milliseconds.
That might happen if the STDIN is coming through a pipe, blocked because
the process at the other end of the pipe is slow. If you can get the other
process to not buffer output, that could help. Or you could use
non-buffered, non-blocking reads, via sysread.
> Is there any way I can 'time out' these scripts so they exit if X
> seconds has passed out?
Yes, with an alarm. But since signals aren't (yet) reliable in Perl, the
only thing you could really do is some quick, simple cleanup and exit.
while () { # Infinite loop
$SIG{ALRM} = sub { die "Timeout!" };
alarm 100; # Die after 100 seconds
last unless defined($line = <STDIN>);
alarm 0; # Turn off the alarm clock
# Process $line...
}
Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 26 Aug 1997 15:49:56 -0400
From: andrew@spyder.manor.org (Andrew Williams)
Subject: Re: Help on Final Exam (Perl class)
Message-Id: <5tvc14$oel@spyder.manor.org>
the one realy interesting and later usefull project I had to write in the
perl class I took was a mail filter. We had to put stuff in to filter based
on a rules file (one that was parsed rather than written in perl), it had
to deal with mail as it came in (as opposed to running through the existing
inbox). We had to put in forwarding to multiple e-mail addresses, forwarding
to multiple mail folders in both standard mail format and mh. doing the
project to the stated description got you a solid c for the program. In order
to get an A you had to add neat and usefull/clever features to it. It was
really a fun project.
Andrew Williams
andrew@manor.org
http://www.manor.org/
http://www.edoc.com/andrew/
------------------------------
Date: 26 Aug 1997 17:56:44 GMT
From: "Loren Brown" <loren_j_brown@ccm.jf.intel.com>
Subject: HELP!!! Using Perl to run Excel
Message-Id: <01bcb249$54ece7e0$699f8686@pentii.jf.intel.com>
To someone who has used Excel from Perl, this is SIMPLE!
Here is a short script...
==================================
#Get Excel started...
# Set two values in A1 and A2
# Prepare to do an AutoFill
$sourcerange = $ExcelApp->Sheets("Sheet1")->Range("A1:A2");
$fillrange = $ExcelApp->Sheets("Sheet1")->Range("A1:A20");
# ***** HERE IS THE PROBLEM >>>> nothing happens WHY!!!!!????
$sourcerange->AutoFill($fillrange);
=================================
For some reason, the $fillrange variable isn't being passed or received
correctly and hence, AutoFill doesn't work.
I would appreciate any help on this problem or pointers to example
perl scripts using MS-Excel.
Thanks!!!
Loren...
------------------------------
Date: Tue, 26 Aug 1997 14:50:39 -0400
From: Ramon Castillo <ramon@ramonc.icix.net>
To: stormshield@hotmail.com
Subject: Re: Help: Making CGI using Perl
Message-Id: <3403257F.6453@ramonc.icix.net>
I've done that in a web page that issues all type of Networks commands
such as nslookup, traceroute, ping and furthermore shows in the screen
where are you comming from (IP).
All that info I found it here in this news groups and in the differents
FAQ.
Anyway if you want the URL to check it out:
http://www.icix.net/~rcastill/suptool.htm
Please Don't mess to much with it.
#
#Im not strong in C My first language was COBOL
# BUT
#
while ($hacking == $funny) {
$live == $love;
}
RC
------------------------------
Date: Tue, 26 Aug 1997 12:34:24 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Mike Rambour <name@server.com>
Subject: Re: How do I break up a line
Message-Id: <Pine.GSO.3.96.970826123336.13463Y-100000@julie.teleport.com>
On Tue, 26 Aug 1997, Mike Rambour wrote:
> Subject: How do I break up a line
> What I am trying to do is split the line into multiple lines at 70
> chars or less, but I also need to break up words. I have it working
> at <70 but it splits words.
Try Text::Wrap from CPAN. Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Tue, 26 Aug 1997 12:38:13 -0400
From: Greg Hassan <gwhassan@prodigy.net>
To: Michael Schuerig <uzs90z@uni-bonn.de>
Subject: Re: How to implement a settings file?
Message-Id: <34030675.EFEAAD4F@prodigy.net>
Michael Schuerig wrote:
> I want to move the configurable settings of a script to a separate
> file,
> but can't sort out how to do it. I played around with require and
> Exporter, without success, though.
>
You are probably just missing an "1;" at the end of the required file.
Either that or you could just do an open and suck a file in but that
wouldn't really do much more then the require already does for you,
plus it would take a little bit more code.
-Greg
--
===============================================================
Greg Hassan, The Independent Solution (CGI,Java,SQL,Perl...)
http://www.hassan.com/, 1-701-235-3239
===============================================================
Need a cool gift? http://www.hassan.com/cooie/
Or Add your url to all of the Search Engines for FREE:
http://www.hassan.com/superlinkadder/
===============================================================
------------------------------
Date: Tue, 26 Aug 1997 12:10:20 -0700
From: Thomas Whang <thomas@netpart.com>
Subject: HTTP Requests with PERL
Message-Id: <34032A1C.EB8CE4E0@netpart.com>
I have a peculiar problem when doing HTTP requests with Perl. If
anybody can give me a clue, that would be greatly appreciated. I am
writing a "crawler", a search program to collect urls from search
engines depending on the keywords given. Everything seems to work fine
when you tell it to list < 100 listings per page. When you list more
than that, it semms to lose info. As shown below.
Here's a little snippet.
<HTML><HEAD><TITLE>Yahoo! Search Results</TITLE></HEAD><BODY><CENTER>
<A HREF="http://www.yahoo.com/bin/top3" ><IMG
SRC="http://www.yahoo.com/images/main3.1.gif" WIDTH=460 HEIGHT=59 BO
RDER=0 ISMAP></A><P></CENTER>
<center>
<b>
<a href="http://www.yahoo.com/search/?http://tennis.yahoo.com/ten/">U.S.
Open</a> -
</b>
<a href="http://www.yahoo.com/search/?http://quote.yahoo.com">Stock
Quotes</a> -
<a
href="http://www.yahoo.com/search/?http://football.yahoo.com/nfl/">NFL
Preseason</a> -
<a href="http://www.yahoo.com/search/?http://chat.yahoo.com">Yahoo!
Chat</a>
<p></center>
<center> </center>
<CENTER><HR WIDTH="70%"><A
HREF="/search?o=1&S=1&p=sex&d=y&n=50&hc=156&hs=1838&h=c"><!-- A -->
^^^^
...
When I do a request with 100 listings per page I lose a character (from
what I can see)
<CENTER><HR WIDTH="70%"><A
HREF="/search?o=1&S=1&p=sex&d=y&n=100&hc=156&hs=1838&h=c"<!-- A -->
^^^
...
It loses the closing > on the tag.
Now when I do a request with 1000
<CENTER><HR WIDTH="70%"><A
HREF="/search?o=1&S=1&p=sex&d=y&n=1000&hc=156&hs=1838&h=c<!-- A -->
^^^
...
I lose the ending quote AND the closing > on the tag.
Because of this, I'm getting parse errors. Any pointers???
Thanks in advance for any tips.
-Thomas
--
------------------------------------------------------------------------
Thomas Whang | Publishers of
NetPartners Internet Solutions, Inc. | WebSENSE
E-mail: thomas@websense.com | Internet Screening System
Phone: 619.712.4060 | http://www.netpart.com/
------------------------------------------------------------------------
------------------------------
Date: Tue, 26 Aug 1997 17:56:50 GMT
From: danew@enterprise.net (Matthew Burnham)
Subject: Re: I'm looking for a perl logo...
Message-Id: <340d0927.4226399@news.enterprise.net>
mike@stok.co.uk (Mike Stok) wrote:
>>> Don't laugh. From what I hear, Gateway is going after companies that use
>>> Cows for marketing.
>>Does this mean that Ben&Jerry's are in trouble?
>If they start selling computers then they are.
Aren't they also going after TUCOWS (the website).
>In the unlikely event a
>company should happen to use camels to advertise cigarettes then there
>would be no problems, but if that company diversified into selling perl
>software and used Joe Camel to promote it then O'Reilly may get upset as
>their work to associate camels and perl is beoing infringed. Apple records
>let Apple computers use the apple logo as long as they didn't start
>selling musical goods, I think.
What about CD drives on their computers? :)
--
Matthew Burnham | danew@enterprise.net
Manager, MindWeb | http://www.mindweb.co.uk/
Page me: http://wwp.mirabilis.com/2807531 | 2807531-icq@mindweb.co.uk
Web design and hosting | UKP24/Mb/Year for DIY space
WWW, FTP, CGI scripting, mailing lists, autoresponders and more!
------------------------------
Date: Tue, 26 Aug 1997 19:20:18 GMT
From: faust@wwa.com (Faust Gertz)
Subject: Re: indexed Search Engine
Message-Id: <34062a75.4033856@news.wwa.com>
Guess what! comp.lang.perl no longer exists, but you weren't the only
person to post to it today. :-)
On 24 Aug 1997 22:09:51 GMT, "Bob lally" <boblally@gte.net> wrote:
>Was wondering if anyone knows of a good perl based indexed search engine?
>I've searched the net and not found a thing.
On 15 Aug 1997 15:09:51 GMT, "Neil Edmondson" <neiled@enteract.com>
wrote:
> Try the following ... a crawler, which ain't fast - cos it's indexing EVERY word);
> then a searcher, which is fast cos the major work has already been done by
> crawler (via CGI - so you'd have to redo that, but the principles are prob. the
> same).
>
> I also recommend checking out that reference for Brian Slesinsky -
> http://www.webmonkey.com/code/97/16/index2a.html
or you can just go to
http://www.hotwired.com/webmonkey/code/97/16/index2a.html
to see Brian's solution. Neil's posted solution follows my signature
unquoted to allow for easier options when it comes to cutting and
pasting. I haven't tried either of them, so don't yell at me if they
don't work. :-)
Streben nach Wahrheit
Faust Gertz
Philosopher at Large
---------------------------------
#!/usr/bin/perl -Tw
use DB_File;
use File::Find;
use Time::Local;
# webcrawl.pl - create a full text index to a web site
# based on an idea by Brian Slesinsky
# http://www.webmonkey.com/code/97/16/index2a.html
$startpath = "/domain/http-docs";
$db = "search_index.db";
$db_current = $startpath . "/" . $db;
$db_new = $startpath . "/" . $db . ".new";
print $db_new;
# remove any previous attempt at indexing then create a new index file
unlink($db_new);
my %db;
dbmopen(%db, $db_new, 0644) or die "dbmopen: $!";
my $fileno = 0;
# scan and index every file
find(\&makeindex,$startpath);
# close the new index and replace any existing index
untie %db;
unlink($db_current);
link($db_new,$db_current) or die "link: $!";
unlink($db_new) or die "unlink: $!";
exit(0);
sub makeindex {
if (/html$/) {
# read the file content into $html
$fullname = $File::Find::name;
($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
$atime,$mtime,$ctime,$blksize,$blocks) = stat
$fullname;
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)
=
localtime($mtime);
$modtime = join '/', ++$mon, $mday, $year;
print "$modtime indexing $fullname\n";
open (HTML, $fullname) || print "open $fullname:
$!\n";
my $html = join ('', <HTML>);
close HTML;
# make a link to the file
$fullname =~ s/$startpath//;
$url = substr($fullname,1);
my ($title) =($html =~/<title>([^<]*)/i);
$title = $url if (!defined $title);
$url = "http://www.weaveware.com/" . $url;
$db{--$fileno} = "<a href=\"$url\">$title
$modtime</a>";
# extract the words from the HTML
$html =~ s/<[^>]+>//g;
$html =~ tr/A-Z/a-z/;
my @words = ($html =~ /\w+/g);
# add this page to the inverted index
my $last = "";
for (sort @words) {
next if($_ eq $last);
$last = $_;
$db{$_} = defined $db{$_} ? $db{$_}.$fileno :
$fileno;
}
}
}
---------------------------
#!/usr/local/bin/perl -Tw
use DB_File;
# search.pl - search page for a Web site
# based on an idea by Brian Slesinsky
# http://www.webmonkey.com/code/97/16/index2a.html
# parse form data
my $query = $ENV{'QUERY_STRING'};
$query =~ s/s=//;
$query =~ s/%[0-9a-fA-F]{2}/ /g;
my @words = ($query =~ /\w+/g);
# print search form
my $query_value = join(' ',@words);
print <<END;
Content-type: text/html
<body bgcolor="#FFFFFF">
<form>
<p><input name=s value="$query_value"><input type=submit
value="Search">
</form>
<p>
END
exit if($query eq "");
# count the number of search terms on each relevant page
my %db;
dbmopen(%db, "/domain/http-docs/search_index.db", undef) or print
"dbmopen:
$!";
my %counters;
my $word;
for $word (@words) {
my $pages = $db{lc $word};
my $page;
for $page ($pages =~ /(-\d+)/g) {
$counters{$page}++;
}
}
# print links to the pages that have all the search terms
my $linkcount = 0;
my $page;
for $page (sort keys %counters) {
if($counters{$page}==scalar(@words)) {
$linkcount++;
if($linkcount>50) {
print "<p>(only the first 50 matches are shown)";
last;
}
my $href = $db{$page};
print "$href<br>";
}
}
__END__
------------------------------
Date: Tue, 26 Aug 1997 11:47:53 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Wei Tang <wtang@cs.ualberta.ca>
Subject: Re: install cron program through cgi
Message-Id: <Pine.GSO.3.96.970826114440.13463T-100000@julie.teleport.com>
On 25 Aug 1997, Wei Tang wrote:
> I am trying to install a cron program through cgi perl scripts:
Your script is running under some userid (probably 'nobody'). Is that id
authorized to run cron? (I hope not! :-)
> open(BUFFER, "|/usr/bin/crontab ");
> print BUFFER "$mycronprog";
> close(BUFFER);
...But if it is authorized, you just wiped out anybody else's attempt at
using cron from that userid. :-(
You may need to try a different way to do what you want. Good luck!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Tue, 26 Aug 1997 19:05:42 GMT
From: faust@wwa.com (Faust Gertz)
Subject: Re: List of perl books, which one should I buy?
Message-Id: <340423c0.2318219@news.wwa.com>
On Sat, 23 Aug 1997 13:03:58 +0100, Mark Worsdall
<jaydee@worsdall.demon.co.uk> wrote:
>Can anyone give recommendations to any of these books before I invest in
>one?
The most complete (though biased) guide to perl books I have seen is
Tom Christiansen's Camel Critiques at
http://language.perl.com/critiques/index.html
>I need one that will take me from the querky //^$_ FUNNY characts
>and what the mean/how they work, through to full ng. Also earn by
>hacking codes together and seeing what they do so good WORKING examples
>will be useful.
Does it need to teach about these things or just explain them. If you
just need explanations, the only way to go is _Programming Perl [2nd
edition] (the ``Turquoise Camel Book'')_, by Larry Wall, Tom
Christiansen, and Randal L. Schwartz. If you need to learn something,
I still like _Learning Perl [2nd edition] (the ``Llama Book'')_, by
Randal L. Schwartz (with foreword by Larry Wall). If you are doing a
lot of web stuff, many people like _How to Set up and Maintain a World
Wide Web Site [2nd edition]_ by Dr. Lincoln Stein, M.D., Ph.D. I
haven't seen this one myself, but I am somewhat familar with Dr.
Stein's handy work from various articles in _The Perl Journal_ and
_Web Techniques_ and the CGI module. I just picked up _Cross-Platform
Perl_ by Eric F. Johnson this weekend and found some things I didn't
remember reading in Randal's book. I learned more from Randal's book,
but I think there is a lot to like in _Cross-Platform Perl_ and
especially reccomend it for those who plan to use perl in a windows
environment.
>13330 Perl By Example
>10873 Learning Perl
See above
>28682 Applied Perl: Internet Programing With Perl
>26794 Perl 5 Quick Reference
If this is the book by Mmcheal S Foghlz, not too many people liked it.
>28288 Perl 5 for Dummies
Would you ever by a 'for Dummies' book?
>26841 Perl 5 by Example
If this is the one by David Medinets, an on-line version is availible
at http://www.planet.net/pmedined/books/books.htm
>Please I am not rich so no saying get the lot. I have a large family of
>underpants to support! 16 in fact, increasing due to birthday and Xmas
>is looming!
Streben nach Wahrheit
Faust Gertz
Philosopher at Large
------------------------------
Date: Tue, 26 Aug 1997 17:56:58 GMT
From: danew@enterprise.net (Matthew Burnham)
Subject: Re: MAIL question
Message-Id: <340e0a53.4525898@news.enterprise.net>
burt@ici.net (Burt Lewis) wrote:
>$youmail = 'burt@ici.net';
>open (MAIL, "|$mailprog $youmail");
>
>Question is, I can't seem to add additional receipients to this, it only
>seems to work with one.
How are you trying to add them?
$youmail = 'burt@ici.net, next@address, another@address';
should work okay.
--
Matthew Burnham | danew@enterprise.net
Manager, MindWeb | http://www.mindweb.co.uk/
Page me: http://wwp.mirabilis.com/2807531 | 2807531-icq@mindweb.co.uk
Web design and hosting | UKP24/Mb/Year for DIY space
WWW, FTP, CGI scripting, mailing lists, autoresponders and more!
------------------------------
Date: Tue, 26 Aug 1997 12:21:19 -0400
From: Greg Hassan <gwhassan@prodigy.net>
To: mbosley@shore.net
Subject: Re: Need advice on data storage and retrieval
Message-Id: <3403027F.A5C21200@prodigy.net>
random wrote:
> Ok, here's the question. I am writing a web based game and the back
> end
> is in perl. Up until now, I have been using basic delimited text
> files
> to store and retrieve the data. I have found that most of the
> programming I am doing is retrieving/storing the data to those files.
> It would be wonderous if I could get some alternatives to using the
> delimited text files (faster IS better! :)
>
> A sample entry would look something like this (delimited by ::):
>
> Draegonya::troop::Infantry::0::1800::4.4::11::0.55::22::11::::22
:1::112::1::1::900::1.1::0.5::::2::1::::5.5::1::0::0::0::0::0::0::0::0::0::0::0::0::0::0::0::0::0::0::0::0::0::0::1::1::250::::::0.666666666666667::A/G::0.166666666666667::0.5::0.166666666666667::::2::1::0::0::0::::::0::N/A::0::0::0::::0::0::0::0::0::::::0::N/A::0::0::0::::0::0::0::0::0::::::0::N/A::0::0::0::::0::0::0::0::0::::::0::N/A::0::0::0::::0::0::0::0::0::::::0::N/A::0::0::0::::0::0::2950::5.5::10.5::19.5::9.83333333333333
>
> *But* each database is different. Each player has 6 separate db's to
> hold their info. Some are 5 entries, and one is 248 entries.
>
It seems like for a game you should just keep everything in memory so
storing
things in csv's shouldn't make any difference. I guess it depends on
how many
people are playing.
I think keeping everything in memory would be the same sort of advantage
in going
with msql but it would probably be faster without the database access
time
depending on your algorythms.
as for the difference between csv'ing and packing, I don't think there
is
that great of a speed difference. Either way you do it, it still needs
to split the
lines up into fields.
I just know that csv's are easy to deal with, you can just pull them
into emacs
and change something real quick. If you make it binary then you have to
write a script to change things in the files.
You could always write two programs that do the same thing except for
the csv/pack
and time them using the unix time command. Maybe the results should be
put in the
Faq so everyone knows or maybe its already there?
-Greg
--
===============================================================
Greg Hassan, The Independent Solution (CGI,Java,SQL,Perl...)
http://www.hassan.com/, 1-701-235-3239
===============================================================
Need a cool gift? http://www.hassan.com/cooie/
Or Add your url to all of the Search Engines for FREE:
http://www.hassan.com/superlinkadder/
===============================================================
------------------------------
Date: Tue, 26 Aug 1997 15:12:07 -0400
From: Benjamin Sugars <bsugars@sunpub.com>
Subject: Re: Need help: how to exit a subroutine if a test inside fails?
Message-Id: <34032A87.5368@sunpub.com>
Tom Phoenix wrote:
>
> On Sun, 24 Aug 1997, Alex Dong Li wrote:
>
> > I am writing a big subroutine. There are some tests in the subroutine.
> > Could anyone tell me how to exit the subroutine if a test fails?
>
> Method one: Simply return. Your caller will get undef (in a scalar
> context) or the empty list (in a list context), which can signal that an
> error occurred.
>
> return unless @_ > 2; # Require two parameters
>
Has anyone ever felt the need for a function that prints something to
STDERR and then immediately does a return()? I often find myself
writing constructs like
open(FILE, $file) or do {
warn "couldn't open $file: $!\n";
return;
};
It would save some typing - and also provide some syntactic closure -
if I could write something like
open(FILE, $file) or
abandon "couldn't open $file: $!\n";
What do you think?
-Ben
--
Ben Sugars <bsugars@canoe.ca>
Senior Webmaster,
CANOE Canadian Online Explorer,
http://www.canoe.ca/
------------------------------
Date: Tue, 26 Aug 1997 11:09:23 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Steve Leibel <stevel@coastside.net>
Subject: Re: NT problem with ARGV
Message-Id: <Pine.GSO.3.96.970826110352.13463L-100000@julie.teleport.com>
On Sun, 24 Aug 1997, Steve Leibel wrote:
> I have intermittent problems getting the following simple script to work
> properly on NT, both with 5.003_07 and 5.004_02:
>
> print "@ARGV\n";
>
> When run with arguments supplied, the script still prints an empty
> string.
That's odd.
> On 5.003_07 I solved the problem by re-downloading and re-installing.
That's odder. :-)
What does this command print? (I don't have an NT machine to test this on,
but I believe that these are the correct quotes for NT. Unix users should
use single quotes on the argument after -we.)
perl -we "print qq#Version $]\n#, map qq#[$_]\n#, @ARGV" foo bar
If you don't get what you expect (or if you're not sure what to expect
from that code :-) post again!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Tue, 26 Aug 1997 12:40:06 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: ldeath@seade.gov.br
Subject: Re: Perl & Shadow Passwords authentitacion.
Message-Id: <Pine.GSO.3.96.970826123815.13463a-100000@julie.teleport.com>
On Fri, 22 Aug 1997 ldeath@seade.gov.br wrote:
> 2) The /etc/shadow file is setmod 400, so the httpd process that runs as
> nobody can't read the shadow file, unless it impersonates the root himself
That's the whole problem: Your script would have to be running as root to
do this. (Once it's running as root, it's easy to make a module to do what
you want.) Check out your system's documentation on set-id programs, and
the perlsec(1) manpage. Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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.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 925
*************************************