[12260] in Perl-Users-Digest
Perl-Users Digest, Issue: 5860 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jun 2 12:07:21 1999
Date: Wed, 2 Jun 99 09:00:17 -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 Wed, 2 Jun 1999 Volume: 8 Number: 5860
Today's topics:
Re: empty line (Tad McClellan)
Re: extract only characters from string? (Tad McClellan)
Geting lost in $@% jungle <pavel@asei.cz>
Re: Geting lost in $@% jungle (Greg Bacon)
Help Win32::OLE Word <olivier.maas@at-lci.com>
Re: microso?t perl <jeromeo@atrieva.com>
Re: microso?t perl (I R A Aggie)
Re: microso?t perl <dgris@moiraine.dimensional.com>
Re: micros~1 perl <tchrist@mox.perl.com>
mkdir() function on NT <chenning@uwf.edu>
Newbie - would appreciate a hand to get started - Thank <jde222RemovethiS@iname.com>
Re: Removing blank lines... (Bill Moseley)
Re: req: sendmail specs <gellyfish@gellyfish.com>
searching HTML files <joe@laffeycomputer.com>
sendmail doesn't work <vision4@bigplanet.com>
Re: sendmail doesn't work <gellyfish@gellyfish.com>
Re: sendmail doesn't work (I R A Aggie)
String extraction problem - please help? <webmaster@avert.org>
Webpage Spell Checker in Perl <matt@godzilla.tamu.edu>
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 1 Jun 1999 19:54:05 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: empty line
Message-Id: <tqr1j7.hv5.ln@magna.metronet.com>
ramon (ramon@gila.sunion.arizona.edu) wrote:
: HELO:
copter
: i have a file containing questions separated by space as such:
separated by blank lines you mean (space is a character)
: which i place into an array. some of the questions are more than one
: line and i want to combine these lines and place them into another
: array. i am having trouble checking for these empty lines.
---------------------------
#!/usr/bin/perl -w
use strict;
my @questions;
{ local $/ =''; # enable paragraph mode
while (<DATA>) {
s/\n/ /g; # join lines with a space
push @questions, $_;
}
}
foreach (@questions) {
print "$_\n----------\n";
}
__DATA__
1. Summertime in the Northern Hemisphere is when
2. Where and when would you look for a nearly new Moon in the sky?
3. Planet X has a nearly circular orbit and a rotation axis which
is perpendicular to the plane of its orbit around a star. The seasons
on Planet X would be
---------------------------
: what are
: they ie, ('\n')? what can i compare them to?
What happened when you tried comparing them to \n ?
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 1 Jun 1999 20:00:13 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: extract only characters from string?
Message-Id: <d6s1j7.hv5.ln@magna.metronet.com>
Ken Williams (tekkin@hotmail.com) wrote:
: How do I extract only alphabet characters(a-z) from a string?
First you specify what you want.
Then you use a regular expression. See perlre.pod and perlop.pod.
$string = '123abc@#$%^789XYZ-fooBAR';
Do you want 'abc' ?
Or do you want 'abcXYZfooBAR' ?
Or do you want a list ( 'abc', 'XYZ', 'fooBAR') ?
Or ...
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 02 Jun 1999 17:05:25 +0200
From: Pavel Hlavnicka <pavel@asei.cz>
Subject: Geting lost in $@% jungle
Message-Id: <37554835.BD65314D@asei.cz>
Hi all,
my script works fine, but I'd like to omit the $arrayref variable:
$result{$hoo} = [100, []];
#some code here
$arrayref = $result{$hoo}[1];
@$arrayref = @path;
Could you help me?
Thanx
--
Pavel Hlavnicka
A.S.E.I. Ltd; Prague
tel.: +420 2 24106102
e-mail: pavel@asei.cz
------------------------------
Date: 2 Jun 1999 15:26:51 GMT
From: gbacon@itsc.uah.edu (Greg Bacon)
Subject: Re: Geting lost in $@% jungle
Message-Id: <7j3ifr$is2$5@info2.uah.edu>
In article <37554835.BD65314D@asei.cz>,
Pavel Hlavnicka <pavel@asei.cz> writes:
: my script works fine, but I'd like to omit the $arrayref variable:
:
: $result{$hoo} = [100, []];
: #some code here
: $arrayref = $result{$hoo}[1];
: @$arrayref = @path;
@{ $result{$hoo}[1] } = @path;
Greg
--
Whenever software asked her whether she was sure she wanted a document
deleted, an operation executed, a session ended, she felt the urge to reply
"No." Yes, she wanted it done, but was she sure? She was never sure of
anything. -- Jutta Degener
------------------------------
Date: Wed, 02 Jun 1999 17:36:31 +0200
From: Olivier Maas <olivier.maas@at-lci.com>
Subject: Help Win32::OLE Word
Message-Id: <37554F7E.9663532F@at-lci.com>
hello, going loco trying to use word to save different docs as texts.
think the PB is mainly to pass 2 args to an OLE method, I tried the
syntax of perldoc Win32::OLE....but nothing
Where Am I erring?
$fichier="c:\\Temp\\test\.doc";
$application=Win32::OLE->new('Word.Application', 'Quit') || warn
"Impossible de créer un objet OLE";
$document=$application->Documents->Open("$fichier");
worked ok, he file is open, I get the name ok...
#then
$res=$document->SaveAs('c:\temp\testtest.txt','WdFormatText',undef,undef,undef,undef,undef,undef,undef,undef,undef);
#or: $document->SaveAs(undef,{FileName => "testtest.txt", FileFormat=>
"WdFormatText"});
#(tried plenty of combinations quotes, double quotes,etc... save as
works but just with 1 arg like:
#$res=$document->SaveAs('c:\temp\testtest.txt');
# the name is then correctly changed, but the file is still a word
file...
#the command I use to get the name of the doc, then print it...
$res=$document->{'Name'};
If Any idears???
please also reply by mail to maas@ensae.fr
olivier
------------------------------
Date: Wed, 02 Jun 1999 08:02:07 -0700
From: Jerome O'Neil <jeromeo@atrieva.com>
Subject: Re: microso?t perl
Message-Id: <3755476F.E86B640B@atrieva.com>
Daniel Grisinger wrote:
>
> [subject line intentionally munged to avoid my killfile :-)]
>
> This worries me.
>
> http://www.activestate.com/press/releases/Microsoft.htm
What's this all about?
> Q: Will the work be Open Source?
>
> A: Most of the work will be released as Open Source. Part of
> our business model is to sell value add, proprietary components.
> Rest assured though, that everything added to core Perl will be
> released under the same terms as Perl.
Smells fishy. I'm always nervous when some MS goob tells me to "rest
assured."
More importantly... should I care?
--
Jerome O'Neil, Operations and Information Services
Atrieva Corporation, 600 University St., Ste. 911, Seattle, WA 98101
jeromeo@atrieva.com - Voice:206/749-2947
The Atrieva Service: Safe and Easy Online Backup http://www.atrieva.com
------------------------------
Date: 2 Jun 1999 15:25:25 GMT
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: microso?t perl
Message-Id: <slrn7lajdf.1b3.fl_aggie@thepentagon.com>
On 02 Jun 1999 08:59:18 -0600, Daniel Grisinger
<dgris@moiraine.dimensional.com>, in
<m3lne2hcmx.fsf@moiraine.dimensional.com> wrote:
+ This worries me.
+ http://www.activestate.com/press/releases/Microsoft.htm
Who sez you have to use their stuff, and who sez that p5p has to
roll it into the perl core?
James
------------------------------
Date: 02 Jun 1999 09:55:16 -0600
From: Daniel Grisinger <dgris@moiraine.dimensional.com>
Subject: Re: microso?t perl
Message-Id: <m3bteyha1n.fsf@moiraine.dimensional.com>
fl_aggie@thepentagon.com (I R A Aggie) writes:
> On 02 Jun 1999 08:59:18 -0600, Daniel Grisinger
> <dgris@moiraine.dimensional.com>, in
> <m3lne2hcmx.fsf@moiraine.dimensional.com> wrote:
>
> + This worries me.
> + http://www.activestate.com/press/releases/Microsoft.htm
>
> Who sez you have to use their stuff, and who sez that p5p has to
> roll it into the perl core?
Given that the current pumpking (lead maintainer of perl) is
an Activestate employee I'd say that they probably have
a sympathetic ear on p5p.
Beyond that, I have absolutely no sympathy with the `let's add
slaveware enhancements to a working open source product' business
model. It was disgusting when sendmail started doing it
and it's disgusting when activestate does it. The biggest
difference, of course, is that I give a shit about what happens
to perl while I don't with sendmail.
dgris
- none of this is to be construed as an attack on
(or even criticism of) Sarathy. he has done a
tremendous amount of good for perl and will undoubtedly
continue to do so.
--
Daniel Grisinger dgris@moiraine.dimensional.com
perl -Mre=eval -e'$_=shift;;@[=split//;;$,=qq;\n;;;print
m;(.{$-}(?{$-++}));,q;;while$-<=@[;;' 'Just Another Perl Hacker'
------------------------------
Date: 2 Jun 1999 09:58:02 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: micros~1 perl
Message-Id: <3755548a@cs.colorado.edu>
[courtesy cc of this posting mailed to cited author]
:[subject line intentionally munged to avoid my killfile :-)]
And mine. :-)
You should go read what's on p5p about it today before you
get too creeped out.
There's also splutterings
on slashdot, but nothing there is official.
--tom
--
For all we know, this is just an elaborite simulation running in a cube on
someone's desk. --Captain Jean-Luke Picard (ST:ng)
------------------------------
Date: Wed, 2 Jun 1999 10:25:35 -0500
From: "Spike Henning" <chenning@uwf.edu>
Subject: mkdir() function on NT
Message-Id: <7j3i3q$ss0$1@news.fsu.edu>
I would appreciate help with using the mkdir() function work on NT using
perl, version 5.005_03 binary build 513.
I'm having trouble getting the mkdir function to work. I'm assuming that
it's related to the permissions aspect since the directory name seems
straightforward enough
.
The actual code is
$errNo=mkdir("$newdir",0777); where $newdir is f:/mydir.
I've tried hardcoding it as well, but it doesn't change the symptoms. When
I print $OS_ERROR($!) it says "(Invalid argument)".
------------------------------
Date: Wed, 2 Jun 99 15:21:51 GMT
From: "Euro Jake" <jde222RemovethiS@iname.com>
Subject: Newbie - would appreciate a hand to get started - Thanks in advance
Message-Id: <7j3ht4$hes$1@news3.Belgium.EU.net>
Hello group
Apologies if this is the wrong group or off topic...
Im not new in programming, tho fully new with unix and the web,
and willing to do the effort to learn perl and cgi
Perl script seems readable a bit, but missing the glueing things to get started
I have been looking around a lot and cant seem to get my config right
Running win95, I have downloaded and installed active perl, installed at c:\perl,
browsed through the included help system, and couldnt get away with it
I would like to get this working to get me started:
A simple .html file, which i start with ie5 browser, calling a simple .pl file,
which produces just a print "hello" and passes control back to the .html thing
Once this runs, i think i would be able to build on it further
Any help positively appreciated, thanks in advance
--
Euro Jake
>RemovethiS< in next line...
Anti spam email jde222RemovethiS@iname.com
------------------------------
Date: Wed, 2 Jun 1999 08:43:56 -0700
From: moseley@best.com (Bill Moseley)
Subject: Re: Removing blank lines...
Message-Id: <MPG.11bef11a8184006298973b@206.184.139.132>
In article <375491D0.89FB531E@auckland.ac.nz>, g.sands@auckland.ac.nz
says about printing non-blank lines
> What about:
>
> while (<>) {
> print unless /^\s*$/;
^
Why zero or more? __|
isn't that the same as:
print unless /^$/;
Wouldn't that be more work for the regexp engine than:
print if /\S/;
Seems like ^\s*$ would require it to think about every char of each
string.
--
Bill Moseley mailto:moseley@best.com
------------------------------
Date: 2 Jun 1999 16:24:47 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: req: sendmail specs
Message-Id: <37554cbf@newsread3.dircon.co.uk>
Bastiaan S van den Berg <office@asc.nl> wrote:
> does anyone know a site to , or information about handling the
> /usr/lib/sendmail program?
>
man sendmail
Or failing that comp.mail.sendmail or better the FAQ at:
<http://www.sendmail.org/faq/>
> i'm trying to send mail from a perl program with the following commands ,
> does anyone have an idea why it won't send mail?
>
> -[= code following =]-
>
> open (MAIL, "|$sendmail -t > /dev/null 2>&1") || die ("Content-Type:
> text/html \n\n<html><head>Error opening pipe to $sendMAIL:
> $!\n</body></html>\n");
> print MAIL ("To: office\@asc.nl , $email \n","Subject: [Site]
> Contactformulier. \n");
> print MAIL"\n\n";
> if ($bedrijf ne "") {print MAIL "Bedrijf : $bedrijf\n";}
> /snip/
> .
> .
> /snip/
> close(MAIL);
>
For starters here there is no point doing what you are doing in your
die - because this will go to your error_log and not get to the users
browser - you should read perlfaq9 on how to get messages to the browser.
Secondly I dont think you want all those brackets there - why dont you
try a here document:
print MAIL <<EOMAIL;
To: office\@asc.nl, $email
Subject: [Site] Contactformulier
Body text here
EOMAIL
Thirdly you will probably want to check the return of the close - because
the open will only fail if the fork() failed - an other error with
sendmail will not be reported until the close().
/J\
--
Jonathan Stowe <jns@gellyfish.com>
------------------------------
Date: Wed, 2 Jun 1999 10:55:04 -0500
From: Joe Laffey <joe@laffeycomputer.com>
Subject: searching HTML files
Message-Id: <Pine.LNX.4.10.9906021052020.18880-100000@tripe.laffeycomputer.com>
I bet this is a FAQ, but I cannot locate it...
I'd like to be able to search for text in HTML files (ignoring tags).
Ideally, I would make an index file and simply do a lookup in that. I
could do this with a tied hash. However, I do not have shell access to the
server on which it will run. So I'd have to write a script to do create
the index.
Anyone know of any modules, caveats, etc.?
Thanks,
Joe Laffey
LAFFEY Computer Imaging
St. Louis, MO
http://www.laffeycomputer.com/
------------------------------
Your mouse has moved. Windows NT must be restarted for the change to
take effect. Reboot now? [ OK ]
------------------------------
Date: Wed, 2 Jun 1999 09:18:21 -0600
From: "Sherry" <vision4@bigplanet.com>
Subject: sendmail doesn't work
Message-Id: <928336338.638375@proxy1.bigplanet.com>
http://easyhomebiz.virtualave.net
I'm having trouble with a pre-written perl script. It functions beautifully
in accepting links, collecting e-mail addresses and posting links. It does
not send an automatic e-mail after a link is posted like it should.
My permissions are set at chmod666 for all files except my links.cgi which
is set for 777
The cgi script is:
#!/usr/local/bin/perl
# Be sure the above path is correct for your server!
############################################################################
##
# This script was generated by FFA Blaster Version 1.5.72
#
# Download your own copy of FFA Blaster, loaded with features like:
# * Autoposts your ads to thousands FFA pages
# * Supports batch mode postings
# * Easy-to-use interface. Start posting within 2 minutes
# * Built-in FFA page script generator
# * Automatically installs your FFA page on your server
# * FREE version available!
# * And much, much more...
#
# Download1: http://www.SubmitAd.com/files/blaster1.exe
# Homesite1: http://www.SubmitAd.com
# Download2: http://www.FFAblaster.com/files/blaster1.exe
# Homesite2: http://www.FFAblaster.com
#
# FFA Blaster requries that you are running Windows 95\/98.
#
# Copyright 1998-99 SPCK Software - All rights reserved
############################################################################
##
############################################################################
##
# YOU EDIT THESE VARIABLES IN THE FFA BLASTER SOFTWARE BEFORE THIS SCRIPT IS
# GENERATED! YOU MUST HAVE CORRECT VARIABLES HERE FOR THE SCRIPT TO WORK
############################################################################
##
# The domain that your links page resides on.
$domain = "easybiz.virtualave.net";
# Server path to your links.html file.
$htmlpath = "/home/4success/public_html/links/links.htm";
# URL of your links.html file.
$htmlurl = "http://easybiz.virtualave.net/links/links.htm";
# Maximum number of links per section.
$maxlinks = 50;
# Send confirmation email? 0 for no, 1 for yes.
$sendemail = 1;
# Server path of sendmail or equivalent.
$mailprog = "/usr/sbin/sendmail";
# This will be the name the confirmation email is from.
$fromname = "On-Line Catalog Business";
# This will be the address the confirmation email is from.
# Perl requires a \ before the @ sign so we insert it here.
$fromemail = "vision4\@bigplanet.com";
# This will be the subject of the confirmation email.
$subject = "Your Page Is Linked!";
# Save email addresses of sumbitter to file? 0 for no, 1 for yes.
$saveemail = 1;
# Server path to your collect.txt file where email addresses of submitter is
saved
$emaildatabase = "/home/4success/public_html/links/collect.txt";
# Holds total number of postings. located in same directory as the script
$CountFile = "links.num";
############################################################################
##
# DO NOT EDIT BELOW THIS LINE UNLESS YOU KNOW WHAT YOU'RE DOING!!!
############################################################################
##
############################################################################
##
# Read in the POSTed variables.
############################################################################
##
read (STDIN, $input, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $input);
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ s/<([^>]|\n)*>//g;
$value =~ s/<//g;
$value =~ s/>//g;
$value =~ s/\*/\\\*/g;
$value =~ s/\+/\\\+/g;
$FORM{$name} = $value;
}
############################################################################
##
$title = $FORM{'title'};
$url = $FORM{'url'};
$email = $FORM{'email'};
$section = $FORM{'section'};
$refer = $ENV{'HTTP_REFERER'};
$remote = $ENV{'REMOTE_ADDR'};
############################################################################
##
# Make sure the user entered a title for their link.
############################################################################
##
if ($title eq '') {
print "Content-type: text/html\n\n";
print "<html><head><title>Ooops, You Forgot To Enter Your Site's
Title!</title></head>\n";
print "<body bgcolor=white><br><center><font size=5 color=blue>\n";
print "<b>Ooops, You Forgot To Enter Your Site's
Title!</b></font><br><br>\n";
print "<b>Please hit your browser's \"back\" button and try
again.</b></center><br>\n";
exit;
}
############################################################################
##
# Make sure the title is not longer than 85 characters.
############################################################################
##
if (length($title) > 85) {
print "Content-type: text/html\n\n";
print "<html><head><title>Ooops, Your Title Is Longer Than 85
Characters!</title></head>\n";
print "<body bgcolor=white><br><center><font size=5 color=blue>\n";
print "<b>Ooops, Your Title Is Longer Than 60
Characters!</b></font><br><br>\n";
print "<b>Please hit your browser's \"back\" button and try
again.</b></center><br>\n";
exit;
}
############################################################################
##
# Check for restricted words in the title.
############################################################################
##
open (FILE, "badwords.txt");
@badwords = <FILE>;
close (FILE);
foreach (@badwords) {
chomp $_;
$temp = $_;
if ($title =~ /\s$temp\s/i || $title =~ /^$temp\s/i || $title =~
/\s$temp$/i) {
print "Content-type: text/html\n\n";
print "<html><head><title>Sorry, There's A Restricted Word In Your
Title!</title></head>\n";
print "<body bgcolor=white><br><center><font size=5 color=blue>\n";
print "<b>Sorry, There's A Restricted Word In Your
Title!</b></font><br><br>\n";
print "<b>Please hit your browser's \"back\" button and try
again.</b></center><br>\n";
exit;
}
}
############################################################################
##
# Check for BANNED email addresses.
############################################################################
##
open (FILE, "bademail.txt");
@bademail = <FILE>;
close (FILE);
foreach (@bademail) {
chomp $_;
$temp = $_;
if ($email eq $temp) {
print "Content-type: text/html\n\n";
print "<html><head><title>Sorry, You can NOT post a link using that email
address!</title></head>\n";
print "<body bgcolor=white><br><center><font size=5 color=blue>\n";
print "<b>Sorry, You can NOT post a link using that email
address!</b></font><br><br>\n";
print "<b>Please hit your browser's \"back\" button and try
again.</b></center><br>\n";
exit;
}
}
############################################################################
##
# Make sure user entered their URL.
############################################################################
##
if ($url eq 'http://') {
print "Content-type: text/html\n\n";
print "<html><head><title>Ooops, You Forgot To Enter Your Site's
URL!</title></head>\n";
print "<body bgcolor=white><br><center><font size=5 color=blue>\n";
print "<b>Ooops, You Forgot To Enter Your Site's URL!</b></font><br><br>\n";
print "<b>Please hit your browser's \"back\" button and try
again.</b></center><br>\n";
exit;
}
############################################################################
##
# Make sure user entered a valid URL.
############################################################################
##
if ($url !~ /^(f|ht)tp:\/\/\w+\.\w+/) {
print "Content-type: text/html\n\n";
print "<html><head><title>Ooops, You Entered An Invalid
URL!</title></head>\n";
print "<body bgcolor=white><br><center><font size=5 color=blue>\n";
print "<b>Ooops, You Entered An Invalid URL!</b></font><br><br>\n";
print "<b>Please hit your browser's \"back\" button and try
again.</b></center><br>\n";
exit;
}
############################################################################
##
# Check for restricted URLs.
############################################################################
##
open (FILE, "badurls.txt");
@badurls = <FILE>;
close (FILE);
foreach (@badurls) {
chomp $_;
$temp = $_;
if ($url =~ /$temp/i) {
print "Content-type: text/html\n\n";
print "<html><head><title>Sorry, You Can't Post A Link To That URL
Here!</title></head>\n";
print "<body bgcolor=white><br><center><font size=5 color=blue>\n";
print "<b>Sorry, You Can't Post A Link To That URL
Here!</b></font><br><br>\n";
print "<b>Please hit your browser's \"back\" button and try
again.</b></center><br>\n";
exit;
}
}
############################################################################
##
# Make sure the user entered their email address.
############################################################################
##
if ($email eq '') {
print "Content-type: text/html\n\n";
print "<html><head><title>Ooops, You Forgot To Enter Your Email
Address!</title></head>\n";
print "<body bgcolor=white><br><center><font size=5 color=blue>\n";
print "<b>Ooops, You Forgot To Enter Your Email
Address!</b></font><br><br>\n";
print "<b>Please hit your browser's \"back\" button and try
again.</b></center><br>\n";
exit;
}
############################################################################
##
# Make sure the user entered a valid email address format.
############################################################################
##
if ($email !~
/^[\w\d][\w\d\,\.\-]*\@([\w\d\-]+\.)+([a-zA-Z]{3}|[a-zA-Z]{2})$/) {
print "Content-type: text/html\n\n";
print "<html><head><title>Ooops, You Entered An Invalid Email
Address!</title></head>\n";
print "<body bgcolor=white><br><center><font size=5 color=blue>\n";
print "<b>Ooops, You Entered An Invalid Email
Address!</b></font><br><br>\n";
print "<b>Please hit your browser's \"back\" button and try
again.</b></center><br>\n";
exit;
}
############################################################################
##
# Preparing to see if link already exists in another form.
############################################################################
##
$shorturl = substr ($url,7);
if ($shorturl =~ /^www/) { $sld = substr ($shorturl,4); }
else { $sld = 'www.' . $shorturl; }
$url2 = 'http://' . $sld;
############################################################################
##
# Read in links.html file and process the submission.
############################################################################
##
$i=1;
$j=0;
%sections =
("busi","Business","comp","Computers","educ","Education","ente","Entertainme
nt","gove","Government","misc","Miscellaneous","pers","Personal");
open(FILE,"+>>$htmlpath");
flock(FILE, 2);
# rewind to beginning and read entire file
seek (FILE, 0, 0);
@lines = <FILE>;
foreach $line (@lines) {
if ($line =~ /\<li\>\<a href\=\"([^\"]+)\">([^<]+)<\/a>/) {
if ($line =~ /$url/ || $line =~ /$url2/ || $line =~ /$title/) {
print "Content-type: text/html\n\n";
print "<html><head><title>Sorry, That Link Already Exists On This
Page!</title></head>\n";
print "<body bgcolor=white><br><center><font size=5 color=blue>\n";
print "<b>Sorry, That Link Already Exists On This
Page!</b></font><br><br>\n";
print "<b>Please hit your browser's \"back\" button and try
again.</b></center><br>\n";
exit;
}
$i++;
}
}
############################################################################
##
# Increase counter that holds total number of postings by 1
############################################################################
##
open (ADNUM, "+<$CountFile");
flock (ADNUM, 2);
$AdNum = <ADNUM>;
chomp $AdNum;
$AdNum++;
seek (ADNUM,0,0);
print ADNUM "$AdNum\n";
close(ADNUM);
############################################################################
##
# rewind to beginning again and empty the file
seek (FILE, 0, 0);
truncate (FILE, 0);
############################################################################
##
# Loop through the links.html file line by line.
foreach $line (@lines) {
if ($line =~ /<!--time-->/) {
@months =
('January','February','March','April','May','June','July','August','Septembe
r','October','November','December');
@days =
('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');
($sec,$min,$hour,$mday,$mon,$year,$wday) = (localtime(time))[0,1,2,3,4,5,6];
if ($sec < 10) { $sec = "0$sec"; }
if ($min < 10) { $min = "0$min"; }
if ($hour < 10) { $hour = "0$hour"; }
if ($mday < 10) { $mday = "0$mday"; }
$date = "on $days[$wday], $months[$mon] $mday, 19$year at $hour:$min:$sec";
print FILE "<!--time--><b>The last link was added $date by
$remote.</b><br>\n";
}
elsif ($line =~ /<!--number-->/) {
print FILE "<!--number--><b>Currently there are <i>$i</i> links on this page
(of totally <i>$AdNum</i> that has been posted)!</b><br>\n";
}
elsif ($line =~ /<!--maxlinks-->/) {
print FILE "<!--maxlinks--><b>Each section is limited to <i>$maxlinks</i>
links, new links placed on top!</b><br>\n";
}
elsif ($line =~ /<!--power-->/) {
print FILE "<!--power--><b>This page is created and powered by <a
href=\"http:\/\/www.submitad.com\/blaster.htm\">FFA
Blaster!</a></b><br><br><hr><br>\n";
}
elsif (substr($line,0,4) ne "<li>") { print FILE $line; }
############################################################################
##
# Final check allows only $maxlinks per section.
else { if ($j < $maxlinks ) { print FILE $line; $j++; }
}
foreach $tag ( keys %sections) {
if ($line =~ /<!--$tag-->/) { $j=0; }
if ( ($section eq $sections{$tag}) && ($line =~ /<!--$tag-->/) ) {
$url =~ s/\\\*/\*/g;
$url =~ s/\\\+/\+/g;
$title =~ s/\\\*/\*/g;
$title =~ s/\\\+/\+/g;
print FILE "<li><a href=\"$url\">$title</a>\n";
$j++;
}
}
}
close(FILE);
############################################################################
###
# Save email address to file.
############################################################################
###
unless ($saveemail == 0) {
open (FILE,"$emaildatabase");
@lines = <FILE>;
close(FILE);
chomp $email;
$match = 0;
foreach $line (@lines) {
chomp $line;
if ($line eq $email) {
$match = 1;
}
}
# If no match we add the new email address
if (! $match) {
open (FILE,">>$emaildatabase");
flock(FILE, 2);
print FILE "$email\n";
close(FILE);
}
}
############################################################################
###
# Send confirmation email
############################################################################
###
unless ($sendemail == 0) {
open (EMAIL, "email.txt");
@body = <EMAIL>;
close (EMAIL);
open(MAIL,"|$mailprog -t");
print MAIL "To: $email\n";
print MAIL "From: $fromemail ($fromname)\n";
print MAIL "Subject: $subject\n\n";
print MAIL "Title: $title\n";
print MAIL "URL: $url\n";
print MAIL "Section: $section\n";
print MAIL "Submitted by: $email\n\n\n";
foreach (@body) { print MAIL "$_"; }
print MAIL " \n";
close (MAIL);
}
############################################################################
##
# All done, send user back to links.html
############################################################################
##
print "Pragma: no-cache\n";
print "Location: $htmlurl\n\n";
exit;
Thanks,
Sherry
------------------------------
Date: 2 Jun 1999 16:44:27 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: sendmail doesn't work
Message-Id: <3755515b@newsread3.dircon.co.uk>
Sherry <vision4@bigplanet.com> wrote:
> http://easyhomebiz.virtualave.net
>
> I'm having trouble with a pre-written perl script. It functions beautifully
> in accepting links, collecting e-mail addresses and posting links. It does
> not send an automatic e-mail after a link is posted like it should.
>
<big snip>
>
> # Server path of sendmail or equivalent.
> $mailprog = "/usr/sbin/sendmail";
>
You will almost certainly find that your sendmail is somewhere else
you will need to confirm with your service provider but it is more
often to be found at /usr/lib/sendmail.
>
> ############################################################################
> ##
> # DO NOT EDIT BELOW THIS LINE UNLESS YOU KNOW WHAT YOU'RE DOING!!!
> ############################################################################
>
I Just loved that - lets have a little look shall we ?
>
> read (STDIN, $input, $ENV{'CONTENT_LENGTH'});
Doesnt check that it got everything it should.
>
> open (FILE, "badwords.txt");
Doesnt check whether the open failed or not.
>
>
> open (FILE, "bademail.txt");
Doesnt check whether the open failed or not.
>
> open (FILE, "badurls.txt");
Doesnt check whether the open failed or not.
>
> ############################################################################
> ##
> # Make sure the user entered a valid email address format.
> ############################################################################
> ##
>
> if ($email !~
> /^[\w\d][\w\d\,\.\-]*\@([\w\d\-]+\.)+([a-zA-Z]{3}|[a-zA-Z]{2})$/) {
>
He he he he he he he
>
> open(FILE,"+>>$htmlpath");
Doesnt check whether the open failed or not.
> open (ADNUM, "+<$CountFile");
Doesnt check whether the open failed or not.
>
Ooh good dates.
> @months =
> ('January','February','March','April','May','June','July','August','Septembe
> r','October','November','December');
>
> @days =
> ('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');
>
> ($sec,$min,$hour,$mday,$mon,$year,$wday) = (localtime(time))[0,1,2,3,4,5,6];
>
My Word - Its that Code again ;-{
> if ($sec < 10) { $sec = "0$sec"; }
> if ($min < 10) { $min = "0$min"; }
> if ($hour < 10) { $hour = "0$hour"; }
> if ($mday < 10) { $mday = "0$mday"; }
>
Hmmm#
** WARNING NON Y2K Compliant code below
> $date = "on $days[$wday], $months[$mon] $mday, 19$year at $hour:$min:$sec";
^^^^^^^
Er what can I say.
>
> open (FILE,"$emaildatabase");
Doesnt check whether the open failed or not.
> open (FILE,">>$emaildatabase");
Doesnt check whether the open failed or not.
> open (EMAIL, "email.txt");
Doesnt check whether the open failed or not.
> @body = <EMAIL>;
>
> open(MAIL,"|$mailprog -t");
>
Doesnt check whether the open failed or not.
> close (MAIL);
>
The close should be checked as its on a pipe.
>
> Thanks,
>
I'd send it back to where it came from.
I think that "Do not edit below here ... " was rather a hostage to fortune
under the circumstances.
/J\
--
Jonathan Stowe <jns@gellyfish.com>
------------------------------
Date: 2 Jun 1999 15:43:13 GMT
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: sendmail doesn't work
Message-Id: <slrn7lakeq.1ec.fl_aggie@thepentagon.com>
On Wed, 2 Jun 1999 09:18:21 -0600, Sherry <vision4@bigplanet.com>, in
<928336338.638375@proxy1.bigplanet.com> wrote:
+ I'm having trouble with a pre-written perl script. It functions beautifully
+ in accepting links, collecting e-mail addresses and posting links. It does
+ not send an automatic e-mail after a link is posted like it should.
Check you syslog to see what sendmail errors are occuring. You could
have cut down the program to the bare essentials:
+ $mailprog = "/usr/sbin/sendmail";
+ unless ($sendemail == 0) {
Is this a true condition?
+ open (EMAIL, "email.txt");
+ @body = <EMAIL>; ^^ or die "email.txt: $!";
+ close (EMAIL);
Is this failing?
+ open(MAIL,"|$mailprog -t");
^^ or die "$mailprog failure: $!";
Is this failing?
[mail header and beginning body generation looks ok]
+ foreach (@body) { print MAIL "$_"; }
Ugh. Can be replaced with 'print @body;'.
+ print MAIL " \n";
+ close (MAIL);
perldoc -f close
If the file handle came from a piped open `close()' will
additionally return FALSE if one of the other system calls
involved fails or if the program exits with non-zero status. (If
the only problem was that the program exited non-zero `$!' will
be set to `0'.) Closing a pipe also waits for the process
executing on the pipe to complete, in case you want to look at
the output of the pipe afterwards, and implicitly puts the exit
status value of that command into `$?'.
You should check the return value, and if necessary, the values of
$! and $?.
James
------------------------------
Date: Wed, 02 Jun 1999 16:41:46 +0100
From: Andrew Collington <webmaster@avert.org>
Subject: String extraction problem - please help?
Message-Id: <375550B9.C6D44055@avert.org>
Hi there,
I have an array of strings, such as:
$lines[0]="/usr/home/avert/www/cgi/archive_98/dec/news_2"
$lines[0]="/usr/home/avert/www/cgi/archive_99/jan/news_1"
and many more in that array. Now I'm going through that array in the
normal way with foreach, such as:
foreach $line (@lines) {
...
}
My problem is this... I would like to be able to extract the '_??' part
of the string, and the 3 character long month abreviation too (jan, feb,
..., dec), but without the /'s. The directory
'/usr/home/avert/www/cgi/' renamins constant, but the _?? ranges from
_96 to _99. The month changes all the time, as does the news_x part
(which I am not interested in).
I know it would be something like 'if ($line =~
/(something)archive(something)/)' to extract the require strings, but I
just don't know regular expression enough (at all!) to do that. Though
I know you would use $1, $2, etc as the strings matched, but.. well, you
get my problem... :)
Any help you can offer on this would be very much appreciated!
Thanks!
Andy
------------------------------
Date: Wed, 02 Jun 1999 10:29:56 -0500
From: Matt Turner <matt@godzilla.tamu.edu>
Subject: Webpage Spell Checker in Perl
Message-Id: <37554DF4.8EC43896@godzilla.tamu.edu>
Does anyone know of a spell check cgi script written in Perl that would
allow a person to enter a url and get the webpage spell checked?
Matt
------------------------------
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 5860
**************************************