[9193] in Perl-Users-Digest
Perl-Users Digest, Issue: 2812 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jun 4 22:07:43 1998
Date: Thu, 4 Jun 98 19:00:27 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Thu, 4 Jun 1998 Volume: 8 Number: 2812
Today's topics:
Re: ??change case on FIRST letter ONLY in a word?? (Matt Knecht)
Re: Altavista, infoseek, etc. <gimonca@mirage.skypoint.net>
blat error message 0312@my-dejanews.com
Re: blat error message <rootbeer@teleport.com>
Blat problem 0312@my-dejanews.com
Re: decimal arithmetic <rootbeer@teleport.com>
Re: decimal arithmetic (Larry Rosler)
Re: decimal arithmetic (Mike Stok)
Re: decimal arithmetic (Larry Rosler)
Re: decimal arithmetic <tchrist@mox.perl.com>
Re: Determining JPEG and GIF dimension sizes in PERL (Mike Stok)
Re: Determining JPEG and GIF dimension sizes in PERL (Martien Verbruggen)
Re: Generate unique id (Martien Verbruggen)
Re: Help!!!! "ccperl -e" behaves differently under UNIX (Larry Rosler)
Re: Help!!!! "ccperl -e" behaves differently under UNIX (Mike Stok)
Re: How can I write to specific line ? (Martien Verbruggen)
Re: how to pass user name and password to unix? <rootbeer@teleport.com>
Is it possible to post/read newsgroup articles using PE <arcadiev@usa.net>
Re: Is PERL case sensitive? (Martien Verbruggen)
Re: newbie: trying to remove unwanted data from an arra (Larry Rosler)
Re: novice question: improving this code? (Mark-Jason Dominus)
Problems with FORK/Sun-Solaris <diran@NOSPAMearthlink.net>
Re: regexp: Validating UPC Code <rootbeer@teleport.com>
Re: regexp: Validating UPC Code (Ilya Zakharevich)
regexp: Validating UPC Codes ionFreeman@my-dejanews.com
Re: Search Engine (Michael J Gebis)
Spider programms in PERL <arcadiev@usa.net>
Re: Why is there no "in" operator in Perl? <ajohnson@gpu.srv.ualberta.ca>
Yes, it is (Marc Day)
Re: Yes, it is (Martien Verbruggen)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 05 Jun 1998 00:22:25 GMT
From: hex@voicenet.com (Matt Knecht)
Subject: Re: ??change case on FIRST letter ONLY in a word??
Message-Id: <5TGd1.354$14.2704173@news2.voicenet.com>
Tom Christiansen <tchrist@mox.perl.com> wrote:
>Huh? Have you forgotten your vi this quickly?
I forgot vi when I discovered vim. :)
>:$str =~ s/\b(\w)/uc($1)/ge;
> $str =~ s/\b(\w)/\u$1/ge;
TMTOWTDI! But, you're correct. Throwing both methods through Benchmark
shows that the \u is _slightly_ faster (And in the FAQ, too).
<pedantic mode=moderate>
In response to the people who suggested using ucfirst, ucfirst doesn't
work when there is leading whitespace. The original author wanted the
first _word_ in a string to be uppercased (Just remove the g modifier
from the above regex's to get that).
</pedant>
--
Matt Knecht - <hex@voicenet.com>
"496620796F752063616E207265616420746869732C20796F7520686176652066
617220746F6F206D7563682074696D65206F6E20796F75722068616E6473210F"
------------------------------
Date: 5 Jun 1998 00:21:22 GMT
From: Charles Gimon <gimonca@mirage.skypoint.net>
Subject: Re: Altavista, infoseek, etc.
Message-Id: <6l7dm2$68g$1@shadow.skypoint.net>
arnoud de jong <arnoud@notenbomer.nl> wrote:
: Does anyone know how I can create a simple search engine. So I can create a
: list of URL's and create a searchable index.
O'Reilly has a book out titled "Web Client Programming with Perl" by
Clinton Wong. Talks about the LWP module, robot exclusion standard,
http, lots of stuff. Buckets of fun!
--
Wild new Ubik salad dressing, not | gimonca@skypoint.com
Italian, not French, but an entirely | Minneapolis MN USA
new and different taste treat that's | http://www.skypoint.com/~gimonca
waking up the world! | A lean, mean meme machine.
------------------------------
Date: Fri, 05 Jun 1998 00:04:25 GMT
From: 0312@my-dejanews.com
Subject: blat error message
Message-Id: <6l7cm8$r6g$1@nnrp1.dejanews.com>
Hi seniors:
I have running iis4.0. and try to make blat work under NT, and it does
work well before, However it seems to be some problems now that blat refused
to send mail again, the error message is " the smtp server does not like
anyid@anydomain.com, have you set 'to:' field properly"
I have totally lost now since i have tries to fix it myself several
times and every try was ended in vain.
Could anybodygive me some clue?
thanks
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/ Now offering spam-free web-based newsreading
------------------------------
Date: Fri, 05 Jun 1998 00:36:33 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: blat error message
Message-Id: <Pine.GSO.3.96.980604173612.29617c-100000@user2.teleport.com>
On Fri, 5 Jun 1998 0312@my-dejanews.com wrote:
> I have running iis4.0. and try to make blat work under NT, and it does
> work well before, However it seems to be some problems now that blat refused
> to send mail again, the error message is " the smtp server does not like
> anyid@anydomain.com, have you set 'to:' field properly"
If you're using the proper commands to run another program from perl, but
the other program doesn't cooperate, then it's the other program's fault.
If you're not using the proper commands, then it's your fault. If you
aren't sure about the proper commands, you should read the program's
documentation. If you've read it and you're still not sure, you should ask
in a newsgroup about the program.
Hope this helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Fri, 05 Jun 1998 00:01:26 GMT
From: 0312@my-dejanews.com
Subject: Blat problem
Message-Id: <6l7cgm$r5h$1@nnrp1.dejanews.com>
Hi seniors:
I have running iis4.0. and try to make blat work under NT, and it does
work well before, However it seems to be some problems now that blat refused
to send mail again, the error message is " the smtp server does not like
anyid@anydomain.com, have you set 'to:' field properly"
I have totally lost now since i have tries to fix it myself several
times and every try was ended in vain.
Could anybodygive me some clue?
thanks
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/ Now offering spam-free web-based newsreading
------------------------------
Date: Thu, 04 Jun 1998 23:14:44 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: decimal arithmetic
Message-Id: <Pine.GSO.3.96.980604161407.29617S-100000@user2.teleport.com>
On Thu, 4 Jun 1998, Bob Trieger wrote:
> dgwilson@gte.net (Douglas Wilson) wrote:
> -> if (($val1+$val2)==$val3) {
>
> Try evaluating $val1 + $val2 in your if statement and it should work.
> IE: if (eval($val1 + $val2) == $val3) { ... }
No, eval does nothing to affect this. (Why would you think it would?)
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Thu, 4 Jun 1998 17:17:31 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: decimal arithmetic
Message-Id: <MPG.fe0d8f9b9981b7d9896a4@hplntx.hpl.hp.com>
[This followup was posted to comp.lang.perl.misc and a copy was sent to
the cited author.]
In article <6l79ii$dkt$9@csnews.cs.colorado.edu>, tchrist@mox.perl.com
says...
> [courtesy cc of this posting sent to cited author via email]
>
> In comp.lang.perl.misc,
> lr@hpl.hp.com (Larry Rosler) writes:
> :Testing for equality of floating-point numbers is like asking if the
> :number of grains of sand in one pile is equal to the number of grains in
> :a second pile. You'll never know.
>
> I've always been partial to:
>
> # equal(NUM1, NUM2, ACCURACY): returns whether NUM1 and NUM2
> # are equal to ACCURACY number of decimal places
> sub equal {
> my ($A, $B, $dp) = @_;
> return sprintf("%.${dp}f", $A) eq sprintf("%.${dp}f", $A);
> }
>
> # free samples:
>
> if ( equal($a, $b, $accuracy) ) {
> # $a and $b are equal to $accuracy decimal places
> } else {
> # they're not equal
> }
>
> But that's just me. But maybe I'm missing something.
Decimal places of accuracy are not grains of sand :-).
I commented on this submission in my answer to Bob Trieger, including
noting the typo. My method:
if (abs($a - $b) < $EPSILON) { ... they're equal ...
is surely faster and perhaps has more generality. But TMOWTDI. We (and
the FAQ) are all in fundamental agreement. Hallelujah!
How can one explain a day like today, when the New Moon isn't until June
9?
--
Larry Rosler
Hewlett-Packard Laboratories
lr@hpl.hp.com
------------------------------
Date: 5 Jun 1998 01:25:34 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: decimal arithmetic
Message-Id: <6l7hee$il4@news-central.tiac.net>
In article <6l71ul$is$1@gte1.gte.net>, Douglas Wilson <dgwilson@gte.net> wrote:
>#!/usr/local/bin/perl -w
>use strict;
>my $val1=119.98;
>my $val2=21.00;
>my $val3=140.98;
>if (($val1+$val2)==$val3) {
> print "Equal\n";
>} else {
> print "Not equal\n";
>}
>
>The above gives me "Not equal".
>If I change val1&val3 or val2&val3 by .01 it'll say "Equal".
>Can anyone confirm?
>
You think in decimal and computers manipulate binary representations of
numbers. Fractions which are exactly representable in one base may not be
representable in another.
perldoc perlfaq4
on recent perl installations will give you a whole slew of information on
numbers, but in general you shhould feel uneasy whenever floating point
numbers are compared for equality:
DB<1> $val1=119.98; $val2=21.00; $sum = $val1 + $val2
DB<2> $val3=140.98
DB<3> printf "%.30f\n%.30f", $sum, $val3
140.980000000000018189894035458565
140.979999999999989768184605054557
so they're close but not equal. You might want to compare the absolute
value of their difference with some small value (1e-15 maybe) or if you're
using reasonabley small values work in integers and insert the point for
display.
If speed isn't a concern then the Math::BigFloat module might interest
you:
DB<1> use Math::BigFloat
DB<2> $val1 = Math::BigFloat->new ('119.98')
DB<3> $val2 = Math::BigFloat->new ('21.00')
DB<4> $sum = $val1 + $val2
DB<5> $val3 = Math::BigFloat->new ('140.98')
DB<6> print "equal" if $val3->fcmp ($sum) == 0
equal
DB<7> print "equal" if $val3->fcmp ($val1 + $val2) == 0
equal
Hope this helps,
Mike
--
mike@stok.co.uk | The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/ | PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/ | 65 F3 3F 1D 27 22 B7 41
stok@colltech.com | Collective Technologies (work)
------------------------------
Date: Thu, 4 Jun 1998 17:42:22 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: decimal arithmetic
Message-Id: <MPG.fe0dec547df19519896a5@hplntx.hpl.hp.com>
[This followup was posted to comp.lang.perl.misc and a copy was sent to
the cited author.]
In article <Pine.GSO.3.96.980604161407.29617S-100000@user2.teleport.com>,
rootbeer@teleport.com says...
> On Thu, 4 Jun 1998, Bob Trieger wrote:
>
> > dgwilson@gte.net (Douglas Wilson) wrote:
> > -> if (($val1+$val2)==$val3) {
> >
> > Try evaluating $val1 + $val2 in your if statement and it should work.
> > IE: if (eval($val1 + $val2) == $val3) { ... }
>
> No, eval does nothing to affect this. (Why would you think it would?)
>
> --
> Tom Phoenix Perl Training and Hacking Esperanto
> Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
my $val1 = 119.98;
my $val2 = 21.00;
my $val3 = 139.98;
printf "%.20f\n", $val1 + $val2; # 139.98000000000002000000
printf "%.20f\n", eval($val1 + $val2); # 139.97999999999999000000
printf "%.20f\n", $val3; # 139.97999999999999000000
Why does it??
--
Larry Rosler
Hewlett-Packard Laboratories
lr@hpl.hp.com
------------------------------
Date: 5 Jun 1998 01:32:48 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: decimal arithmetic
Message-Id: <6l7hs0$rhh$1@csnews.cs.colorado.edu>
Here's a correction, and a demo.
sub equal {
my ($A, $B, $dp) = @_;
my ($traceA, $traceB);
$traceA= sprintf("%.${dp}g", $A);
$traceB= sprintf("%.${dp}g", $B);
return $traceA eq $traceB;
}
$a='0.000000000003145679';
$b='0.000000000003145680';
for $i ( 1..10 ) {
printf "$a and $b are%s equal to %d places.\n",
equal($a, $b, $i) ? "" : " not", $i;
}
0.000000000003145679 and 0.000000000003145680 are equal to 1 places.
0.000000000003145679 and 0.000000000003145680 are equal to 2 places.
0.000000000003145679 and 0.000000000003145680 are equal to 3 places.
0.000000000003145679 and 0.000000000003145680 are equal to 4 places.
0.000000000003145679 and 0.000000000003145680 are equal to 5 places.
0.000000000003145679 and 0.000000000003145680 are equal to 6 places.
0.000000000003145679 and 0.000000000003145680 are not equal to 7 places.
0.000000000003145679 and 0.000000000003145680 are not equal to 8 places.
0.000000000003145679 and 0.000000000003145680 are not equal to 9 places.
0.000000000003145679 and 0.000000000003145680 are not equal to 10 places.
--tom
--
I already have too much problem with people thinking the efficiency of
a perl construct is related to its length. On the other hand, I'm
perfectly capable of changing my mind next week... :-) --lwall
------------------------------
Date: 5 Jun 1998 01:33:10 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Determining JPEG and GIF dimension sizes in PERL
Message-Id: <6l7hsm$k5j@news-central.tiac.net>
In article <6l78l1$es4@news-central.tiac.net>,
The Needham's <needcrew@tiac.net> wrote:
>Hi,
>
>I am trying to figure out if there is a way to determine the height and
>width of a given image from within perl. I will be using only JPG and GIF
>images if this helps.
If you're using perl 5.xxx then the first thing to do is go and look at
CPAN (the comprehensive perl archive network) and see if there are any
likely modules in the modules index. One place to find the module index
is at
http://www.perl.com/CPAN-local//modules/01modules.index.html
and looking through the list there's
Image RJRAY Image-Size-2.6.tar.gz 23k 27 Jan 1998
If you explore CPAN you'll find that the modules all have their README
files broken out so you can see if a likely module will fill your needs:
http://www.perl.com/CPAN-local//authors/Randy_J_Ray/Image-Size-2.6.readme
starts out
mage::Size - Determine the size of images in several common formats
Version: 2.6 (See CHANGE HISTORY below)
WHAT IS IT
Image::Size is a library based on the image-sizing code in the
wwwimagesize script, a tool that analyzes HTML files and adds HEIGHT and
WIDTH tags to IMG directives. Image::Size has generalized that code to
return a raw (X, Y) pair, and included wrappers to pre-format that output
into either HTML or a set of attribute pairs suitable for the CGI.pm
library by Lincoln Stein. Currently, Image::Size can size images in XPM,
XBM, GIF, JPEG, PNG, TIFF and the PPM family of formats (PPM/PGM/PBM).
Hope this helps,
Mike
--
mike@stok.co.uk | The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/ | PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/ | 65 F3 3F 1D 27 22 B7 41
stok@colltech.com | Collective Technologies (work)
------------------------------
Date: 5 Jun 1998 01:19:46 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Determining JPEG and GIF dimension sizes in PERL
Message-Id: <6l7h3i$ms8$2@comdyn.comdyn.com.au>
In article <6l78l1$es4@news-central.tiac.net>,
"The Needham's" <needcrew@tiac.net> writes:
> I am trying to figure out if there is a way to determine the height and
> width of a given image from within perl. I will be using only JPG and GIF
> images if this helps.
Image::Size. Get it from CPAN (http:/www.perl.com/CPAN/)
# perl -MCPAN -e shell
cpan> i Image::Size
Module id = Image::Size
DESCRIPTION Measure size of images in common formats
CPAN_USERID RJRAY (Randy J Ray)
CPAN_VERSION 2.6
CPAN_FILE RJRAY/Image-Size-2.6.tar.gz
DSLI_STATUS Rdpf (released,developer,perl,functions)
INST_FILE (not installed)
NExt time you need something, try CPAN first, then ask.
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | The world is complex; sendmail.cf
Commercial Dynamics Pty. Ltd. | reflects this.
NSW, Australia |
------------------------------
Date: 5 Jun 1998 01:29:20 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Generate unique id
Message-Id: <6l7hlg$ms8$4@comdyn.comdyn.com.au>
In article <35771411.A9B3D644@yahoo.comremove>,
Stylin <stylinsty@yahoo.comREMOVE> writes:
> Can anyone point me to the algorithm for creating a unique id?
THE algorithm? There are many.
One simple and very dumb one: (1)
create a key
check if the key already exists
repeat until it doesn't.
Another one, which is lots better: (2)
All keys are monotonically increasing integers
Start with key 1
For every new process, create a key which is 1 higher than the last one
> Something based on milliseconds since the beginning of mankind would be
> cool.
That is not unique. Two programs might run at exactly the same time,
no matter what time resolution you use. A combination of time (seconds
would most likely be enough) and process id might be a good one (3). Of
course, if your system is really really fast, and rotates through all
available process ids within one second, you're out of luck.
Practically that won't happen for a few years.
It's hard to tell you which one is best without knowing what sort of
application you're writing, and what sort of shared data multiple
instances of this application have. Probably (3) will do well for
processes that have no shared data, (2) is much better if your
processes do share data.
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | Very funny Scotty, now beam down my
Commercial Dynamics Pty. Ltd. | clothes.
NSW, Australia |
------------------------------
Date: Thu, 4 Jun 1998 16:56:20 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Help!!!! "ccperl -e" behaves differently under UNIX and Windows 95
Message-Id: <MPG.fe0d4019c1df7ba9896a3@hplntx.hpl.hp.com>
In article <87d8cost2i.fsf@bj2-64.rh.uchicago.edu>, p-fein@uchicago.edu
says...
> Ping Cui <ping.cui@daytonoh.ncr.com> writes:
>
> > Hello everyone:
> >
> > Could you please help me explain why perl behaves differently under
> > following cases?
>
> It's not perl, it's your shell (or whatever that thing in windows is
> called). Anyway, Unix uses ticks (') to quote quotes ("). Apparently
> Win 95 can use quotes (") to do this, but bugs out on ticks ('). It's
> analgous to using different slashes for directories
Twice in one day!!!
This response is not Perl.
'That thing in windows' is called the command interpreter, COMMAND.EXE or
CMD.EXE depending on the flavor. It is truly a heap of Micro$..t ! Lots
of good shells ported to WinDOG are available, some free and some for $$.
But people will use the tools they have at hand. How much can you blame
them?
--
Larry Rosler
Hewlett-Packard Laboratories
lr@hpl.hp.com
------------------------------
Date: 5 Jun 1998 01:39:29 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Help!!!! "ccperl -e" behaves differently under UNIX and Windows 95
Message-Id: <6l7i8h$k5j@news-central.tiac.net>
In article <3577172F.D909B203@daytonoh.ncr.com>,
Ping Cui <ping.cui@daytonoh.ncr.com> wrote:
>Hello everyone:
>
> Could you please help me explain why perl behaves differently under
>following cases?
>
>Case 1:
>
>perl -e '$a = "111111";print $a'
>
>(working under UNIX,
>not working under windows 95 and getting an error
>"Can't find string terminator "'" anywhere before EOF at -e line 1." )
The windows command line interpreter (or is it the DOS interpreter) can't
handle single quotes to quote arguments.
>case 2:
>
>perl -e "$a = '111111';print $a"
>
>(not working under UNIX and getting
>syntax error at -e line 1, near "="
>Execution of -e aborted due to compilation errors. It works under
>windows 95)
In this case the double quotes work for the windows command interpreter to
quote the statements, but a typical unix shell will try and interpolate $a
in the double quotes before passing the result to perl. Most likely $a
turns into an empty string.
There are a number of "better shells" for windows, one place to look might
be http://www.gci-net.com/~users/c/cteeple/windowsntconsole.htp
Hope this helps,
Mike
--
mike@stok.co.uk | The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/ | PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/ | 65 F3 3F 1D 27 22 B7 41
stok@colltech.com | Collective Technologies (work)
------------------------------
Date: 5 Jun 1998 01:14:00 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: How can I write to specific line ?
Message-Id: <6l7goo$ms8$1@comdyn.comdyn.com.au>
In article <6l5q1v$h5m$1@news.huji.ac.il>,
evgenya@amos-01.cs.huji.ac.il (Evgenya Borisenko) writes:
> Hi,
>
> I'd like to know is there a possibility to write (change) to a specific
> line in a file ?
This is answered in the FAQ.
# perldoc perlfaq5
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?
Please read. And while you're at it, browse some of the other
questions and documentation.
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | Little girls, like butterflies, need no
Commercial Dynamics Pty. Ltd. | excuse - Lazarus Long
NSW, Australia |
------------------------------
Date: Thu, 04 Jun 1998 23:11:01 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: how to pass user name and password to unix?
Message-Id: <Pine.GSO.3.96.980604160717.29617Q-100000@user2.teleport.com>
On Thu, 4 Jun 1998, Simon wrote:
> is there a PERL command to access files in a protected UNIX directory by
> passing the login name and password?
You could write one, if there isn't such a program.
> or maybe sending them with a HTTP command with parameters.
> something like:
>
> http://www.somedomain.com/protected/myfile.zip?name=john+password=xxxx
Don't send a password unencrypted over HTTP without first posting the
password to Usenet. :-)
If you wish to write a program which would be able to access any user's
files, it would (almost certainly) need to be set-id to root. See the
perlsec manpage for more information. Also, since there are (many!)
potential security holes involved with this, see the WWW Security FAQ.
Hope this helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Fri, 05 Jun 1998 02:47:06 GMT
From: "Leonid A.Arcadiev" <arcadiev@usa.net>
Subject: Is it possible to post/read newsgroup articles using PERL script?
Message-Id: <01bd9023$f7b08dc0$e8854018@dundas>
Can anybody advice me a PERL script which will post and read newsgroup
articles?
Please post a reply or mail it to arcadiev@usa.net
Sincerely,
Leonid A. Arcadiev
------------------------------
Date: 5 Jun 1998 01:22:28 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Is PERL case sensitive?
Message-Id: <6l7h8k$ms8$3@comdyn.comdyn.com.au>
Subject: Is PERL case sensitive?
Depends what you mean.
It is perl for the program, Perl for the language. Never PERL.
That is case sensitive. The program perl, and the language Perl are
both case sensitive as well. I don't really know about PERL.
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au |
Commercial Dynamics Pty. Ltd. | Curiouser and curiouser, said Alice.
NSW, Australia |
------------------------------
Date: Thu, 4 Jun 1998 18:18:42 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: newbie: trying to remove unwanted data from an array....
Message-Id: <MPG.fe0e74bf17959719896a6@hplntx.hpl.hp.com>
In article <MPG.fdf89a1e0df4f53989694@hplntx.hpl.hp.com>, lr@hpl.hp.com
says...
> In article <1da27zd.n0g1lx1pyg400N@slip166-72-108-222.ny.us.ibm.net>,
> kpreid@ibm.net says...
> ...
> > Larry Rosler posted a solution using grep; here's the equivalent in map:
> >
> > @output = map { /SUB-TOTAL:/ ? $_ : () } @rawoutput;
> >
> > (grep-map equivalence copied straight from page 179 of "Programming
> > Perl".)
>
> Benchmarks show 'map' as much as 40% FASTER than 'grep'; 'map' gets
> relatively faster as the output list gets smaller (fewer matches).
>
> I am astounded. YAFI -- Yet Another Failed Intuition.
I think my Benchmarks were bogus, and intuition may be right this time.
#!/usr/local/bin/perl -w
use Benchmark;
@a = (('x' x 100) x 1000, 'xxfoo' x 20);
timethese (1 << 11, {
'grep' => q{ @almost_empty = grep /foo/, @a },
'map' => q{ @almost_empty = map { /foo/ ? $_ : () } @a },
} );
__END__
Benchmark: timing 2048 iterations of grep, map...
grep: 24 secs (17.52 usr 0.09 sys = 17.61 cpu)
map: 38 secs (30.77 usr 0.14 sys = 30.91 cpu)
This is perl, version 5.004_03
I have overwritten the code I was Benchmarking yesterday, and may have
simply mislabeled the cases. I would appreciate it if someone can
confirm that this new result is correct. In which case 'grep' is still
the best way to solve this problem.
--
Larry Rosler
Hewlett-Packard Laboratories
lr@hpl.hp.com
------------------------------
Date: 4 Jun 1998 21:21:15 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: novice question: improving this code?
Message-Id: <6l7h6b$k49$1@monet.op.net>
Keywords: anharmonic regalia soiree they'd
In article <35765C75.8701EF00@nortel.co.uk>,
F.Quednau <quednauf@nortel.co.uk> wrote:
>Superb answer. Thanks for that! (Hell, you might as well publish it :)
That wouldn't be the first time that happened.
------------------------------
Date: Fri, 05 Jun 1998 01:22:25 GMT
From: "Diran A." <diran@NOSPAMearthlink.net>
Subject: Problems with FORK/Sun-Solaris
Message-Id: <357748E7.61A9@NOSPAMearthlink.net>
I've been having a problem running a FORK process on Sun/Solaris
platforms. We have a user base of about 300 people using one of our
programs with no problems, but our Sun/Solaris users are just not able
to use this process.
Is anyone aware of a problem with the FORK process on the Sun/Solaris
platform?
Here's the offending subroutine. Maybe the problem is with my code.
I'd appreciate any help I can get:
sub mailing {
$pid = fork();
print "Content-type: text/html \n\n fork failed: $!" unless defined
$pid;
if ($pid) {
#parent
## Here we print a response page. Nothing exciting.
exit(0);
}
else {
#child
close (STDOUT);
##### SEND OUT EMAILS HERE ############
#&passcheck;
######### Here is where we did the addition ###################
###############################################################
# First, tell the script where to find your email text file
open (FILE,"$closing/email.txt"); #### Full path name from root.
# Now we read in the email text
@closing = <FILE>;
# Now that's its been read, we can close the text file
close(FILE);
open (LIST,"<$memberinfo/address.txt");
if ($LOCK_EX){
flock(LIST, $LOCK_EX); #Locks the file
}
@database_array = <LIST>;
close (LIST);
foreach $lines(@database_array) {
chomp($lines);
open (MAIL, "|$mailprog -t")
|| print "Can't start mail program";
print MAIL "To: $lines\n";
print MAIL "From: $list_mail\n";
print MAIL "Subject: $INPUT{'mail_subject'}\n\n";
print MAIL "$INPUT{'message'}";
# Now we tell the script to read each line from your email text file
# and paste it into your actual outgoing email.
foreach $line(@closing) {
print MAIL "$line";
}
# All done
print MAIL"\n\n";
close (MAIL);
}
}
}
Thanks for anyone that might be able to help shed some light on this.
Diran A.
------------------------------
Date: Fri, 05 Jun 1998 00:33:44 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: regexp: Validating UPC Code
Message-Id: <Pine.GSO.3.96.980604165322.29617a-100000@user2.teleport.com>
On Thu, 4 Jun 1998 ionFreeman@my-dejanews.com wrote:
> /[067]\d{11}/
> matches a UPC code. However, that 12th digit has to equal ten less the
> ten- based modulus of thrice the sum of the odd digits plus the sum of
> the previous even digits. Is there a way I can do this with
> backreferences inside a regular expression?
Nope. Perl's patterns are smart, but they aren't that smart. They can't
match only valid UPC numbers.
No, I take that back. You _can_ match only valid UPC numbers, but doing so
takes a somewhat big pattern. To save space, I'll show you only the start
of it:
/000000000000|000000000019|000000000028|... # :-)
But what I think you really want is something like this.
print "It's valid!\n"
if /([067]\d{11})/ and &good_upc($1);
That sub shouldn't be too hard to write. Let's see...
sub good_upc {
my $upc = shift;
my $check = chop($upc);
$upc =~ s/(\d)(\d)/ ($2 + (0,3,6,9,2,5,8,1,4,7)[$1]) % 10 /ge;
$check += chop($upc) while $upc;
($check %= 10) == 0; # return value
}
I'll leave it up to you to prove whether this does or doesn't meet your
needs. And to decide whether the attempt at doing it in a clever way
makes it better or worse. :-) Hope this helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 5 Jun 1998 01:20:10 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: regexp: Validating UPC Code
Message-Id: <6l7h4a$ih1$1@mathserv.mps.ohio-state.edu>
[A complimentary Cc of this posting was sent to Tom Phoenix
<rootbeer@teleport.com>],
who wrote in article <Pine.GSO.3.96.980604165322.29617a-100000@user2.teleport.com>:
> On Thu, 4 Jun 1998 ionFreeman@my-dejanews.com wrote:
>
> > /[067]\d{11}/
>
> > matches a UPC code. However, that 12th digit has to equal ten less the
> > ten- based modulus of thrice the sum of the odd digits plus the sum of
> > the previous even digits. Is there a way I can do this with
> > backreferences inside a regular expression?
>
> Nope. Perl's patterns are smart, but they aren't that smart. They can't
> match only valid UPC numbers.
They can with recent enough Perl (5.004_55+). But this is still very
ugly, since you need some components like
(?(?{$sum == 0})
0
|
(?(?{$sum == 1})
1
|
...
)
)
Since I'm reconsidering my involvement with Perl core hacking, I do
not know when this is going to improve.
Ilya
------------------------------
Date: Fri, 05 Jun 1998 00:26:55 GMT
From: ionFreeman@my-dejanews.com
Subject: regexp: Validating UPC Codes
Message-Id: <6l7e0e$sp4$1@nnrp1.dejanews.com>
This is where I stand now as a possible solution, but typing (\d) 11 times is
extraordinarily inelegant.
ion
--
$UPC = "063255878220"; #this is a valid UPC code
if($UPC =~ /^([067])(\d)(\d)(\d)(\d)(\d)(\d)(\d)(\d)(\d)(\d)(\d)$/)
{
my $Check = 3*($1+$3+$5+$7+$9+$11); #thrice the odd digits
$Check += $2+$4+$6+$8+$10; #plus the even digits but the last
$Check = 10 - $Check%10; #ten less the ten-based modulus
unless($12 == chop($Check)){ die "$UPC has an invalid check digit";}
#last digit (0 if $Check is 10)
}
else
{
die "$UPC is not a 12-digit string starting with 0, 6, or 7";
}
print "Valid UPC\!\n";
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/ Now offering spam-free web-based newsreading
------------------------------
Date: 5 Jun 1998 00:11:14 GMT
From: gebis@albrecht.ecn.purdue.edu (Michael J Gebis)
Subject: Re: Search Engine
Message-Id: <6l7d32$r7i@mozo.cc.purdue.edu>
Tom Phoenix <rootbeer@teleport.com> writes:
}On 4 Jun 1998, Michael J Gebis wrote:
}[ somewhat edited for brevity ]
}> sowmaster@juicepigs.com (Bob Trieger) writes:
}> }"Vincent M. Probasco" <probavm@cat.com> wrote:
}> }-> I was simply looking for
}> }-> advice on which search engine
}> }-> to use for the following problem.
}> (I think)He's looking for advice, not a program handout.
}I think you're mistaken; he said elsewhere that it didn't even have to be
}written in Perl. He seems to be asking for a fast search engine, not a
}suitable algorithm.
There are two choices:
1) Vincent was confused and asked a somewhat confusing question, but
really wasn't trying to shirk.
2) Vincent was confused and asked a somewhat confusing question, and
was indeed being lazy.
There is one given:
I was confused, and prolly' should have shut up.
I'm sorry. I will therefore publically berate myself in an overly dramatic
way:
I, sirs, am worse than Hitler.
This will hopefully do three things:
1) Show I'm really sorry...after all, I compared myself to HITLER!
2) Amuse and/or annoy.
3) Bring Hitler into the thread, hopefully invoking Godwin's law and
putting an end to a thread which I find increasingly embarassing.
--
Mike Gebis gebis@ecn.purdue.edu mgebis@eternal.net
------------------------------
Date: Fri, 05 Jun 1998 02:48:52 GMT
From: "Leonid A.Arcadiev" <arcadiev@usa.net>
Subject: Spider programms in PERL
Message-Id: <01bd9024$37164270$e8854018@dundas>
Can anybody advice how to write a spider in perl, that would check on a
website and read through its contents. If the responce has been received,
everything is fine, if no responce, generate an error message.
Please post a reply or send it to arcadiev@usa.net
Many thanks in advance,
Sincerely,
L.A.Arcadiev
------------------------------
Date: Thu, 04 Jun 1998 19:21:23 -0500
From: Andrew Johnson <ajohnson@gpu.srv.ualberta.ca>
Subject: Re: Why is there no "in" operator in Perl?
Message-Id: <35773A03.37A847D1@gpu.srv.ualberta.ca>
Jim Bowlin wrote:
>
> Andrew Johnson wrote:
> >
[snip]
>
> Andrew, the test is more fair if you optimize the regular expression.
>
> use Benchmark;
> use vars qw/@a $try $num_1 $num_2 $num_3/;
> @a=qw(ab abc bc de ab);
> $try='ab';
> $count=100000;
> timethese($count,{
> '/regex/o' => '$num_1 = grep /^$try$/o, @a',
my response was directed (but not particularly well it now
seems) at the response I had followed up, which used an
example in which $try changed value each time --- so
using /o alone wouldn't have been much use--- mostly mine
was just to counter the seemingly prevelant notion that
grep always goes with a regex, which is not always the best
answer.
Of course, with that notion in mind, I neglected to take
a better look at the question and realize grep wasn't a
good answer in any case...as per other followups.
regards
andrew
------------------------------
Date: Fri, 05 Jun 1998 00:10:21 GMT
From: mnd02@keele.ac.uk (Marc Day)
Subject: Yes, it is
Message-Id: <357b374c.14080847@news.keele.ac.uk>
But then I have a lot of these messages on newgruops I help out.
------------------------------
Date: 5 Jun 1998 01:34:22 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Yes, it is
Message-Id: <6l7huu$ms8$5@comdyn.comdyn.com.au>
> Subject: Re: Yes, it is
> References: NONE
Yes, it is what???
Is this a reply to some other message?
In article <357b374c.14080847@news.keele.ac.uk>,
mnd02@keele.ac.uk (Marc Day) writes:
> But then I have a lot of these messages on newgruops I help out.
What?
Wait a second... Could I have some of those mushrooms you're eating?
Please?
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | I think I think, therefore I think I
Commercial Dynamics Pty. Ltd. | am.
NSW, Australia |
------------------------------
Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Mar 97)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V8 Issue 2812
**************************************