[23774] in Perl-Users-Digest
Perl-Users Digest, Issue: 5978 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Dec 24 14:05:41 2003
Date: Wed, 24 Dec 2003 11:05:06 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Wed, 24 Dec 2003 Volume: 10 Number: 5978
Today's topics:
Re: Accounting, Database Problem (Jay Tilton)
Re: effecient software engineering <jwillmore@remove.adelphia.net>
Re: How to write a script that takes input from the scr (Sara)
Re: How to write a script that takes input from the scr (Tad McClellan)
installing mod manually <aolblowz@yahoo.com>
Re: installing mod manually <jwillmore@remove.adelphia.net>
Re: installing mod manually <aolblowz@yahoo.com>
Re: monitor windows processes (Daniel Berger)
Re: Multiple SELECT queries <nobull@mail.com>
Re: Multiple SELECT queries <mpeppler@peppler.org>
Re: newbie: Terminating while($line=<stdin>) on Windows (John Deuf)
Re: Posting Guidelines for comp.lang.perl.misc ($Revisi (Tad McClellan)
Re: search interval (Sara)
Re: search interval <yhu@mail.nih.gov>
Slow script <yshtil@cisco.com>
Re: Slow script <uri@stemsystems.com>
Re: SOLVED:: HTML::Form->Parse (Perl) not working under (Jeffrey J. Kosowsky)
STDIN Question (Hobbit HK)
Re: STDIN Question (David Efflandt)
Re: Time out SSL request? (ko)
Why chop fails? (Huey)
Re: Why chop fails? <jurgenex@hotmail.com>
Re: Why does Perl use more resource than Php? <do.not@spam.me>
Re: Why does Perl use more resource than Php? <philrob@HOLYflatnetSHIT.net>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 24 Dec 2003 16:17:06 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: Accounting, Database Problem
Message-Id: <3fe9b9f1.395882833@news.erols.com>
genericax@hotmail.com (Sara) wrote:
: PS: I forgot- you did say you wanted to limit the array to 500
: elements. Thats easy, try someting like:
:
: push @a, $newvalue;
: shift @a if @x > 500;
^^
I guess @x is supposed to be @a.
That's fine for the specific case of @a == 501, but it will do the wrong
thing if @a >= 502 .
A more generalized way to trim an array to the last 500 elements:
splice @a, 0, -500;
------------------------------
Date: Wed, 24 Dec 2003 14:55:44 GMT
From: James Willmore <jwillmore@remove.adelphia.net>
Subject: Re: effecient software engineering
Message-Id: <20031224095543.0c57e9be.jwillmore@remove.adelphia.net>
On 23 Dec 2003 23:08:14 -0800
afriedman111@hotmail.com (Aaron) wrote:
> I read that scripting is very useful in software engineering. I
> picked up some video game programming books and they mention that
> scripting can be used to seperate the code that is likely to change
> from the core game engine.
>
> I have heard that Perl is widely used in the game programming
> industry. Can perl scripting used for this? If not, what is it used
> for? If it is used for this, how does Perl communicate with the
> main game engine? Can some one explain how this works? For example:
> are there two executables that run and communicate back and forth,
> or is there only one executable? Is there a Perl interpreter that
> reads in scripts into your main program?
What *exactly* are you looking to do? Are you just trying to get a
feel for the capabilities of Perl? If that's the case, go to
http://www.perl.com/ and start reading :-)
You *may* want to read perlembed (if you have Perl installed, then
just type 'perldoc perlembed' at the command line to get this document
- if not, visit http://perldoc.com). This may be what you're after.
It's a way to embed Perl code in your C application - if I understand
your post. This also *assumes* that you know C :-) You could also
check out SWIG (http://www.swig.org/), which will also allow you to
"connect" Perl code with a C/C++ application.
If this isn't anything you're looking for, post with more specifics
:-)
HTH
--
Jim
Copyright notice: all code written by the author in this post is
released under the GPL. http://www.gnu.org/licenses/gpl.txt
for more information.
a fortune quote ...
Speak softly and carry a +6 two-handed sword.
------------------------------
Date: 24 Dec 2003 06:13:15 -0800
From: genericax@hotmail.com (Sara)
Subject: Re: How to write a script that takes input from the screen and writes a number to a text file?
Message-Id: <776e0325.0312240613.6d49bd9f@posting.google.com>
poppy2173@hotmail.com (Poppy Gerard) wrote in message news:<dc7a50cc.0312240322.2150c515@posting.google.com>...
> 24/12/03 - am
>
> Hi there. I am not sure if PERL is the right way to do this - but I
> am trying to generate a simple script that will run at a Website and
> accept a numerical input typed in on the screen, and write the number
> to a simple ASCII text file.
>
> Does anyone know how one can do this with PERL, or is there a better /
> easier way to generate such a program on-line?
>
> I would be grateful for any help / advice that people may be able to
> offer.
>
> With many thanks,
> and Seasons Greetings,
>
>
> Poppy Gerard
> poppy2173@hotmail.com
Hello Poppy:
your "screen" is generally an output device, unless you have a
touchscreen? Do you mean the keyboard?
my $x = <STDIN>;
will snag a line typed on your keyboard if that's what you're after.
So something like
# get the input and test it
$_ = <STDIN>;
chomp;
die "hey pardner this aint no number!!\n\n" unless /^\d+$/;
# output it to a file
die "Tarnation this dad-blamed file wont open!!\n\n" unless open F,
">myOutputFile";
print F;
close F;
print "wow I sure like CLPM\n\n";
g
------------------------------
Date: Wed, 24 Dec 2003 08:42:18 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: How to write a script that takes input from the screen and writes a number to a text file?
Message-Id: <slrnbuj9ea.8vh.tadmc@magna.augustmail.com>
Poppy Gerard <poppy2173@hotmail.com> wrote:
> I am not sure if PERL
The name of the language is "Perl".
The name of the interpreter is "perl".
It is not an acronym.
perldoc -q difference
> is the right way to do this - but I
> am trying to generate a simple script that will run at a Website and
You want to write a "CGI program".
You can write a CGI program in just about any programming language
that you choose.
Many many people do happen to choose to use Perl for their CGI programs.
> accept a numerical input typed in on the screen,
There is no "screen" in a CGI program.
A CGI program gets it input from the web server[1], and sends its
output to the web server[2].
> and write the number
> to a simple ASCII text file.
>
> Does anyone know how one can do this with PERL, or is there a better /
> easier way to generate such a program on-line?
People write programs.
Programs generate programs.
Their is no general purpose program-generator, you will need to
_write_ a program. To so that, you will need to learn a programming
language, perhaps Perl, perhaps anything else you might like.
If you chose to write that program using Perl, then it might
look something like this (untested):
----------------------------------------------
#!/usr/bin/perl
use strict;
use warnings;
use CGI qw/:standard/;
use CGI::Carp;
open FILE, '>simple_ASCII.txt' or
carp "could not open 'simple_ASCII.txt' $!";
print FILE param('the_number_from_the_form'), "\n";
close FILE or carp "problem closing file $!";
print "Content-Type: text/plain\n\n";
print param('the_number_from_the_form'), " has been written to the file\n";
----------------------------------------------
That's it!
(except a Real CGI Program would need to deal with multitasking and
do some form of file locking.
)
> I would be grateful for any help / advice that people may be able to
> offer.
There are a bazillion Perl FAQs about what you want to do, all you need
are some good search terms:
perldoc -q CGI
How can I make my CGI script more efficient?
Where can I learn about CGI or Web programming in Perl?
What is the correct form of response from a CGI script?
My CGI script runs from the command line but not the
browser. (500 Server Error)
How can I get better error messages from a CGI program?
How do I make sure users can't enter values into a form
that cause my CGI script to do bad things?
How do I decode a CGI form?
perldoc -q "\block"
How can I lock a file?
Why can't I just open(FH, ">file.lock")?
I still don't get locking. I just want to increment the
number in the file. How can I do this?
See also the Posting Guidelines that are posted here frequently.
[1] the web server in turn may have gotten the values from a <form>
filled out in a client program (eg. browser).
[2] the web server in turn may forward the output to a client program.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 24 Dec 2003 10:24:31 -0500
From: lucas <aolblowz@yahoo.com>
Subject: installing mod manually
Message-Id: <Q5idnVACucwtMnSiRVn-hg@golden.net>
I'm having trouble installing Math::Pari. I found out that it's because the
Makefile.PL that comes in the package doesn't use passive mode for FTP, and
I need to use passive. I've been trying to install with the mod CPAN, but
of course this wont work because of the above. How can I install a module
by hand?
I downloaded the correct file I needed, unpacked it, fixed the ftp get
section to make it use passive mode, and it all worked fine. a Makefile
was created, but it installs into the currect directory, and I need it to
go into my perl directory (/usr/local/lib/perl5)
thx
--
lucas
-------------------------
Perl Coder since 2001
shift || die;
-------------------------
------------------------------
Date: Wed, 24 Dec 2003 15:44:54 GMT
From: James Willmore <jwillmore@remove.adelphia.net>
Subject: Re: installing mod manually
Message-Id: <20031224104454.4e5fadcd.jwillmore@remove.adelphia.net>
On Wed, 24 Dec 2003 10:24:31 -0500
lucas <aolblowz@yahoo.com> wrote:
> I'm having trouble installing Math::Pari. I found out that it's
> because the Makefile.PL that comes in the package doesn't use
> passive mode for FTP, and I need to use passive. I've been trying
> to install with the mod CPAN, but of course this wont work because
> of the above. How can I install a module by hand?
>
> I downloaded the correct file I needed, unpacked it, fixed the ftp
> get section to make it use passive mode, and it all worked fine. a
> Makefile was created, but it installs into the currect directory,
> and I need it to go into my perl directory (/usr/local/lib/perl5)
perl Makefile.PL PREFIX=/usr/local
make
make test
su (if you're not root already)
make install
You *may* want to double check the PREFIX. I always seem to screw
that up. But, in this case, I'm pretty sure it's right.
Also, Math::Pari is different from other modules in this respect - if
it can't find the pari distro, it will download it for you. If this
is where you're getting hosed up, look in the README or INSTALL
file(s) for further directions. It's been awhile, but I think the
author gives some pretty clear directions on what to do if that's the
case.
HTH
--
Jim
Copyright notice: all code written by the author in this post is
released under the GPL. http://www.gnu.org/licenses/gpl.txt
for more information.
a fortune quote ...
7:30, Channel 5: The Bionic Dog (Action/Adventure) The Bionic
Dog drinks too much and kicks over the National Redwood Forest.
------------------------------
Date: Wed, 24 Dec 2003 11:26:47 -0500
From: lucas <aolblowz@yahoo.com>
Subject: Re: installing mod manually
Message-Id: <9P6dndWD08bVI3Si4p2dnA@golden.net>
Thanks ;)
I thought about using the 'prefix' paramater, but didn't turns out it worked
fine. I didn't find anything in the readme or install files about problems
with ftp. So, if anybody wants to know what I did to get around the ftp
requiring PASV to work properly, here you go:
Download the package (Math-Pari-2.010500.tar.gz)
unpack
edit ./Math-Pari-2.010500/utils/Math/PariBuild.pm
and modify: $ftp = Net::FTP->new($host) or die "Cannot create FTP object:
$!";
to: $ftp = Net::FTP->new($host, Passive => 1) or die "Cannot create FTP
object: $!";
Save file, run ./Math-Pari-2.010500/Makefile.pl prefix=/usr/local/lib/perl5
or wherever your perl directory is
the Makefile will download another gzip file and compile the C code (some of
it is in C), and install to your perl directory.
Thanks again Jim
--
lucas
-------------------------
Perl Coder since 2001
shift || die;
-------------------------
------------------------------
Date: 24 Dec 2003 09:33:34 -0800
From: djberg96@hotmail.com (Daniel Berger)
Subject: Re: monitor windows processes
Message-Id: <6e613a32.0312240933.140ec676@posting.google.com>
"RB" <wi@rjsolutions.org> wrote in message news:<bsa908$2o0g$1@msunews.cl.msu.edu>...
> Does anyone know how to monitor the existance of a process running in
> windows task manager.
>
> Basically I want to start another process only if the previous has finished
> and the script runs in windows.
>
> Thanks
You have a couple of choices. The first is to record the pid of that
process somewhere and test whether or not it's running using "kill 0"
(same as Unix).
Your other option is to resort to something like Win32::Process::Info
or Proc::ProcessTable and check for the name of the process.
Regards,
Dan
------------------------------
Date: 24 Dec 2003 16:06:26 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: Multiple SELECT queries
Message-Id: <u9ekuuryil.fsf@wcl-l.bham.ac.uk>
Sharif Islam <mislam@spamless.uiuc.edu> writes:
> Is this is an efficient way to do multiple select queries? It does
> what I need to accomplish. I am just curious if there are any better
> way to do this sort of queries.
> my @Query = ("SELECT COUNT(*) AS CT from table where URL is NULL",
> "SELECT COUNT(*) AS Cov from table where coverage is NULL","SELECT
> COUNT(*) AS Agg from table where ID is NULL") ;
>
> #query 1
> $sth = $dbh->prepare($Query[$Count]);
> $sth->execute();
> $row = $sth->fetchrow_arrayref;
> $sth->finish() ;
> #query 2
> $sth = $dbh->prepare($Query[$Count+1]);
> $sth->execute();
> $row1 = $sth->fetchrow_arrayref;
> $sth->finish;
> #query 3
> $sth = $dbh->prepare($Query[$Count+2]);
> $sth->execute();
> $row2 = $sth->fetchrow_arrayref;
If you ever find yourself doing same thing over and over for a series
of similarly names variables your mind should be sceaming "loop" and
"array".
This has nothing to do with Perl, it applies in all programming
lanuages.
my @rows = map { $dbh->selectrow_arrayref($_) } @Query[$Count .. $Count+2];
Actually if you only care about the first column of the first row of
each of the queries you don't need a 2D array.
my @counts = map { scalar $dbh->selectrow_array($_) } @Query[$Count .. $Count+2];
This, of course, still does three database queries. Now DBI can't
return multiple rowsets from a single statement but assumming your DB
engine supports nested selects or UNION you can combine multiple
queries into a single a rowset. (This has little to do with Perl -
it's really an SQL thing).
E.g. - combine three 1x1 rowsets into a 1x3 rowset
SELECT * FROM
(SELECT COUNT(*) AS CT from table where URL is NULL) AS Q1
FULL OUTER JOIN
(SELECT COUNT(*) AS Cov from table where coverage is NULL) AS Q2
FULL OUTER JOIN
(SELECT COUNT(*) AS Agg from table where ID is NULL) AS Q3
This may or may not be more efficient.
Actually there's at least one _much_ better way to get the particular
information you use in the example with a single simple SELECT but
that's a purely SQL thing and has _nothing_ whatever to do with Perl.
Hint: "COUNT(*) where URL is NULL" == "COUNT(*) - COUNT(URL)"
BTW: I note you are not error-checking so I'm trusting you have
$dbh->{RaiseError} set.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Wed, 24 Dec 2003 10:22:25 -0800
From: "Michael Peppler" <mpeppler@peppler.org>
Subject: Re: Multiple SELECT queries
Message-Id: <pan.2003.12.24.18.22.25.736342@peppler.org>
On Tue, 23 Dec 2003 15:30:29 -0600, Sharif Islam wrote:
> Is this is an efficient way to do multiple select queries? It does what I
> need to accomplish. I am just curious if there are any better way to do
> this sort of queries.
With Sybase and DBD::Sybase you can execute all the queries in a single
request:
my $sth = $dbh->prepare("
SELECT COUNT(*) AS CT from table where URL is NULL
SELECT COUNT(*) AS Cov from table where coverage is NULL
SELECT COUNT(*) AS Agg from table where ID is NULL");
$sth->execute;
my @data;
do {
while(my $d = $sth->fetch) {
push(@data, $d->[0]);
}
} while($sth->{syb_more_results});
now the @data array will hold the three COUNT(*) values.
Michael
--
Michael Peppler Data Migrations, Inc.
mpeppler@peppler.org http://www.mbay.net/~mpeppler
Sybase T-SQL/OpenClient/OpenServer/C/Perl developer available for short or
long term contract positions - http://www.mbay.net/~mpeppler/resume.html
------------------------------
Date: 24 Dec 2003 09:03:59 -0800
From: google@spongers.com (John Deuf)
Subject: Re: newbie: Terminating while($line=<stdin>) on Windows
Message-Id: <9760255.0312240903.46c362ca@posting.google.com>
Martien Verbruggen <mgjv@tradingpost.com.au> wrote in message news:<slrnbui7tm.qbf.mgjv@martien.heliotrope.home>...
> On 23 Dec 2003 19:03:57 -0800,
> John Deuf <google@spongers.com> wrote:
> > "Madhur" <a_madhur@vsnl.net> wrote in message news:<bsa11g$b8aej$1@ID-81175.news.uni-berlin.de>...
> >> Hello
> >> while($line==<stdin>)
> >> {
> >>
> >> }
> >> How would this be terminated. It is terminated by ^D on Unix system I
> >> think.
> >> But on windows It doesnt work.
> >
> > Hi,
> >
> > maybe the line should be read as
> >
> > while($line eq <stdin>)
> >
> > But it is certainly not what you want.
> > If the initial line was
> >
> > while($line = <stdin>)
> >
> > you expect maybe that the while stops when STDIN becomes false.
>
> Not really. Thw loop would exit when <stdin> becomes undefined (not
> false, but specifically undefined, see perlop documentation), and that
> happens when there are no more lines to be read from the handle stdin
> (not STDIN, Perl is case sensitive), i.e. when end-of-file is reached.
>
> > With a PC you may have to face the ^M ending char, the irritating
> > carriage-return char added to line-feed. I.e. on PC, 2 chars to end
> > the line.
>
> Huh?
>
> If you're on an operating system where in a file the end of line is
> represented by more than one character, then inside of Perl, the end of
> line is still a simple "\n". End of line is always "\n", irrespective of
> what the representation in the external file is.
>
> If you transport such files between platforms, and don't correctly
> convert the end-of-line sequences, then you could end up reading
> spurious characters, but that simply means that you're not reading a
> regular text file for the platform you're on.
>
> I am, of course, assuming that you're reading this file in text mode,
> since end-of-line makes no sense in any other context.
>
> > To cope with that problem, I propose this, but I'm sure there are
> > better algorithms, using $_ for instance :)
> >
> > while (<STDIN>) # get line in $_ { chomp; #
> > removes the unix LF char s/\015//; # removes the PC CR
>
> If, on windows, you would actually see a \015 there, then that would
> mean that the external file had a \015 before its normal end-of-line,
> and there would have been a byte sequence of \015\015\012 in the file.
> That's not really a text file, and indicates a problem with the file,
> rather than with the program or programmer. Or it indicates that the
> originator of the file wanted to have that extra \015 in there, for
> whatever sick reason.
>
> BTW, the end-of-line character (yes, a single one only) on Unix is \012,
> not \015. Macs use a single \015, and windows uses \015\012. Also see
> the perlport documentation for more information.
>
> If oyu want to remove newlines, use chomp(). If you need to read broken
> files, write specific routines to deal with that, but please, don't
> advocate the use of this sort of code for regular text files. it is not
> necessary, and in fact, broken.
>
> You should not have to worry about what your machine uses as the
> end-of-line indicator. In Perl it will be \n, and chomp will remove it.
>
> > char $line = $_; # if you really want the $line var...
>
> And if you really want the "$line var", then you should simply use it,
> and not $_:
>
> while (my $line = <STDIN>)
> {
> chomp $line; # to remove the newline
> # blahblah
> }
>
> Why use $_ at all? And why not scope the variable appropriately?
>
> Martien
Hi Martien :)
Thank you to answer my answer.
Did you at least read the initial question from the initial message :)
And tried to interpret it and answer it... Seemingly the initial user
is not a pro at Perl and needed to get a solution ready to use.
- <STDIN> being empty or false : actually it is finally evaluated to
false
Does playing with words really help the newbie :)
- Regarding the 2 chars on a PC coming from Unix - ok you program Perl
since the early nineties ... - but you should know my friend that on
some implementations and depending on the way it has been installed
the "chomp" removes only the \012 (LF) not the \015 (CR) ...
- STDIN : this is funny :) I'm sure you are not answering threads to
show off, since your time is so valuable, but my friend, as you say,
"read the doc" :)) All the global special filehandles are given in
uppercase (Perl in a nutshell for instance p.55). You're lucky,
"stdin" works in lowercase. But try with ARGV !!
- Regarding $_, yes, you got the point, and, for once, you answered
the user. Good. However I think it is better to forget the C
programming and tend to use $_ instead of other variables (needing
allocation etc...). Moreover it is so convenient to use this default
variable...
while (<STDIN>)
{
chomp;
s/\015//; # in case your implementation needs it and (for our
friend)if
# you don't want to spend ages to find out where the PC
specific
# config is missing
...
}
Cheers :)
------------------------------
Date: Wed, 24 Dec 2003 07:01:01 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Posting Guidelines for comp.lang.perl.misc ($Revision: 1.4 $)
Message-Id: <slrnbuj3gd.8vh.tadmc@magna.augustmail.com>
James Szinger <szinger@lanl.gov> wrote:
> "Alan J. Flavell" <flavell@ph.gla.ac.uk> writes:
>>
>> http://www.google.com/search?q=jargon+tofu
>> Use the web, Luke...
>
> Acronyms which are not generally known should be spelled out the first
> time they appear. Since "TOFU" is jargon and the guidelines are meant
> to help, I'm in favor of spelling it out as a courtesy to the reader.
> I find the present wording unclear.
I've expanded the acronym and adding "top-posting" to the list.
I've also worked in the reference to "How To Ask Questions The Smart Way"
that I've been meaning to add for several months.
Here are the diffs to the POD:
diff -r1.4 posting_guidelines.pod
10a11,16
> The article at:
>
> http://www.catb.org/~esr/faqs/smart-questions.html
>
> describes how to get answers from technical people in general.
>
213c219,220
< "Jeopardy" (because the answer comes before the question), or "TOFU".
---
> "top-posting", "Jeopardy" (because the answer comes before the question),
> or "TOFU" (Text Over, Fullquote Under).
220d226
<
I'll put those changes into effect in a few days.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 24 Dec 2003 06:16:35 -0800
From: genericax@hotmail.com (Sara)
Subject: Re: search interval
Message-Id: <776e0325.0312240616.3fdfa5dc@posting.google.com>
Ying Hu <yhu@mail.nih.gov> wrote in message news:<3FE8C50D.BE70D081@mail.nih.gov>...
> Hi,
> There are two data sets,
> data set 1:
> A1 123 125
> A2 129 200
> A3 400 420
> ...
> ...
> data set 2:
> B1 126
> B2 130
> B3 202
> ...
> ...
>
> My question is how to get B2 and A2 { 130 (B2) is in [from]129 [to]200
> (A2)} .
>
> thanks
> Ying
TRY:
http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&group=comp.lang.apl
Its better suited to this kind of application.
Cheers!
------------------------------
Date: Wed, 24 Dec 2003 12:34:14 -0500
From: Ying Hu <yhu@mail.nih.gov>
Subject: Re: search interval
Message-Id: <3FE9CE16.2FAC8D2D@mail.nih.gov>
My perl script is as the following, but I do know that is not good one.
The two data sets are in text files and very huge.
$infile = "data_sets1.txt";
open IN, $infile or die "$infile $!\n";
while (<IN>){
chomp;
@F = split;
$A_from{$F[0]} = $F[1];
$A_to{$F[0] = $F[2];
}
$infile = "data_sets2.txt";
open IN, $infile or die "$infile $!\n";
while (<IN>){
chomp;
@F = split;
$B_point{$F[0]} = $F[1];
}
foreach $b (sort {$B_point{a}<=>$B_point{$b} keys %B_point){
foreach $a (sort {$A_from{$a} <=> $A_from{$b} keys %A_from){
if ($B_point{$b} >= $A_from{$a} and $B_point{$b} <= $A_to){
print "A:$a B:$b\n";
}
}
}
Ying Hu wrote:
> Hi,
> There are two data sets,
> data set 1:
> A1 123 125
> A2 129 200
> A3 400 420
> ...
> ...
> data set 2:
> B1 126
> B2 130
> B3 202
> ...
> ...
>
> My question is how to get B2 and A2 { 130 (B2) is in [from]129 [to]200
> (A2)} .
>
> thanks
> Ying
------------------------------
Date: Wed, 24 Dec 2003 10:21:32 -0800
From: Yuri Shtil <yshtil@cisco.com>
Subject: Slow script
Message-Id: <3FE9D92C.2070704@cisco.com>
Hi
I have a script I inherited that was developed under perl 5.004.
I tried to run it under perl 5.8.0. It runs much much slower.
There is a lot of regular expressions that are invoked.
Any idea anyone why this might be happening?
Yuri.
------------------------------
Date: Wed, 24 Dec 2003 19:03:13 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Slow script
Message-Id: <x765g6hwcv.fsf@mail.sysarch.com>
>>>>> "YS" == Yuri Shtil <yshtil@cisco.com> writes:
> I have a script I inherited that was developed under perl 5.004.
> I tried to run it under perl 5.8.0. It runs much much slower.
> There is a lot of regular expressions that are invoked.
> Any idea anyone why this might be happening?
line 42 is written poorly.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: Wed, 24 Dec 2003 16:36:11 GMT
From: kosowsky@consult.pretender (Jeffrey J. Kosowsky)
Subject: Re: SOLVED:: HTML::Form->Parse (Perl) not working under Fedora Core 1
Message-Id: <m24qvqb2br.fsf@consult.pretender>
James Willmore <jwillmore@remove.adelphia.net> writes:
> No offense, but I don't bother with RPM's when it comes to Perl
> modules. In fact, given your position (a new install of Fedora), the
> *first* thing I'd do is use the CPAN shell and start updating *all*
> the modules. Because the *most* of the Perl modules that come with
> *most* distros are horribly out of date "out of the box". And the
> RPM's are usually not much better.
>
> I'd get used to using the CPAN shell instead of using the RPM's - but
> that's just my opinion :-)
No offense taken... but as a perennial perl newbie, I don't know much
about the CPAN shell.
I tend to use RPMS as time-savers so I don't have to worry about
updating and rebuilding apps.
What is the CPAN shell? Is it like a perl version of up2date/yum/apt?
Jeff
------------------------------
Date: 24 Dec 2003 09:45:50 -0800
From: hobbit_hk@hotmail.com (Hobbit HK)
Subject: STDIN Question
Message-Id: <22ee5d47.0312240945.7f512283@posting.google.com>
I know that if I do:
$line=<STDIN>;
I'll read from STDIN until I'll press ENTER... My question is, how can
I change it? I mean, can I do that if I'll press, for example, "c"
it'll stop reading from STDIN? or, alternatively, can I do that it'll
stop reading after 2 chars?
------------------------------
Date: Wed, 24 Dec 2003 18:02:01 +0000 (UTC)
From: efflandt@xnet.com (David Efflandt)
Subject: Re: STDIN Question
Message-Id: <slrnbujl4p.mjh.efflandt@typhoon.xnet.com>
On 24 Dec 2003 09:45:50 -0800, Hobbit HK <hobbit_hk@hotmail.com> wrote:
> I know that if I do:
> $line=<STDIN>;
>
> I'll read from STDIN until I'll press ENTER... My question is, how can
> I change it? I mean, can I do that if I'll press, for example, "c"
> it'll stop reading from STDIN? or, alternatively, can I do that it'll
> stop reading after 2 chars?
perldoc -q key
I do know if those methods display each key pressed or leave it up to you
to echo them to the screen (with output buffering disabled and print
without newline, although, you may need a newline after accepting last
input).
--
David Efflandt - All spam ignored http://www.de-srv.com/
------------------------------
Date: 24 Dec 2003 06:33:02 -0800
From: kuujinbo@hotmail.com (ko)
Subject: Re: Time out SSL request?
Message-Id: <92d64088.0312240633.664e26be@posting.google.com>
macapone@yahoo.com (Michael Capone) wrote in message news:<96996c7b.0312231350.4b960612@posting.google.com>...
> Hi folks,
>
> I'm using perl (actually, mod_perl environment on RH 8.0) to connect
> to an external SSL server. I feed it an XML request and get a
> response back. The problem is, the server is flaky, and I'd like to
> be able to timeout / break if I haven't gotten a response in X
> seconds. (Note that the server may connect, but simply not send a
> response, i.e., it's too busy.)
>
> I don't really understand filehandles and setting timeouts in unix /
> perl as much as I should. The code below was lifted from the
> Net::SSLeay readme and worked, and I never questioned it further.
>
> Could someone show me how to modify the code below to add my timeout?
> Note that I'm also completely open to other methods of connecting to
> an SSL server; the Net::SSLeay method seemed to be the quickest to
> implement, and I have no idea if there's a better way out there.
>
> Thanks!
>
> Michael
[snip code]
perldoc -f alarm
perldoc -f eval
You can pretty much cut/paste from the alarm() example.
HTH - keith
Th
------------------------------
Date: 24 Dec 2003 07:42:08 -0800
From: huey_jiang@yahoo.com (Huey)
Subject: Why chop fails?
Message-Id: <ae92bb50.0312240742.dc8da57@posting.google.com>
Hi All,
Merry Xmas! I wonder somebody would work at this moment, but this
simple problem just drives me nuts! How can a chop function fail? I
simply read from a text file, and need to clean up the newline char
with chop, but failed! My simply code:
#!perl
# records in file foo.txt is like "me:123\n"
open (F, "./foo.txt");
while (<F>) {
($u, $p) = split(/:/, $_);
chop $p;
if ( $p eq "123" ) {
print "got ya!", "\n";
}
}
close(F);
I am using cygwin perl. I noticed $p looked correct in command-line
when printed. The problem is the if () test never go true, it means
that $p never equals "123", and chop never worked! Aha! Funny? Anybody
ever experienced such a thing? Please give me your solution, thanks a
lot!
Huey
------------------------------
Date: Wed, 24 Dec 2003 16:00:34 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Why chop fails?
Message-Id: <CKiGb.15375$NZ1.490@nwrddc02.gnilink.net>
Huey wrote:
> [...] How can a chop function fail? I
> simply read from a text file, and need to clean up the newline char
> with chop, but failed!
Why are you using chop() instead of chomp()?
> My simply code:
>
> #!perl
> # records in file foo.txt is like "me:123\n"
> open (F, "./foo.txt");
> while (<F>) {
The usual method is to chomp() first, then process the line further. You are
doing it the other way round which is not wrong, but counterintuitive.
> ($u, $p) = split(/:/, $_);
> chop $p;
> if ( $p eq "123" ) {
> print "got ya!", "\n";
> }
> }
> close(F);
>
> I am using cygwin perl.
That implies you are running on Windows which uses a two-character
end-of-line indicator. chop() will remove only the last character (I think
that's the \0x0D), still leaving the other character intact (the \0x0A)
> I noticed $p looked correct in command-line
> when printed. The problem is the if () test never go true, it means
> that $p never equals "123",
Well, of course it doesn't because $p has the value "123\0x0A", i.e. it
contains 4 characters while you are comparing it with a text of 3
characters. That ain't gonna match.
> and chop never worked!
How do you know that? You didn't compare the string length before and after
the chop()?
I bet chop() worked perfectly fine and did remove the last character from
the string, just as it is supposed to do.
> [...] Please give me your solution,
Use the right function for the purpose: chomp()
Or are you still programming in Perl4?
jue
------------------------------
Date: Wed, 24 Dec 2003 10:28:41 -0500
From: Keith Bowes <do.not@spam.me>
Subject: Re: Why does Perl use more resource than Php?
Message-Id: <CiiGb.24$fu6.20@fe01>
I Report, You Decide wrote:
> A hosting service lungcapage has banned yabb, because it takes too much
> CPU/memory, but phpBB is fine. Is that perl/php or the script itself? why
> perl sucks more resource of a server than php? i thought only mod-perl will
> suck not regular perl.
>
That's strange. I would have thought that Perl would be more efficient,
due to PHP being easier and having more modules that are included
without invocation. But I guess it's possible that hard to read doesn't
necessarily mean fast to run.
------------------------------
Date: Wed, 24 Dec 2003 12:31:43 -0600
From: Phil Roberts <philrob@HOLYflatnetSHIT.net>
Subject: Re: Why does Perl use more resource than Php?
Message-Id: <Xns945BBC7B9EF6Dphilroberts@216.196.97.132>
With total disregard for any kind of safety measures "I Report,
You Decide" <test@test.com> leapt forth and uttered:
> A hosting service lungcapage has banned yabb, because it takes
> too much CPU/memory, but phpBB is fine. Is that perl/php or the
> script itself? why perl sucks more resource of a server than
> php? i thought only mod-perl will suck not regular perl.
>
Perl is usually run as a CGI module which will consume more server
RAM than a scripting interpreter which is running as part of the
server process (as PHP almost always is). When PHP is run as a CGI
it suffers from pretty much the exact same overhead problem.
Using files for storage will always be more server-intensive than a
proper DB server though. Regardless of the language.
--
There is no signature.....
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.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 5978
***************************************