[16266] in Perl-Users-Digest
Perl-Users Digest, Issue: 3678 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Jul 15 14:07:11 2000
Date: Sat, 15 Jul 2000 11:05:10 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <963684310-v9-i3678@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Sat, 15 Jul 2000 Volume: 9 Number: 3678
Today's topics:
Re: "Perl by examples" (Steve Leibel)
Accessing string martho@my-deja.com
Re: Accessing string <bwalton@rochester.rr.com>
Re: Accessing string (Tad McClellan)
ANNOUNCE Mac::Serial.pm v1.007 - OOI to Macintosh seria <diverdi@XTRsystems.com>
ANNOUNCE: Bit::Vector 5.8 release candidate <sb@sdm.de>
Re: ATTENTION PERL MACHOES!!!!!!!!!!!!!!!!!!! (Eric Bohlman)
flock nonsense ? martin@radiok2r.de
Re: flock nonsense ? <slinberg@silicongoblin.com>
Re: flock nonsense ? <bwalton@rochester.rr.com>
Re: flock nonsense ? <flavell@mail.cern.ch>
Re: flock nonsense ? (Tad McClellan)
help with FlatText DB Editor <cmulder@casema.net>
Re: help with FlatText DB Editor (Tad McClellan)
Re: local and use strict (Eric Bohlman)
Re: Locking a file <flavell@mail.cern.ch>
Re: modify source file <rhomberg@ife.ee.ethz.ch>
Re: Perl can't add ! <cal@iamcal.com>
Re: Perl Expert? I need help! (Tad McClellan)
Re: PERL IDES <jraff@home.com>
Please criticise this text extraction script <rhys.tucker@dtn.ntl.com>
Simple IP/Domain validation???? <coy@coystoys.com>
Re: Time in mili-seconds <rhomberg@ife.ee.ethz.ch>
Re: Time in mili-seconds (Tad McClellan)
Re: Trying to use an array as a hash value (Tad McClellan)
Re: Upper-to-lower case problem (Alan Page)
Re: Upper-to-lower case problem (Alan Page)
Re: Upper-to-lower case problem (Alan Page)
Web site engine using Perl <berube@odyssee.net>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 15 Jul 2000 11:07:21 -0700
From: stevel@coastside.net (Steve Leibel)
Subject: Re: "Perl by examples"
Message-Id: <stevel-1507001107220001@192.168.100.2>
In article <Pine.BSF.4.21.0007131917160.214-100000@pepe.asi.pwr.wroc.pl>,
=?X-UNKNOWN?Q?Adam_Sk=F3ra?= <pepe@pepe.asi.pwr.wroc.pl> wrote:
> Could anyone send me book: "perl by examples" in HTML ?
Try
www.amazon.com
I hear they'll send you just about any book you want.
------------------------------
Date: Sat, 15 Jul 2000 14:26:56 GMT
From: martho@my-deja.com
Subject: Accessing string
Message-Id: <8kpsb4$8pv$1@nnrp1.deja.com>
Hello !
Are there any possebilitys to access a string like in other
script-languages with
left
right
mid
length
???
Regards
Martin
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Sat, 15 Jul 2000 14:54:25 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: Accessing string
Message-Id: <39707B62.B1B49B61@rochester.rr.com>
martho@my-deja.com wrote:
...
> Are there any possebilitys to access a string like in other
> script-languages with
> left
> right
> mid
> length
...
> Martin
...
perldoc -f length
perldoc -f substr
If you don't know what means, type it in at a command prompt.
--
Bob Walton
------------------------------
Date: Sat, 15 Jul 2000 11:39:17 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Accessing string
Message-Id: <slrn8n11d5.h2u.tadmc@magna.metronet.com>
On Sat, 15 Jul 2000 14:26:56 GMT, martho@my-deja.com <martho@my-deja.com> wrote:
>Hello !
>
>Are there any possebilitys to access a string like in other
>script-languages with
>left
>right
>mid
>length
errr, as you cannot count on the readers of your article
knowing whatever unnamed language you are referring to,
you should describe what those thingies do.
So now you will just get a bunch of guesses at what it is you want.
Much better to say what it is you want rather than rely on folks
guessing correctly...
My Guesses:
perldoc -f length
perldoc -f substr
perldoc perlre
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 13 Jul 2000 00:39:29 -0600
From: "Joseph A. DiVerdi" <diverdi@XTRsystems.com>
Subject: ANNOUNCE Mac::Serial.pm v1.007 - OOI to Macintosh serial ports
Message-Id: <FrZb5.19862$EQ3.599376@news-east.usenetserver.com>
Announce Mac::Serial.pm v1.007 -
object-oriented interface to Macintosh serial ports
This MacPerl library uses a simple object-oriented programming style to
provide a set of tools to control the serial ports of the Macintosh and
communicate through them.
This library defines Mac::Serial objects, entities which contain the
values for serial port configuration parameters. Using a Mac::Serial
object's methods ports can be opened and closed and data can be sent
out of those ports or received through them. Each Mac::Serial object is
independent of the others and can be manipulated independently. Ports
can be repeatedly opened and closed, several can be open
simultaneously, configuration parameters can be changed at any time,
and data sends and receives are independent of each other.
In addition, various configuration settings are under program control
including data transmission protocols (baud rate, data size, etc.),
hardware and software flow control methods, and the size of the buffer
allocated to the input driver.
The following example creates a Mac::Serial object and reports which
ports are available on the executing machine. It then opens the port
named "Modem Port", sets a few configuration parameters including the
input buffer size to (an arbitrary) 4,000 bytes, sends a few characters
out the serial port, and closes the port. At every step, error checking
is performed and the script dies if any error response is received.
#! perl -w
use Mac::Serial;
my $error;
my $modem = Mac::Serial->new;
$error = $modem->error;
die $error if $error;
my @port_names = $modem->ports;
print "Available port Names: ", join("'", @port_names), "\n";
$modem->open('Modem Port');
$error = $modem->error;
die $error if $error;
$modem->config(baudrate => 19200, parity => 'even', datasize => 7,
stopbits => 1.5, buffer => 4000, XOnOut => "off");
$error = $modem->error;
die $error if $error;
$modem->send('Hello world!');
$error = $modem->error;
die $error if $error;
$modem->close;
$error = $modem->error;
die $error if $error;
exit;
Comments are always appreciated and can be sent todiverdi@xtrsystems.com
------------------------------
Date: Sat, 15 Jul 2000 00:56:16 +0200 (MET DST)
From: Steffen Beyer <sb@sdm.de>
Subject: ANNOUNCE: Bit::Vector 5.8 release candidate
Message-Id: <4sZb5.19871$EQ3.599580@news-east.usenetserver.com>
=====================================
Package "Bit::Vector" Version 5.8
=====================================
- RELEASE CANDIDATE -
This package is available for download from my web site at
http://www.engelschall.com/u/sb/download/
Prerequisites:
--------------
Perl version 5.000 or higher, and an ANSI C compiler (!)
^^^^^^
What's new in version 5.8:
--------------------------
+ Changed "na" to "PL_na" in Vector.xs in order to make the module
ready for Perl 5.6.0.
+ Removed the error messages which appeared at global destruction
time with Perl 5.6.0.
+ Changed the corresponding test script (t/02____destroy.t) accordingly.
+ Optimized the "strEQ" away from the typemap section in Vector.xs.
+ Fixed the misspelled word "whether" in the documentation.
+ Added method "Power()".
+ Added overloaded operator "**" (for exponentiation).
+ Changed method "Copy()"; the two vectors do not need to have the same
size anymore. The method will copy as much as will fit or fill up
with 0's or 1's (depending on the sign of the source) if necessary.
+ Changed the corresponding test script (t/09_parameters.t) accordingly.
Abstract:
---------
Bit::Vector is an efficient C library which allows you to handle
bit vectors, sets (of integers), "big integer arithmetic" and
boolean matrices, all of arbitrary sizes.
The library is efficient (in terms of algorithmical complexity)
and therefore fast (in terms of execution speed) for instance
through the widespread use of divide-and-conquer algorithms.
The package also includes an object-oriented Perl module for
accessing the C library from Perl, and features overloaded
operators for maximum ease of use.
The C library can nevertheless be used stand-alone, without Perl.
Legal issues:
-------------
This package with all its parts is
Copyright (c) 1995 - 2000 by Steffen Beyer.
All rights reserved.
This package is free software; you can use, modify and redistribute
it under the same terms as Perl itself, i.e., under the terms of
the "Artistic License" or the "GNU General Public License".
The C library at the core of this Perl module can additionally
be used, modified and redistributed under the terms of the
"GNU Library General Public License".
Please refer to the files "Artistic.txt", "GNU_GPL.txt" and
"GNU_LGPL.txt" in this distribution, respectively, for details!
Author's note:
--------------
This is a release candidate.
Please report any bugs or ugly things you find!
Suggestions are welcome!
I hope you will find this new version beneficial!
Yours sincerely,
--
Steffen Beyer <sb@engelschall.com>
http://www.engelschall.com/u/sb/whoami/ (Who am I)
http://www.engelschall.com/u/sb/gallery/ (Fotos Brasil, USA, ...)
http://www.engelschall.com/u/sb/download/ (Free Perl and C Software)
------------------------------
Date: 15 Jul 2000 16:29:06 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: ATTENTION PERL MACHOES!!!!!!!!!!!!!!!!!!!
Message-Id: <8kq3gi$1i3$1@slb2.atl.mindspring.net>
Nnickee (nnickee@nnickee.com) wrote:
: <nod> That's exactly what I was trying to say. If I were to attempt
: to put together a "rules for posting questions to c.l.p.m" it would
: probably go something like this: [ thee's and thou's and ye's are
: most likely used incorrectly at least 90% of the time in the
: following, but it's just off the top of my head ]
[snip]
: 9. Thou shalt not gush all over the Gurus. Thee are expected to
: thank them when they helpeth thee.
10. Thou shalt not vainly assume that thy prayers to the Most Holy
Operating System have been answered; thou shalt die() should they fall on
deaf ears.
------------------------------
Date: Sat, 15 Jul 2000 14:11:36 GMT
From: martin@radiok2r.de
Subject: flock nonsense ?
Message-Id: <8kpref$843$1@nnrp1.deja.com>
Hi !
I want to read a file, modify it's content and then write it back to
disc. While this, other accesses should be locked. The problem:
flock can only be used for open files. So when using the following code,
there is a gap, where other processes can access the file.
open FILE for reading
flock
read
do something with it
close
<- HERE SOME OTHER PROCESS COULD ACCESS THE FILE
open FILE for writing
flock
write
close
Any better ideas ?
Regards
Martin
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Sat, 15 Jul 2000 15:09:50 GMT
From: Steve Linberg <slinberg@silicongoblin.com>
Subject: Re: flock nonsense ?
Message-Id: <slinberg-7DC791.11095315072000@news.ne.mediaone.net>
In article <8kpref$843$1@nnrp1.deja.com>, martin@radiok2r.de wrote:
> Hi !
>
> I want to read a file, modify it's content and then write it back to
> disc. While this, other accesses should be locked. The problem:
>
> flock can only be used for open files. So when using the following code,
> there is a gap, where other processes can access the file.
>
> open FILE for reading
> flock
> read
> do something with it
> close
> <- HERE SOME OTHER PROCESS COULD ACCESS THE FILE
> open FILE for writing
> flock
> write
> close
Sure, other people could write to the file in the gap between a close
and open. Why shouldn't they? By closing the file, you're saying
you're done with it.
> Any better ideas ?
Yes: don't release the lock until you're done with the file. If you
need to read AND write from it, then open it for reading and writing.
See the open documentation.
--
Steve Linberg
Chief Goblin
Silicon Goblin Technologies
http://silicongoblin.com
------------------------------
Date: Sat, 15 Jul 2000 15:18:42 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: flock nonsense ?
Message-Id: <39708113.3D63EFCA@rochester.rr.com>
martin@radiok2r.de wrote:
...
> I want to read a file, modify it's content and then write it back to
> disc. While this, other accesses should be locked. The problem:
>
> flock can only be used for open files. So when using the following code,
> there is a gap, where other processes can access the file.
>
> open FILE for reading
> flock
> read
> do something with it
> close
> <- HERE SOME OTHER PROCESS COULD ACCESS THE FILE
> open FILE for writing
> flock
> write
> close
>
> Any better ideas ?
perldoc -q lock
perldoc perlopentut
perldoc -f flock
have lots of better ideas. Also note that flock might not work on
brain-life impaired OS's (including ones that start with Win9). It may
not work well over a network even for some non-brain-life-impaired
OS's. In case you don't grok it, the basic better idea is to use a
separate empty file opened for write (because the flock emulation on
some systems requires that) for locking purposes. When you get the lock
on that, do whatever operations on your real file or files you wish,
then unlock or close the lock file. The lock file servers no purpose
other than managing the lock. Note that locks are advisory only -- the
locks they establish are with cooperating processes only. That means it
only locks out other processes that are attempting to obtain a lock, not
other processes that are attempting to do I/O. Beware, and read your
OS's (and Perl's) documentation on file locking carefully. For
potentially better locking (that might even work on a network), check
your OS's implementation of fcntl, if any.
...
> Martin
...
--
Bob Walton
------------------------------
Date: Sat, 15 Jul 2000 18:02:53 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: flock nonsense ?
Message-Id: <Pine.GHP.4.21.0007151742230.7861-100000@hpplus03.cern.ch>
On Sat, 15 Jul 2000, Bob Walton wrote:
[...]
> It may
> not work well over a network even for some non-brain-life-impaired
> OS's. In case you don't grok it, the basic better idea is to use a
> separate empty file opened for write (because the flock emulation on
> some systems requires that) for locking purposes.
You're discussing semaphore files, a topic that recently came under
the microscope on this group. It does indeed seem to offer some
benefits, but let's not exaggerate them.
If you can't successfully lock files over NFS, then trying to lock the
NFS files against access from multiple nodes by using a semaphore file
(inevitably also over NFS) doesn't seem to offer any obvious benefits.
Unless of course you have a better-supported filesystem than NFS
(AFS?) for your semaphores than you have for your data - but why would
anyone do that???
> on that, do whatever operations on your real file or files you wish,
> then unlock or close the lock file. The lock file servers no purpose
> other than managing the lock. Note that locks are advisory only -- the
> locks they establish are with cooperating processes only. That means it
> only locks out other processes that are attempting to obtain a lock, not
> other processes that are attempting to do I/O.
With respect, my counsel would be that you should be referring the
questioner to the carefully considered documentation, rather than
trying to compose an independent tutorial (complete with potential
misunderstandings) on the hoof. Which then only rates to produce
another long thread generating more heat than light. If the
documentation is wrong, let's get it fixed. If it isn't, then let's
stop trying to rewrite it. IMHO, anyway.
> Beware, and read your
> OS's (and Perl's) documentation on file locking carefully. For
> potentially better locking (that might even work on a network),
> check your OS's implementation of fcntl, if any.
Surely the whole point of using Perl is to insulate yourself from the
details of this or that OS? If the perl porters knew that your OS
called for the use of fnctl, surely they would have used it? How much
more likely is it that the inexperienced Perl programmer (all the
indications are that this questioner was inexperienced!) will know
better about flocking than the Perl porters? Every time - yes,
_every_ time, I have analysed somebody's do-it-yourself locking
scheme, it has been broken. Admittedly I haven't hammered Perl's
locking schemes nearly as hard as some contributors here, but I've
never experienced a problem with it, when I was following what the
documentation told me.
all the best
--
"Mir ist es ein Rätsel wie man mit minimalem Verstand so einen
Unfug fabrizieren kann." - Adrian Knoth
------------------------------
Date: Sat, 15 Jul 2000 11:46:56 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: flock nonsense ?
Message-Id: <slrn8n11rg.h2u.tadmc@magna.metronet.com>
On Sat, 15 Jul 2000 14:11:36 GMT, martin@radiok2r.de <martin@radiok2r.de> wrote:
>I want to read a file, modify it's content and then write it back to
>disc.
Perl FAQ, part 5:
"How do I change one line in a file/
delete a line in a file/
insert a line in the middle of a file/
append to the beginning of a file?"
>While this, other accesses should be locked. The problem:
perldoc -q "\block"
>flock can only be used for open files. So when using the following code,
>there is a gap, where other processes can access the file.
>
>open FILE for reading
If you open it for reading AND writing, then you won't need
to close() it.
>flock
>read
>do something with it
>close
><- HERE SOME OTHER PROCESS COULD ACCESS THE FILE
So don't close (give up the lock) then.
>open FILE for writing
>Any better ideas ?
One of those FAQs does what you describe.
(and again near the end of "perldoc perlopentut")
Why can't you just do it that way?
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sat, 15 Jul 2000 15:10:33 +0200
From: "Carel" <cmulder@casema.net>
Subject: help with FlatText DB Editor
Message-Id: <397062a2$0$19235@reader2>
I have a FlatText ASCII DataBase that is used by a searchengine.
The database looks like this:
title | description | keywords,keyword,keywords | URL | date | size
title | description | keywords,keyword,keywords | URL | date | size
title | description | keywords,keyword,keywords | URL | date | size
title | description | keywords,keyword,keywords | URL | date | size
title | description | keywords,keyword,keywords | URL | date | size
I want to be able to display all the entries is the database in a text box
or something
and the program must be able to generate new ones with the information that
a user gives with a HTML form (*HTML form must be inside the perl script)
Can somebody give me url's / example code how this is done?
Eric
------------------------------
Date: Sat, 15 Jul 2000 09:36:04 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: help with FlatText DB Editor
Message-Id: <slrn8n0q64.gs6.tadmc@magna.metronet.com>
On Sat, 15 Jul 2000 15:10:33 +0200, Carel <cmulder@casema.net> wrote:
>I have a FlatText ASCII DataBase that is used by a searchengine.
>
>The database looks like this:
>
>title | description | keywords,keyword,keywords | URL | date | size
>title | description | keywords,keyword,keywords | URL | date | size
>title | description | keywords,keyword,keywords | URL | date | size
>title | description | keywords,keyword,keywords | URL | date | size
>title | description | keywords,keyword,keywords | URL | date | size
>
>I want to be able to display all the entries is the database in a text box
>or something
In answer to the Perl part of your question, type:
perldoc -f split
(be sure to escape any regex metacharacters that you want taken literally)
>and the program must be able to generate new ones with the information that
>a user gives with a HTML form (*HTML form must be inside the perl script)
Application-specific questions should be asked in a newsgroup
about that application, not in the newsgroup for the general
purpose programming language that you have chosen.
"forms" and HTML are on-topic in:
comp.infosystems.www.authoring.cgi
comp.infosystems.www.authoring.html
>Can somebody give me url's / example code how this is done?
There is some sample code in the standard Perl docs that are
already on your hard drive.
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 15 Jul 2000 16:40:46 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: local and use strict
Message-Id: <8kq46e$1i3$2@slb2.atl.mindspring.net>
Brendon Caligari (bcaligari@shipreg.com) wrote:
: "jason" <elephant@squirrelgroup.com> wrote in message
: news:MPG.13da5ed557c176009896b9@news...
: > frowned upon by whom ? .. breaking out of a loop is a well tested and
: > supported language feature than lends itself to good design
:
: I'm just intrdocuing myself to perl. Many perl concepts are 'NO NO NO' in
: other 'stricter' languages. Try 'breaking' out of two nested loops in C.
The problem is that C doesn't offer an inherently disciplined method of
breaking out of loops; you have to hack it with a goto, which can be used
either safely or unsafely (e.g. it can be used to jump into the middle of
a loop). Perl offers a disciplined alternative which leads to more
understandable and maintainable code than having to do bookkeeping in the
middle of an inner loop in order to handle a possible exit.
------------------------------
Date: Sat, 15 Jul 2000 15:46:06 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Locking a file
Message-Id: <Pine.GHP.4.21.0007151542440.7861-100000@hpplus03.cern.ch>
On Sat, 15 Jul 2000 martin@radiok2r.de wrote:
> What's the best way to lock/unlock a file while one user is working with
> ist ?
What's the best way to say "use the available documentation
resources"?
perldoc -q lock; perldoc -f flock; perldoc perlopentut
> I could use flock(), but if the user aborts or the connections
> breaks down, the file would be locked forever...
What leads you to believe that?
> P.S.: Please mail your answers, too, to martin@radiok2r.de Thanx.
Post to usenet, read answers on usenet. Thanks.
------------------------------
Date: Sat, 15 Jul 2000 16:08:42 +0200
From: Alex Rhomberg <rhomberg@ife.ee.ethz.ch>
Subject: Re: modify source file
Message-Id: <3970706A.B3BBBDC8@ife.ee.ethz.ch>
JMarsan wrote:
>
> Hi,
>
> I would like to know if Perl allows to locate a word in a text file and
> replace this word by another directly in the text file without having
> to create a new file or overwrite the initial file.
Let me summarise the requirements:
- A word must be replaced.
- No new file must be created
- The original file is not to be changed (overwritten)
Perl can do that.
Find the file you do want to overwrite, read the original, change the
text, write it out to the other file.
- Alex
------------------------------
Date: Sat, 15 Jul 2000 18:56:17 +0100
From: "Cal Henderson" <cal@iamcal.com>
Subject: Re: Perl can't add !
Message-Id: <WA1c5.548$Yp.16389@news6-win.server.ntlworld.com>
"Stuart Horner" <stuart@unidev.com> wrote in message
news:NUVb5.16320$EQ3.572715@news-east.usenetserver.com...
: I'm having a Perl adding error!
:
[snip]
: "873.25" + "24.95" = "898.200000000001"
: "898.200000000001" + "24.95" = "923.150000000001"
[snip]
: What is going on with this?? I'm just adding two numbers together, from a
: hash of a hash!
[snip]
perldoc perlfaq4
first question
--
Cal Henderson
sub a{my$a=reverse shift;$a=~y/b-z/a-y/;unshift@a,$a;}sub b{$c.=reverse
shift; while(length($c)>=$b[0]){a(substr($c,0,$b[0]));$c=substr($c,$b[0]);
shift@b;}}@b=(6,3,5,4,10,6,4,4,2,1);$a="l?jouipv"."ezvmxpbuxih";$a.=
",jofoqqibmzamsfsfxfjtuiIg";while($a ne ""){b(substr($a,0,2));$a=
substr($a,2);}print join(" ",@a);
------------------------------
Date: Sat, 15 Jul 2000 09:27:01 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Perl Expert? I need help!
Message-Id: <slrn8n0pl5.gqo.tadmc@magna.metronet.com>
[ Please put your comments *following* the quoted text that you
are commenting on.
Please do not quote an _entire_ article. Quote just enough to
establish the context for your comments that follow.
Please do not quote .sigs
Please visit: news.announce.newusers
Thank you.
]
On Sat, 15 Jul 2000 00:15:02 -0500, Alejandro Kurczyn <akurczyn@usa.net> wrote:
>Assuming the regexp works, what is the difference between it and:
>
>$a =~ s/\s+//g;
>$a=substr($a,0,8);
That looks just like the code I posted in a different subthread
(except you've made it harder to read).
If it is, then:
If you have a question about my code, followup to the article
where I posted the code.
Please don't break stuff by copying it from one subthread
to another.
There should be an entry in the References: header for articles
that you are referring to.
>Is it better to use regexps if there is already a function to do it?
We cannot answer unless "better" is defined.
What is "better" depends on what you want to optimize.
Speed?
Size of source code?
Size of executable?
Memory usage?
Disk usage?
Development time?
Maintenance time?
For code that I post, you can nearly always assume the last one there.
I am a (plodding) Software Engineer rather than a (clever) Hacker.
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sat, 15 Jul 2000 17:55:41 GMT
From: "jraff" <jraff@home.com>
Subject: Re: PERL IDES
Message-Id: <xA1c5.67171$lU5.454261@news1.rdc1.nj.home.com>
This IDE is free, no syntax-highlighting though.
Programmer's File Editor
http://www.lancs.ac.uk/people/cpaap/pfe/
This one supports syntax-highlighting.
1st Page 2000 v2.0 Final
http://www.evrsoft.com/download/
-----------------------------------------------
"Robin Bank" <rbank@csf.edu> wrote in message
news:8knutk$116q$1@reader.nmix.net...
> Anyone know any good PERL IDEs for Win98, I'm sick of notepad, and I need
to
> be able to rapidly develop perl.
>
> Thanks,
> Robin
>
>
------------------------------
Date: Sat, 15 Jul 2000 18:07:45 +0000
From: rhys <rhys.tucker@dtn.ntl.com>
Subject: Please criticise this text extraction script
Message-Id: <3970A871.4ED80C5E@dtn.ntl.com>
I would be grateful for suggestions on how I could have done this better
(although I am pleased that I finally got it working at all).
The objective is to extract email addresses from html pages - I have
already used it to email British members of parliament!.
I tried to use grep without spliting the HTML string but did not
succeed. Is it necessary to split the HTML string into smaller discrete
scalars?
Also I am not pleased that there are so many embedded loops.
Thanks for your suggestions.
rhys
#!/usr/bin/perl -w
# Extracts email addresses embedded in (especially html) text
# usage - $0 inputfilename outputfilename
$infile = shift;
open(INFILE,"<$infile") or die "Unable to open \$infile $infile :
$!\n";
@lines = <INFILE>;
close (INFILE);
foreach $line(@lines)
{
@split = split(/(\"|:|\<|\>)/,$line);
$prev_match = "";
foreach(@split)
{
if (/(\w+\.)*\w+@\w+(\.\w+)*/)
# if matches email address ~ need to not create duplicate #
array elements
{
if ($_ ne $prev_match)
{
push @emails, $_;
$prev_match = $_;
}
}
}
}
$outfile = shift;
open(OUTFILE,">$outfile") or die "Unable to open \$outfile $outfile :
$!\n";
foreach $email(@emails)
{
print OUTFILE "$email\n"; # use join?
}
close OUTFILE;
------------------------------
Date: Sat, 15 Jul 2000 17:55:25 GMT
From: "Coy" <coy@coystoys.com>
Subject: Simple IP/Domain validation????
Message-Id: <hA1c5.3148$Mt.14049@nnrp1.ptd.net>
Hi Ho..
I have a need to use a small generic
perl script to check for IP or DomainName
validation before processing the rest of the script.
basically, something simple as :
./netcheck <domain.com> || <ip.addr>
Output should be basically simple:
NO or YES the domain/address is valid.
This is on a remote server, that i do not have admin
rights to. So this has to be raw barebones perl.
I have no idea on what perl mods are available.
I have thought of gethostbyname(); or gethostbyaddr();
but haven't been able to get something to work.
any ideas on how this could be made more simply ?
TIA
-Coy
------------------------------
Date: Sat, 15 Jul 2000 16:14:19 +0200
From: Alex Rhomberg <rhomberg@ife.ee.ethz.ch>
Subject: Re: Time in mili-seconds
Message-Id: <397071BB.B6D17382@ife.ee.ethz.ch>
[posted and mailed]
martho@my-deja.com wrote:
> How can I get a timestamp in miliseconds ? "time" returns only seconds.
perldoc -q second
From perlfaq8: How can I measure time under a second?
The resolution will not be better than gettimeofday(2)
- Alex
------------------------------
Date: Sat, 15 Jul 2000 08:40:34 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Time in mili-seconds
Message-Id: <slrn8n0mu2.gm3.tadmc@magna.metronet.com>
On Sat, 15 Jul 2000 10:58:59 GMT, martho@my-deja.com <martho@my-deja.com> wrote:
>How can I get a timestamp in miliseconds ? "time" returns only seconds.
^^^^^
Errr, multiply the seconds by 1000.
Time*stamps* are recorded using seconds. You cannot get better than that.
You can, however, get _time_ in a finer resolution, but that is
in the Perl FAQ, so you have doubtless already seen that
solution.
Why won't the answer given there work for you?
perldoc -q time
"How can I measure time under a second?"
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sat, 15 Jul 2000 08:34:26 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Trying to use an array as a hash value
Message-Id: <slrn8n0mii.gm3.tadmc@magna.metronet.com>
On Sat, 15 Jul 2000 13:21:43 +0200, Bart Lateur <bart.lateur@skynet.be> wrote:
>doglovers@rocketmail.com wrote:
>
>>So if you create the reference to an array:
>>$arrayref = \(a,b,c,d), then you put the reference into the the hash:
>So, Perl does something completely different instead: it turns "\(...)"
>into a list of individual references to each item.
>p.s. it's in the docs, I'm sure. I just don't remember exactly where...
perldoc perlref
"Making References" section:
--------------------------
Taking a reference to an enumerated list is not the same
as using square brackets--instead it's the same as creating
a list of references!
@list = (\$a, \@b, \%c);
@list = \($a, @b, %c); # same thing!
--------------------------
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 15 Jul 2000 14:40:50 GMT
From: alandpage@aol.comnospam (Alan Page)
Subject: Re: Upper-to-lower case problem
Message-Id: <20000715104050.07745.00001896@ng-ch1.aol.com>
> http://www.activestate.com/ActivePerl/
>
>makes for some pretty platform independant programming (especially for
>the CGI - which generally requires very little operating system specific
>extensions or system calls)
Jason (and others),
Thanks for the tip; I'm downloading it now!
Alan
------------------------------
Date: 15 Jul 2000 14:50:34 GMT
From: alandpage@aol.comnospam (Alan Page)
Subject: Re: Upper-to-lower case problem
Message-Id: <20000715105034.07745.00001898@ng-ch1.aol.com>
Nnickee,
Thanks for the help!
>As far as testing goes, you'll need to install a web server as well if
>you want to test it in your browser (apache is a good free one, and
>they do have a port for win95), but you don't *have* to do that
How difficult is it to install? I've installed Xitami, Sambar, and Personal Web
Server before for HTML and Cold Fusion testing on my machine.
Thanks again,
Alan
------------------------------
Date: 15 Jul 2000 14:58:21 GMT
From: alandpage@aol.comnospam (Alan Page)
Subject: Re: Upper-to-lower case problem
Message-Id: <20000715105821.07745.00001900@ng-ch1.aol.com>
>Indeed . Much neater. Requires Perl5, though. The only Perl that
>matters, nowadays.
>
>p.s. Very often I have to fix broken scripts, so that they run under
>5.004. Amazingly how much that has been added in 5.005 -- and in 5.6;
>although I don't think I've yet used any new features of that.
Bart,
When you say Perl5 does that mean Perl 5.xxx or 5.005? Does 5.6 really mean
5.006? I think I have 5.004 based on my shebang of #!/usr/bin/perl54. I have a
note out to my ISP to find out what I've really got access to.
Thanks again for the info,
Alan
------------------------------
Date: Sat, 15 Jul 2000 11:25:10 -0400
From: "Benjamin Bérubé" <berube@odyssee.net>
Subject: Web site engine using Perl
Message-Id: <wm%b5.22213$NS6.336125@news.globetrotter.net>
Hi,
I'm wondering if anyone knows a web site engine written in Perl ?
Also, I'm currently working on such an engine for my web site, but i'm
writting it so that anyone could create a nice web site with full dynamic
pages.
Some features:
- every html pages are created dynamically
- support Perl code inside html pages (see this like ASP pages, only
with Perl instead of VBScript)
- support multi-languages
- built-in support for members + logins
- admin mode for managing the site
- logs keeping track of every moves inside the site
- put ads and rotate them as people visit the site
I'm considering putting out the source code on my site. Is/would anyone
interested in creating a web site using my engine ? Is there anyone out
there looking for such a engine ?
Anyone interested, write me. If I get enough responses, I will consider it
seriously.
Thanks,
Ben
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V9 Issue 3678
**************************************