[11279] in Perl-Users-Digest
Perl-Users Digest, Issue: 4879 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Feb 12 10:08:37 1999
Date: Fri, 12 Feb 99 07:00:32 -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 Fri, 12 Feb 1999 Volume: 8 Number: 4879
Today's topics:
[Help] Anybody can make some like this perl cgi script <factory@factory.co.kr>
Re: Announce: Perl Function Repository (was Re: Calcula <dgris@moiraine.dimensional.com>
Re: Announce: Perl Function Repository (was Re: Calcula (Ilya Zakharevich)
automatically save web page <s.trew@bigfoot.com>
Re: automatically save web page <Tony.Curtis+usenet@vcpc.univie.ac.at>
Re: automatically save web page <ebohlman@netcom.com>
Re: Can anyone donate webspace to a person learning per (Tad McClellan)
Re: change column of nmbers to 2 dim array <pdcawley@bofh.org.uk>
Re: Changing the user inside a Perl script <richardsonja@logica.com>
Re: Content-type: application/pdf breaks in MS IE3.02 <flavell@mail.cern.ch>
DBI.PM MS Access problem (Clay Reimer)
Re: Does Perl restrict regular expressions? <pdcawley@bofh.org.uk>
Re: Fast Text Search <einar.gudmundsson@realtime.co.uk>
Re: Fast Text Search <zack44@altavista.net>
File Upload Temp file not deleted <e.christensen@netjob.dk>
Re: flock not working properly! HELP! (Ryan McGuigan)
modifying a file in place <oesch@bluewin.ch>
Re: Negative lookahead problem <ebohlman@netcom.com>
Re: newbie: hitcounter <paubucho@aug.edu>
Open a URL in perl <brandeda@se.bel.alcatel.be>
Re: Open a URL in perl <Tony.Curtis+usenet@vcpc.univie.ac.at>
Re: Open a URL in perl <ebohlman@netcom.com>
Re: Perl 5.002 compile on NT? <ibelgaufts@gfc-net.de>
Re: Perl Criticism (Richard Clamp)
Perl4 binaries for Aix4.1/RS600 ? <kwl@pine.dk>
Perlcc problem. <mangel@virtualsw.es>
Re: PFR: Julian Date <dgris@moiraine.dimensional.com>
PFR: read_file, write_file <uri@sysarch.com>
Re: PFR: UTC_to_Epoch (Randal L. Schwartz)
pipes on NT <pai@cadence.com>
pipes on NT <pai@cadence.com>
Problems Installing Perl 5.005 on Sloaris 2.6 <martin.strohmaier@bt.com>
Re: silly simple query (Tad McClellan)
sockets chrisNOSPAMPLEASE@atg-design.co.uk
Re: Win32 perl how to do system(set var= $var) <richardsonja@logica.com>
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 12 Feb 1999 15:55:35 +0900
From: "Yeong Mo/Director Hana co." <factory@factory.co.kr>
Subject: [Help] Anybody can make some like this perl cgi script ?
Message-Id: <7a17ju$s96$1@news.kornet.nm.kr>
I need a script which is only working for reading a data.txt file and
writing the lines to a $categorys/index.html file.
# The fillowing lines are in data.txt file.
101&&user@user1.com&&page01&&Sort_04&&yellow
kkk&&user@user2.com&&page01&&Sort_50&&green
gfg&&user@user3.com&&page52&&Sort_04&&red
fff&&user@user4.com&&page77&&Sort_04&&white
ggg&&user@user3.com&&page03&&Sort_83&&black
ses&&user@user4.com&&page02&&Sort_44&&blue
hot&&user@user3.com&&page03&&Sort_18&&silver
........ and much more....lines.
On this data.txt file there are five components are stored like bellow;
# "$login&&$email&&$pagename&&$categorys&&$maintitle
# &categorys means directorys.
The first line should be printed at the index file under directory of
Sort_04
I want it to be shown at Sort_04/index.html as following;
color=Green ---- directory=Sort_50 ----filename= page01 ---- Crick here to
go the page.
The HTML code should be like bellow;
<font size=2> color=Green ---- directory=Sort_50 ---- filename= page01 ----
<a href = "Sort_50/page01.html> Crick here to go the page.</a></font>
In case there are more than one lines including certain directory name, all
of the lines should be printed at the index file under certain directory
an Example); it should be printed the following lines at the index.html
under directory of Sort_04.
color=Yellow ---- directory=Sort_04 ----filename= page01 ---- Crick here to
go the page.
color=red ---- directory=Sort_04 ----filename= page52 ---- Crick here to go
the page.
color=white ---- directory=Sort_04 ----filename= page77 ---- Crick here to
go the page.
For your reference please visit my URL; it is still under construction, but
it is enough to show you my problem.
http://factory.co.kr/cgi/shop/enregister.html
http://factory.co.kr/cgi/shop/plink_en.html
You will understand why i need this script after you visit two of above url.
You can create a product catalog through "enregister.html" and the result
will be printed at a directory/index.html.
You can add a link through "plink_en.html". but the result will not be shown
imediately. it needs me to load certain script named "plink_en.cgi". After
that you can see your input information.
There is the problem. when i load "plink_en.cgi the printed lines created
by "enregister.cgi" are erased at the time.
So, i need to load a new script to print the lines again.
Also, this new script should have a function to edit and delete the lines
without changing all of rest html code created by "enregister.cgi.
To print this lines, you should use some like following codes due to create.
edit and delete the printed lines without changing the rest part of original
html file..
Hope you to understand what i mean, i really want this problem to be solved.
One more, I'm not familier with languges.
Thank you...
Yeong..
###Referance code...
# Suck the index page, and write the new entry to it
open(FILE, "$base_dir/$categorys/index.html ") || die "I can't open
$base_dir/$categorys/index.html file1\n";
flock (FILE, 1) or die "can't lock index file\n";
@lines = <FILE>;
close(FILE);
$sizelines = @lines;
# Now, re-open the links file, and add the new link
open(FILE, ">$base_dir/$categorys/index.html ") || die "I can't open
$base_dir/$categorys/index.html file2\n";
flock (FILE, 2) or die "can't lock index file\n";
for ($a = 0; $a <= $sizelines; $a++) {
$_ = $lines[$a];
if (/<!--begin-->/) {
print FILE "<!--begin-->\n";
print FILE "<p><img src=/cgi/shop/image/shop.gif border=0><font
size=2><b>$maintitle:</b><a
href=\"/cgi/shop/$categorys/$pagename.html\">$categorys/$pagename</a>-New</p
>\n";
} else {
print FILE $_;
}
}
close(FILE);
#########
# Suck the index page, and write the new entry to it
open(FILE, "$base_dir/$categorys/index.html ") || die "I can't open
$base_dir/$categorys/index.html file1\n";
flock (FILE, 1) or die "can't lock index file\n";
@lines = <FILE>;
close(FILE);
$sizelines = @lines;
# Now, re-open the links file, and add the new link
open(FILE, ">$base_dir/$categorys/index.html ") || die "I can't open
$base_dir/$categorys/index.html file2\n";
flock (FILE, 2) or die "can't lock index file\n";
for ($a = 0; $a <= $sizelines; $a++) {
$_ = $lines[$a];
if (/<!--begin-->/) {
print FILE "<!--begin-->\n";
print FILE "<p><img src=/cgi/shop/image/shop.gif border=0><font
size=2><b>$maintitle:</b><a
href=\"/cgi/shop/$categorys/$pagename.html\">$categorys/$pagename</a>-Edit</
p>\n";
} else {
print FILE $_;
}
}
close(FILE);
#################
# Suck the index page, and write the new entry to it
open(FILE, "$base_dir/$categorys/index.html ") || die "I can't open
$base_dir/$categorys/index.html file\n";
flock (FILE, 1) or die "can't lock index file\n";
@lines = <FILE>;
close(FILE);
$sizelines = @lines;
# Now, re-open the links file, and comment out the page to delete
open(FILE, ">$base_dir/$categorys/index.html ") || die "I can't open
$base_dir/$categorys/index.html file\n";
flock (FILE, 2) or die "can't lock index file to delete entry\n";
for ($a = 0; $a <= $sizelines; $a++) {
$_ = $lines[$a];
if (/$pagename.html/) {
# do nothing (ie. don't write)
}
else {
print FILE $_;
}
}
close(FILE);
+++++ end +++++
------------------------------
Date: 11 Feb 1999 23:10:28 -0700
From: Daniel Grisinger <dgris@moiraine.dimensional.com>
Subject: Re: Announce: Perl Function Repository (was Re: Calculate yesterdays date)
Message-Id: <m37lto6tkb.fsf@moiraine.dimensional.com>
[posted and mailed]
merlyn@stonehenge.com (Randal L. Schwartz) writes:
> Will it be changed to thedaybefore() tomorrow? :)
Of course not. Tomorrow it will be amended to read-
my $yesterday = yesterday();
my $daybefore = yesterday's_yesterday();
dgris
--
Daniel Grisinger dgris@moiraine.dimensional.com
perl -Mre=eval -e'$_=shift;;@[=split//;;$,=qq;\n;;;print
m;(.{$-}(?{$-++}));,q;;while$-<=@[;;' 'Just Another Perl Hacker'
------------------------------
Date: 12 Feb 1999 04:56:49 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Announce: Perl Function Repository (was Re: Calculate yesterdays date)
Message-Id: <7a0cah$6gp$1@mathserv.mps.ohio-state.edu>
[A complimentary Cc of this posting was sent to Daniel Grisinger
<dgris@moiraine.dimensional.com>],
who wrote in article <m3d83g92nf.fsf_-_@moiraine.dimensional.com>:
> The Perl Function Repository-
> http://moiraine.dimensional.com/~dgris/perl/pfr/
>
> Right now the only piece of code included in the PFR is Russ
> Allbery's yesterday() subroutine that was posted here yesterday.
If you are picking snippets from the newsfeed, probably it is good to
supply a DejaNews thread URL (is there such a beast?) so that people
will be able to track the related discussion as well.
Ilya
------------------------------
Date: Fri, 12 Feb 1999 13:07:19 +0000
From: Stephen Trew <s.trew@bigfoot.com>
Subject: automatically save web page
Message-Id: <36C42786.2039EF56@bigfoot.com>
Hi,
I need a script that will automatically go to a URL and grab
the contents of a table. I need to run it as a cron job
every day to collect data from the web.
Any suggestions as to how to start?
Thanks
Stephen
--
><>
Stephen Trew, email: s.trew@bigfoot.com
School of Geosciences, The Queen's University of Belfast
Belfast, BT7 1NN, Northern Ireland, UK.
phone: +44(0)1232 273367 fax: +44(0)1232 321280
web: http://www.bigfoot.com/~S.Trew/Home-Page
Reach me by ICQ. My ICQ# is 15302096
------------------------------
Date: 12 Feb 1999 15:21:56 +0100
From: Tony Curtis <Tony.Curtis+usenet@vcpc.univie.ac.at>
Subject: Re: automatically save web page
Message-Id: <83emnvem7v.fsf@vcpc.univie.ac.at>
Re: automatically save web page, Stephen
<s.trew@bigfoot.com> said:
Stephen> Hi, I need a script that will automatically
Stephen> go to a URL and grab the contents of a
Stephen> table. I need to run it as a cron job
Stephen> every day to collect data from the web.
Stephen> Any suggestions as to how to start?
perldoc LWP
perldoc HTTP::Request
hth
tony
--
Tony Curtis, Systems Manager, VCPC, | Tel +43 1 310 93 96 - 12; Fax - 13
Liechtensteinstrasse 22, A-1090 Wien. | <URI:http://www.vcpc.univie.ac.at/>
"You see? You see? Your stupid minds! | private email:
Stupid! Stupid!" ~ Eros, Plan9 fOS.| <URI:mailto:tony_curtis32@hotmail.com>
------------------------------
Date: Fri, 12 Feb 1999 14:13:02 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: automatically save web page
Message-Id: <ebohlmanF71otq.89E@netcom.com>
Stephen Trew <s.trew@bigfoot.com> wrote:
: I need a script that will automatically go to a URL and grab
: the contents of a table. I need to run it as a cron job
: every day to collect data from the web.
: Any suggestions as to how to start?
perldoc LWP
perldoc LWPCook
These will teach you how to retrieve the document at the URL.
perldoc HTML::Parser
perldoc HTML::Filter
These will teach you how to extract the table contents from the document
once you've got it. Resist the temptation to write regexps to do the
extraction; you'll spend far more time debugging your code than it will
take to learn the parsing modules.
------------------------------
Date: Fri, 12 Feb 1999 08:04:41 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Can anyone donate webspace to a person learning perl?
Message-Id: <pdc1a7.q8t.ln@magna.metronet.com>
j.kuiters@bigpond.com wrote:
: I'm currently learning Perl and am finding it lots of fun, however the
: programs I'm creating are to show my employer the benifits of using
: perl.
You should also see the below for more ammo:
http://www.perl.org/advocacy
(couldn't check that URL, seems their server is down right now...)
: I don't and nor do they have a webserver on the internet that has perl
: on it.
That would be one more data point worth pursuing, but it is
not really needed to show the value of Perl since most folks
who have adopted Perl do not use it for Web related stuff.
Perl had a significant following before the WWW was even invented.
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 12 Feb 1999 11:55:34 +0000
From: Piers Cawley <pdcawley@bofh.org.uk>
Subject: Re: change column of nmbers to 2 dim array
Message-Id: <s7p7ltnn8eh.fsf@windrush.elsevier.co.uk>
abigail@fnx.com (Abigail) writes:
> Bart Lateur (bart.lateur@skynet.be) wrote on MCMXC September MCMXCIII in
> !! Besides, what do you find so attractive in:
> !!
> !! map BLOCK LIST;
> !!
> !! over:
> !!
> !! foreach (LIST) BLOCK
> !!
>
> Order in which things appear. What I do is often more important then
> on what I perform things.
So what's wrong with
do BLOCK foreach (LIST);
--
Where is the Life we have lost in living?
Where is the wisdom we have lost in knowledge?
Where is the knowledge we have lost in information?
TS Eliot -- The Wasteland
------------------------------
Date: Fri, 12 Feb 1999 11:55:41 -0000
From: "James Richardson" <richardsonja@logica.com>
Subject: Re: Changing the user inside a Perl script
Message-Id: <7a14s3$7gt@romeo.logica.co.uk>
strattner@my-dejanews.com wrote in message
<79vgd4$hob$1@nnrp1.dejanews.com>...
>Here's my situation:
>
>
>I checked the documention, and it did mention a 'setuid'. However, I could
>not find any reference to a setuid command, code samples, nothing. My
>question is, where can I find helpful information on changing the effective
>user within Perl?
>
The euid and egid are held in the perl variables $> and $).
You can change them by assigning to them.
Check the perlvar manpage.
You probably have to have certain permissions to do this.....
Heres an example from some code of mine (_not_ running from a web server!)
.......
sub get_informix_uid {
(getpwnam("informix"))[3];
}
sub get_informix_gid {
(getgrnam("informix"))[2];
}
sub running_as_root {
if ( (getpwuid($<))[0] ne "root") {
return 0;
}
1;
}
sub become_informix {
Info( "Setting myself to informix:informix");
if (! running_as_root) {
Error ( "Can't change UID:GID, as not running as root");
return 0;
}
else {
$> = get_informix_uid;
$) = get_informix_gid;
}
1;
}
------------------------------
Date: Fri, 12 Feb 1999 12:03:31 +0100
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Content-type: application/pdf breaks in MS IE3.02
Message-Id: <Pine.HPP.3.95a.990212120142.9875C-100000@hpplus01.cern.ch>
On 12 Feb 1999, Sam Holden wrote:
> It's not a perl problem obviously.
Obviously
> Maybe IE isn't set up correctly, maybe
> your not following the protocol properly and Netscape is more forgiving
> than IE.
Try "IE isn't designed correctly". It doesn't support HTTP content-type
headers: it guesses instead.
------------------------------
Date: Fri, 12 Feb 1999 13:40:55 GMT
From: clay@zeddcomm.com (Clay Reimer)
Subject: DBI.PM MS Access problem
Message-Id: <36c42f56.5767123@news.nf.sympatico.ca>
I am wondering if anyone has run accross the following problem.
My perl script is trying to retrieve data from an MS Access database.
If the field type is text then the script can get the data. If the
field type is memo then, fields above a certain length are not
retreived. Is there some way around this? Can I retreive these longer
(3-4 line) memo fields into a variable?
Clay Reimer
clay@zeddcomm.com
------------------------------
Date: 12 Feb 1999 13:51:04 +0000
From: Piers Cawley <pdcawley@bofh.org.uk>
Subject: Re: Does Perl restrict regular expressions?
Message-Id: <s7p4sorn31z.fsf@windrush.elsevier.co.uk>
Jonathan Feinberg <jdf@pobox.com> writes:
> Piers Cawley <pdcawley@bofh.org.uk> writes:
>
> > Wouldn't it be a little more perlish to do:
> >
> > #!perl -w
> >
> > open LOG, "<filename" or die "Can't open filename: $!";
> >
> > my $unknown = 0;
> > while (<LOG>) { $unknown++ if /" +"$/ }
> > close LOG;
>
> Wouldn't it be a little more perlish to do:
>
> perl -lne '$c++ if /somepattern/;END{print "$c\n"}' file
You may well be right. However, I was under the impression that he
wanted something that could be dropped into production code. I may
be sticking my neck out here, but some of the more outlandish one-
liners which have cropped up in this thread aren't much use in the
'production' context.
--
Where is the Life we have lost in living?
Where is the wisdom we have lost in knowledge?
Where is the knowledge we have lost in information?
TS Eliot -- The Wasteland
------------------------------
Date: Fri, 12 Feb 1999 11:09:52 +0000
From: Einar Gudmundsson <einar.gudmundsson@realtime.co.uk>
Subject: Re: Fast Text Search
Message-Id: <36C40C00.AE22A678@realtime.co.uk>
Zack wrote:
>
> What's the fastest way to search through a delimited text database. Line by line and checking the individual fields after a split is fine up to about 5,000 records or so, but I really need to use bigger databases (up to 50-100,000 records) and a DBI database is not an option.
Why isn't a RDBMS an option. MySQL is a free product supporting most
platforms, and
supports almost all the features of a professional RDBMS suite like
Oracle or Sybase,
but usually works faster - up till 2-3 times.
Regrads
Einar Gudmundsson
------------------------------
Date: Fri, 12 Feb 1999 09:15:52 -0500
From: Zack <zack44@altavista.net>
To: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: Fast Text Search
Message-Id: <36C43798.23F56182@altavista.net>
Eric Bohlman wrote:
> Why isn't a DBI-compatible relational database engine an option? It's
> almost certainly the best solution for this size database.
This application is going on a Windows Based network.
Basically the client want the program index all of the documents on each users computer matching a certain criteria. (All text file, each with a certain extension).
The program will index the directory/path/filename (Location), the first line in the file (Title), and the first paragraph in the file (Description). The database is a simple, pipe delimited ascii, generated by the program automatically.
The program will do this for each users' machine, as well as the main netware server, each individual database being updated overnight.
They want it setup so that each PC has a local, searchable copy of the database (to reduce network traffic, it's an OOOOOLD coax network)
So, DBI isn't an option, as we don't want to install a DBI Database on each PC, and ODBC/Perl is just not "there" yet. The program will be compiled using perl2exe, so distributing Perl to each PC isn't a problem.
All of the required code is written and tested, but searching these big ascii databases is just too damn slow.
So, to restate the problem, I need a FAST way to search through the Description Field and return the PATH and Description.
Currently, the fastest I can get it is about :30 seconds to go through 50k
Zack
------------------------------
Date: Fri, 12 Feb 1999 13:02:31 +0100
From: Ernst Christensen <e.christensen@netjob.dk>
Subject: File Upload Temp file not deleted
Message-Id: <36C41856.AAFBC51D@netjob.dk>
Hi
I am using CGI.pm to upload files from a HTML- form.
I workes fine, but the problem is that the temporary files (e.g.
CGITemp17200) does not be deleted.
I have set the $TempFile::TMPDIRECTORY to a directory width all the
right permissions.
What is wrong, I am on a WinNT system.
Ernst
------------------------------
Date: Fri, 12 Feb 1999 12:50:33 GMT
From: ryan@mail.ramresearch.com (Ryan McGuigan)
Subject: Re: flock not working properly! HELP!
Message-Id: <tsVw2.375$%B4.387994@news.abs.net>
Ok, I feel stupid replying to my own posts, but someone asked me to post
my solution... Uhhhgggg, now I have to admit my own stupidity, it wasn't
flock causing the problem it was my script. I was writing to a temporary
file and then I would unlink it after closing it. I think the problem was
after closing it another process would open it and start writing to it
before it was unlinked... So I just put the process ID of each process in
the temp. file's name... I guess I could have unlinked it before closing
it??? Anything wrong with doing that?
Ryan McGuigan (ryan@mail.ramresearch.com) wrote:
: Don't bother responding I already figured it out.
: Ryan McGuigan (ryan@mail.ramresearch.com) wrote:
: : Hi, I got a big problem, for some reason flock isn't working properly.
: : here what I have in my locking subrouting,
: : unless (flock ($db_fh, 2 | 4)) {
: : warn "Waiting for lock ($!) ....\n";
: : for ($i = 0; $i < 1000; $i ++ ) {
: : if (flock ($db_fh, 2 | 4)) {
: : sleep(1);
: : last;
: : }
: : warn "$!\n"
: : }
: : }
: : This seems to work ok when there are like 2 processes that run at the same
: : time, but if I run around 5 to 20 processes, it somehow doesn't work.
: : This is a severe problem, it doesn't just lose data, because of the way I
: : manipulate the file it gets completely whacked.
: : BTW, the 2 and the 4 are correct on my system (Linux 2.0.35, Perl
: : 5.004_04), I checked to be sure. I have tried all the examples give in
: : the camel book, perldocs etc etc etc... NOTHING will make it work right.
: : If anyone has ANY thing they can offer it would be much appreciated.
: : thanks
: : Ryan
------------------------------
Date: Fri, 12 Feb 1999 13:08:59 +0100
From: Philippe Oesch <oesch@bluewin.ch>
Subject: modifying a file in place
Message-Id: <36C419DB.F02F3797@bluewin.ch>
PerlMongers et al.,
how would i get lines 2 to eof of NEWS to the top of NICHTNEWS?
just got a problem with the following chunk:
while (<NEWS>){
if (2 .. eof()) {$transfer = $_}
while (<NICHTNEWS>) {
if ($. == 1) {
print NICHTNEWS_TMP $transfer;
}
}
}
i am trying to edit the file with a backup copy (as in the perl
cookbook, recipe 7.8). $transfer seems to be empty in the second while
statement. stupid me can't fix it right now, err...
could you...?
--
Philippe Oesch
PGP Key ID: 0x6F293ADC
------------------------------
Date: Fri, 12 Feb 1999 13:57:53 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: Negative lookahead problem
Message-Id: <ebohlmanF71o4H.6p3@netcom.com>
Antti Boman <antti.boman***NOSP@M***helsinki.fi> wrote:
: $tmp1="Check http://something.com/ out.";
: $tmp2="Check <a href="http://something.com/">this</a> out.";
: How can substitute the URL in $tmp1 to <a href="http://something.com/">, but
: still, with the same piece of code, not affect $tmp2?
: This doesn't naturally work:
: s{(?! href="?)(http://something.com/)}{<a href="\1">};
The reason it doesn't work is that you're using a negative look*ahead*
when what you need is a negative look*behind*. Your lookahead
says "don't match the 'http://...' if what we're currently looking at is
a space followed by 'href...'" and has no effect because the stuff past the
lookahead can't possibly match the stuff inside the lookahead. A
lookahead isn't useful when the pattern after it can only match a
literal string; its purpose is to impose some constraints on a subsequent
pattern that's capable of matching (too many) multiple strings
As of Perl 5.005, you can use negative lookbehinds, which do what you
want (they impose constraints based on "what we were just looking at"
rather than "what we're now looking at").
------------------------------
Date: Fri, 12 Feb 1999 09:14:43 -0500
From: Pavel Aubuchon-Mendoza <paubucho@aug.edu>
Subject: Re: newbie: hitcounter
Message-Id: <36C43751.10B719F7@aug.edu>
www.worldwidemart.com/scripts
John wrote:
> I would like to use perl to create a hitcounter for a website. Does
> anyone know of some documentation or examples that could get me started
> and/or show me what to look out for?
>
> thanks, John
--
Pavel Aubuchon-Mendoza
Network Specalist I
Augusta State University
(706)737-1484
pgp: finger csvpra@news.aug.edu
------------------------------
Date: Fri, 12 Feb 1999 14:04:12 +0100
From: David Van den Brande <brandeda@se.bel.alcatel.be>
Subject: Open a URL in perl
Message-Id: <36C426CC.DD666A41@se.bel.alcatel.be>
Hello,
I have a form with one text field.
The user must put a URL in this field en then submit it (method POST).
My perl script reads out the URL.
I would like now to add some commands to my script so I can open the
HTML page that corresponds with the URL, modify it and returning it to
the customer.
How do I have to do this?
I tried the following but that doesn't work:
(the URL is put into the
variable $url)
...
open baseURL, "+<$url" or die "Can't open file";
@lines=<baseURL>;
close $line (@lines);
foreach $line (@lines)
{
#print some modifications
print "$line";
}
...
Thanks in advance,
David
Please mail your suggestions to brandeda@se.bel.alcatel.be
Thanks
--
V David Van den Brande, Trainee at
----------------- Alcatel Switching VE27
| A L C A T E L | Fr. Wellesplein 1 - 2018 Antwerp - Belgium
----------------- mailto:brandeda@se.bel.alcatel.be
------------------------------
Date: 12 Feb 1999 15:22:55 +0100
From: Tony Curtis <Tony.Curtis+usenet@vcpc.univie.ac.at>
Subject: Re: Open a URL in perl
Message-Id: <83d83fem68.fsf@vcpc.univie.ac.at>
Re: Open a URL in perl, David
<brandeda@se.bel.alcatel.be> said:
David> Hello, I have a form with one text field.
David> The user must put a URL in this field en then
David> submit it (method POST). My perl script
David> reads out the URL. I would like now to add
David> some commands to my script so I can open the
David> HTML page that corresponds with the URL,
David> modify it and returning it to the customer.
David> How do I have to do this?
If you want to fetch a URL the simplest way is with
LWP, so
perldoc LWP
hth
tony
--
Tony Curtis, Systems Manager, VCPC, | Tel +43 1 310 93 96 - 12; Fax - 13
Liechtensteinstrasse 22, A-1090 Wien. | <URI:http://www.vcpc.univie.ac.at/>
"You see? You see? Your stupid minds! | private email:
Stupid! Stupid!" ~ Eros, Plan9 fOS.| <URI:mailto:tony_curtis32@hotmail.com>
------------------------------
Date: Fri, 12 Feb 1999 14:07:32 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: Open a URL in perl
Message-Id: <ebohlmanF71oKK.7tp@netcom.com>
David Van den Brande <brandeda@se.bel.alcatel.be> wrote:
: I would like now to add some commands to my script so I can open the
: HTML page that corresponds with the URL, modify it and returning it to
: the customer.
: How do I have to do this?
: I tried the following but that doesn't work:
: (the URL is put into the
: variable $url)
: ...
: open baseURL, "+<$url" or die "Can't open file";
You're suffering from a very common form of confusion here. Despite the
fact that URLs have a syntax that resembles that of Unix filenames, a URL
is *NOT*, I repeat *NOT*, a filename and does *NOT* represent an object
accessible through the local machine's filesystem! Perl's 'open()'
translates into a request to the local filesystem, and thus can only be
applied to filenames, not URLs.
If you want to read the resource corresponding to a URL, you need to make
a connection to the machine where the resource resides, request it via
the appropriate protocol, and receive it. Fortunately, the LWP module
does all this for you.
: @lines=<baseURL>;
: close $line (@lines);
This isn't legal Perl code.
: foreach $line (@lines)
: {
: #print some modifications
: print "$line";
: }
: ...
------------------------------
Date: Fri, 12 Feb 1999 14:38:58 +0100
From: "J|rgen Ibelgaufts" <ibelgaufts@gfc-net.de>
Subject: Re: Perl 5.002 compile on NT?
Message-Id: <36C42EF2.31C298A2@gfc-net.de>
HI,
i did it like this:
go to http://www.perl.com/CPAN-local/authors/id/GSAR/
download one of the files perl5.005.tar.gz or perl5.005_02.tar.gz
unpack them with winzip into the main directory of your disk drive
you will find a new directory named perl5.005 or perl5.005_02
change into this directory and read the file readme.win32
follow the instructions and go into the directory win32 and change one of the file
makefile or makefile.mk (depending on which make tool you have) in order to tell
the make tool which compiler you have and where it is and whether you want to have
the experimental thread support and such things. the makefiles document
themselves and tell you exactly what to do.
after editing, you type make or dmake, and it will build.
after building, you type make test or dmake test, and it will test itself.
after testing, you tyoe make install or dmake install, and it will install itself.
finally you can change the global path variable and add the directory of your perl
executable.
I found it _v_e_r_y___e_a_s_y
Juergen Ibelgaufts
----------------------------------------------------------------------
Brian P. Barnes schrieb:
>
> Hi,
>
> I really like Perl and have used it for years. I compiled it on my Sun
> box with basically 4 commands per module. A 4th grader could do it after
> glancing at the instructions.
>
> On my NT box, I currently use ActiveState Perl due to severs compiling
> difficulties on NT, but I want to compile it from source like the real
> hackers do. I want to add many modules, some of which I understand are
> not binarily compatible with ActiveState.
>
> I have downloaded the latest, stable Perl (p500502) and have vc++ 5.0
> and am using the "cmd" shell as recommended in the readme.win32. I have
> edited the win32/makefile.mk as follows (and checked the accuracy of
> CCHOME):
> D:\download\p500502\win32>diff makefile.mk makefile.mk.021199
> 20c20
> < INST_DRV *= d:
> ---
> > INST_DRV *= c:
> 43,44c43,44
> < CCTYPE *= MSVC
> < #CCTYPE *= BORLAND
> ---
> > #CCTYPE *= MSVC
> > CCTYPE *= BORLAND
> 66c66
> < USE_PERLCRT *= define
> ---
> > #USE_PERLCRT *= define
> 104,105c104
> < #CCHOME *= C:\bc5
> < CCHOME *= d:\DevStudio\vc
> ---
> > CCHOME *= C:\bc5
>
> D:\download\p500502\win32>ls d:\DevStudio\vc
> ENVIRON.HTM VCRemove crt lib
> VCREAD.HTM atl help mfc
> VCREMOVE.EXE bin include vcremove.inf
>
> I have run the vcvars32.bat file and verified that the variables are
> indeed set. When I try the nmake,
> I immediately get this error.
> D:/download/p500502/win32>D:/DevStudio/VC/bin/nmake
>
> Microsoft (R) Program Maintenance Utility Version 1.62.7022
> Copyright (C) Microsoft Corp 1988-1997. All rights reserved.
>
> makefile(11) : fatal error U1035: syntax error : expected ':' or '='
> separator
> Stop.
>
> Any ideas?
>
> Thank you,
>
> Brian
------------------------------
Date: Fri, 12 Feb 1999 10:48:51 GMT
From: richardc@tw2.com (Richard Clamp)
Subject: Re: Perl Criticism
Message-Id: <36c40680.5586888@news.cis.dfn.de>
On Fri, 12 Feb 1999 04:10:47 GMT, topmind@technologist.com wrote:
>
>Correction: If population Y tends to abuse X, then X
>should not be used by population Y.
>
I dunno, my (Y) car wouldn't go half as well if you took it's gearbox
(X) away, or stopped me using it.
But then you had to know that wouldn't hold up to a second of thought,
surely.
Richard
------------------------------
Date: Fri, 12 Feb 1999 13:48:17 +0100
From: Keld Wesenberg =?iso-8859-1?Q?Lyngs=F8?= <kwl@pine.dk>
Subject: Perl4 binaries for Aix4.1/RS600 ?
Message-Id: <36C42311.FD03854B@pine.dk>
Hello All,
Is there someone who knows a site where I can optain
Perl4 binaries for Aix4.1/RS6000 ?
Thanks in advance
Keld
------------------------------
Date: Fri, 12 Feb 1999 13:54:21 +0100
From: Miguel Angel Moreno <mangel@virtualsw.es>
Subject: Perlcc problem.
Message-Id: <36C4247D.D2F36568@virtualsw.es>
Hi!
I'm trying to compile a perl program with perlcc but it always answer
with an error during the cc compilation of the .c code returned by
perlcc in the first step, the output is always like:
/tmp/cca009511.o(text+0x1012):in function 'pp_main'
/tmp/cca009511.o(text+0x1012):undefined reference to 'runops'
I hope somebody can help me with this.
Thanks in advance.
mangel
------------------------------
Date: 12 Feb 1999 00:16:55 -0700
From: Daniel Grisinger <dgris@moiraine.dimensional.com>
Subject: Re: PFR: Julian Date
Message-Id: <m3u2ws5bx4.fsf@moiraine.dimensional.com>
[posted and mailed]
snow@biostat.washington.edu (Gregory Snow) writes:
<snip>
> Note, this is off from the "usual" definition of Julian days by a
> constant, but if that is important to you, then just add the constant
> back in.
The constant should be documented in the code.
dgris
--
Daniel Grisinger dgris@moiraine.dimensional.com
perl -Mre=eval -e'$_=shift;;@[=split//;;$,=qq;\n;;;print
m;(.{$-}(?{$-++}));,q;;while$-<=@[;;' 'Just Another Perl Hacker'
------------------------------
Date: 12 Feb 1999 00:59:55 -0500
From: Uri Guttman <uri@sysarch.com>
Subject: PFR: read_file, write_file
Message-Id: <x71zjwp3fo.fsf_-_@home.sysarch.com>
BTW i never saw the original announce of this. it think it is great.
here are 2 little favorites of mine which seem to get asked for by all
newbies. read a file as a list or a single string and write a file from
a list or string.
they are so simple i didn't comment them. also they need to use Carp but
that can be changed by the end user. they also don't use the IO::
modules so they are quicker and don't need to load lots of code.
enjoy,
uri
# utility sub to read a file in.
# it can return a single string or a list of lines
use Carp ;
sub read_file {
my( $file_name ) = @_ ;
my( $text, @lines ) ;
local( *FH ) ;
open( FH, $file_name ) || croak "can't open '$file_name' $!" ;
if ( wantarray ) {
@lines = <FH> ;
close( FH ) ;
return @lines ;
}
local( $/ ) ;
$text = <FH> ;
close( FH ) ;
return( $text ) ;
}
# utility sub to write a file file. takes a file name and
# single string or a list of lines/strings
sub write_file {
my( $file_name ) = shift ;
local( *FH ) ;
open( FH, ">$file_name" ) || croak "can't create $file_name $!" ;
print FH @_ ;
close( FH ) ;
}
--
Uri Guttman ----------------- SYStems ARCHitecture and Software Engineering
Perl Hacker for Hire ---------------------- Perl, Internet, UNIX Consulting
uri@sysarch.com ------------------------------------ http://www.sysarch.com
The Best Search Engine on the Net ------------- http://www.northernlight.com
------------------------------
Date: 12 Feb 1999 06:13:42 -0800
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: PFR: UTC_to_Epoch
Message-Id: <m1iud7emll.fsf@halfdome.holdit.com>
>>>>> "Larry" == Larry Rosler <lr@hpl.hp.com> writes:
Larry> You bet! Thanks for setting this up. Links to the Repository need to
Larry> be created from http://www.perl.com/ and other appropriate places, of
Larry> course.
Even simpler... the whole respository should be mirrored into the
CPAN. Then you wouldn't have to worry about hundreds of hits a minute
coming at your machine when this gets popular, and it automatically
ends up on those CDROMs of the CPAN.
Or, just convince the Powers That Be that subroutine snippets are a
subset of "scripts", and put it in the existing scripting section of
the CPAN.
<mimic character=obiwan>Use the existing mechanisms, Luke!</mimic>
--
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me
------------------------------
Date: Fri, 12 Feb 1999 16:10:41 +0531
From: "Narasimha G. Pai" <pai@cadence.com>
Subject: pipes on NT
Message-Id: <36C404ED.CAD4339B@cadence.com>
Hi ,
I need some help . The following code works fine
on Unix systems but is yells and fails on NT .
on which I am using activestate PERL .
My real aim is to start a process from a perl script
and wait for it to end for a max $TIMEOUT secs .
if it does not end I want to kill the child process
BUT continue running the perl script . If this code
is not portable is there any alternative way of
doing it ? :
In the code the open command fails .
if ($pid = open(CMD, "-|"))
{
# Parent
$SIG{"ALRM"} = "AlarmINT";
alarm($delay);
}
else
{
# Child
# setpgrp(0, $$);
setpgrp();
system("$cmd 2>&1");
exit($?);
}
--
|======================================================================|
|Kanwarpreet Singh Grewal | email: kanwar@cadence.com |
| Cadence Design Systems (India) Pvt. Ltd.,| Home address: E-217 |
| SDF # B-8, Noida Export Processing Zone, | Ram Vihar |
| Noida, UP - 201305, India | Sector : 30 |
| Tel: +91-11-8562842 | Noida, UP India |
|======================================================================|
------------------------------
Date: Fri, 12 Feb 1999 16:11:14 +0531
From: "Narasimha G. Pai" <pai@cadence.com>
Subject: pipes on NT
Message-Id: <36C4050E.42617817@cadence.com>
Hi ,
I need some help . The following code works fine
on Unix systems but is yells and fails on NT .
on which I am using activestate PERL .
My real aim is to start a process from a perl script
and wait for it to end for a max $TIMEOUT secs .
if it does not end I want to kill the child process
BUT continue running the perl script . If this code
is not portable is there any alternative way of
doing it ? :
In the code the open command fails .
if ($pid = open(CMD, "-|"))
{
# Parent
$SIG{"ALRM"} = "AlarmINT";
alarm($delay);
}
else
{
# Child
# setpgrp(0, $$);
setpgrp();
system("$cmd 2>&1");
exit($?);
}
--
|======================================================================|
|Kanwarpreet Singh Grewal | email: kanwar@cadence.com |
| Cadence Design Systems (India) Pvt. Ltd.,| Home address: E-217 |
| SDF # B-8, Noida Export Processing Zone, | Ram Vihar |
| Noida, UP - 201305, India | Sector : 30 |
| Tel: +91-11-8562842 | Noida, UP India |
|======================================================================|
------------------------------
Date: Fri, 12 Feb 1999 11:52:13 +0000
From: martin strohmaier <martin.strohmaier@bt.com>
Subject: Problems Installing Perl 5.005 on Sloaris 2.6
Message-Id: <36C415EC.3F9DFFA5@bt.com>
Getting error : on install make test :
make: Warning: Both `makefile' and `Makefile' exist
`sh cflags libperl.a miniperlmain.o` miniperlmain.c
CCCMD = gcc -DPERL_CORE -c
In file included from perl.h:361,
from miniperlmain.c:11:
/usr/local/lib/gcc-lib/sparc-sun-solaris2.4/2.6.3/include/sys/param.h:185:
warning: `NBBY' redefined
/usr/include/sys/select.h:45: warning: this is the location of the
previous definition
In file included from /usr/include/sys/stream.h:26,
from /usr/include/netinet/in.h:38,
from perl.h:517,
from miniperlmain.c:11:
/usr/include/sys/model.h:32: #error "No DATAMODEL_NATIVE specified"
*** Error code 1
make: Fatal error: Command failed for target `miniperlmain.o'
#
I cannot identify cause
Any suggestions ?
------------------------------
Date: Fri, 12 Feb 1999 08:07:45 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: silly simple query
Message-Id: <hjc1a7.q8t.ln@magna.metronet.com>
Gavin Cato (gavin@optus.net.au.dontspam.myass) wrote:
: What would be the perl equivalent of
: cat $filename | grep $variable | wc -l
^^^
Useless Use Of Cat...
perl -ne '$cnt++ if /variable/; END {print "$cnt\n"}' filename
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Fri, 12 Feb 1999 13:41:42 GMT
From: chrisNOSPAMPLEASE@atg-design.co.uk
Subject: sockets
Message-Id: <7a1b2k$3h0$1@nnrp1.dejanews.com>
Hi,
Firstly I have never used sockets before...I have read the perldocs, which
have shedded *some* light but am still no nearer to solving my problem.
(btw..remember..you must have been in this position once????)
What I'm wanting to do is use sockets to execute a perl/ODBC script on NT4,
which connects to an Oracle8 database (this script is already written and
works), and pass the results back to UNIX.
...but I have no idea where to start..what port I need to use..in fact how to
go about it...
does anyone know any URL's that explain how to achieve this scenario, or can
anyone point me in the right direction who has done this before?
Even a script to connect up to NT4 and print the system time would be a start
and would help me...
Many TIA
Chris
-=-=-
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Fri, 12 Feb 1999 14:25:27 -0000
From: "James Richardson" <richardsonja@logica.com>
Subject: Re: Win32 perl how to do system(set var= $var)
Message-Id: <7a1dks$b3c@romeo.logica.co.uk>
sirron@mail.mcoe.k12.ca.us wrote in message
<79sn5g$329$1@nnrp1.dejanews.com>...
>Hello group,
>
>When I do this, I find that the return code is always 0. When I do a set
>command in a dos window after running this script, I find that the variable
>is not being set.
>
>Any thoughts would be appreciated.
Ho hum.... (this answer is about *nix, but I guess that NT follows something
similar)...so your program wont work on Linux either.
A child inherits an environment from its parent.
A child cannot alter the environment of its parent, cos the two processes
exist in separate memory spaces. (unless 1) The parent is involved somehow
2) maybe with vfork(), but this is probably v. dangerous and unsupported))
This is why you have things like the '.' and 'source' commands.
Consider:
Program A Child
-------------- --------
setenv("X=1")
fork (Spoing - I'm a new
process - X=1)
exec(b)
b: X=2
exit
X is still 1
HTH
James
------------------------------
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 4879
**************************************