[25392] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 7637 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jan 12 14:10:24 2005

Date: Wed, 12 Jan 2005 11:10:16 -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, 12 Jan 2005     Volume: 10 Number: 7637

Today's topics:
    Re: cgi-bin script not printing output on html <vikram.keshavamurthy@gmail.com>
    Re: CGI: Execute a perl script inside another perl scri <nobull@mail.com>
    Re: complex numbers <itsme@yahoo.com>
    Re: complex numbers <rkern@ucsd.edu>
    Re: complex numbers <invalidemail@aerojockey.com>
        disk space script <blackforest2000@hotmail.com>
    Re: effective sort on two fields in both searchorders ( xhoster@gmail.com
    Re: effective sort on two fields in both searchorders ( <nobull@mail.com>
    Re: GLOB vs IO::Handle <nobull@mail.com>
    Re: Looking for strategies for performance improvements xhoster@gmail.com
    Re: Perl IDEs (Anno Siegel)
    Re: Problem splitting lines from file input (Anno Siegel)
    Re: Waiting for non-child processes <do-not-use@invalid.net>
    Re: Waiting for non-child processes (Anno Siegel)
    Re: Waiting for non-child processes (Anno Siegel)
    Re: Waiting for non-child processes chris-usenet@roaima.co.uk
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: 12 Jan 2005 10:24:52 -0800
From: "Vikram" <vikram.keshavamurthy@gmail.com>
Subject: Re: cgi-bin script not printing output on html
Message-Id: <1105554292.693513.209730@c13g2000cwb.googlegroups.com>

Hi Tintin,

Thanks for your reply. Your solution works, indeed i don't need to use
the dos internal command here. This is what I was looking for and I
appreciate your help.

Vikram



------------------------------

Date: Wed, 12 Jan 2005 18:17:40 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: CGI: Execute a perl script inside another perl script
Message-Id: <cs3pa5$eo1$1@sun3.bham.ac.uk>



xdarcos@hotmail.com wrote:

> Thanks all for your answers but it doesn't work yet :-(.
> So OK, 'exec' is not the good solution, neither 'system'.
> I didn't know the 'do' function, I tried it but without success: in my
> exe, the environnement variables I have set in 'envCGI.pl' are still
> unknown.

Please always produce a _minimal_ but _complete_ test case.

I just did this on my windows box here and was unable to reproduce the 
problem.

------------x.pl---------------
do 'y.pl';
system 'cmd';
-------------------------------

------------y.pl---------------
$ENV{FOO}='BAR';
-------------------------------

When I run x.pl the child cmd.exe could see the environment variable set 
in y.pl.

Rather than expecting each person who tries to help to produce a minimal 
but complete test case to attempt to reproduce the symptoms is is much 
more efficient (and polite) for the person asking the question to do so.

Often the act of doing so will find the problem.

Have you read the posting guidelines that are posted here frequenting? 
They contain a lot of valuable advice that will help you to get answers 
and also help you to avoid accidently giving the appearance of being 
lazy/arrogant/selfish.

> Regarding "perldoc -q environment" Jürgen, this is dedicated to Unix
> and I am using Windows

What it says applies largely to Windows too. I believe there is in 
Windows a way to alter the environment variables of another process - 
but that's low-level OS-specific stuff that you'd need to discuss in an 
OS specific group.



------------------------------

Date: Wed, 12 Jan 2005 16:30:04 GMT
From: "It's me" <itsme@yahoo.com>
Subject: Re: complex numbers
Message-Id: <ggcFd.10634$5R.9228@newssvr21.news.prodigy.com>

Precisely.   One have to convert complex number into vectors, and vector of
complex numbers into vector of vectors, list of complex numbers into list of
vectors, ...., you get the idea.

And my code no longer look like the equation I have on paper...

Like I said, I've travelled down that path before with C++ and Modelica.
It gets ugly.

Anyway.



"Antoon Pardon" <apardon@forel.vub.ac.be> wrote in message
news:slrncu9mmo.1r6.apardon@rcpc42.vub.ac.be...
> Op 2005-01-12, It's me schreef <itsme@yahoo.com>:
> >
> > "Robert Kern" <rkern@ucsd.edu> wrote in message
> > news:cs1mp9$sg9$1@news1.ucsd.edu...
> >>
> >> That's *it*.
> >
> > So, how would you overload an operator to do:
> >
> > With native complex support:
> >
> > def  twice(a):
> >     return 2*a
> >
> > print twice(3+4j), twice(2), twice("abc")
> >
> > Let's presume for a moment that complex is *not* a native data type in
> > Python.  How would we implement the above - cleanly?
>
>
> I suppose in the same way as (graphic) points and vectors can be
> implemented cleanly.
>
> A few years back I had written a Vector class in python, just
> to get an understanding of how things worked. It worked without
> a problem with your twice function.
>
>
> >>> Vec(1.0,2.0)
> Vector[1.0, 2.0]
> >>> def twice(a):
> ...   return 2 * a
> ...
> >>> twice(Vec(1.0,2.0))
> Vector[2.0, 4.0]
> >>>
>
>
> I suppose what can be done with a vector class could have been
> done with a complex class should complex numbers not have been
> native to python.
>
> -- 
> Antoon Pardon




------------------------------

Date: Wed, 12 Jan 2005 10:25:12 -0800
From: Robert Kern <rkern@ucsd.edu>
Subject: Re: complex numbers
Message-Id: <cs3q29$7kf$1@news1.ucsd.edu>

It's me wrote:
> "Robert Kern" <rkern@ucsd.edu> wrote in message
> news:cs1mp9$sg9$1@news1.ucsd.edu...
> 
>>That's *it*.
> 
> 
> So, how would you overload an operator to do:
> 
> With native complex support:
> 
> def  twice(a):
>     return 2*a
> 
> print twice(3+4j), twice(2), twice("abc")
> 
> Let's presume for a moment that complex is *not* a native data type in
> Python.  How would we implement the above - cleanly?

The way it's implemented now. See the file Object/complexobject.c for 
details. Numeric operations on ints, longs, floats, and complex numbers 
are all implemented using operator overloading.

There's nothing special about the complex object. One can even remove it 
from the language quite easily. Some of the embedded versions of Python 
have in fact done so.

-- 
Robert Kern
rkern@ucsd.edu

"In the fields of hell where the grass grows high
  Are the graves of dreams allowed to die."
   -- Richard Harter


------------------------------

Date: 12 Jan 2005 10:53:29 -0800
From: "Carl Banks" <invalidemail@aerojockey.com>
Subject: Re: complex numbers
Message-Id: <1105556009.063965.145210@z14g2000cwz.googlegroups.com>


It's me wrote:
> The world would come to a halt if all of a sudden nobody understands
complex
> numbers anymore.  :-)
Actually, it would oscillate out of control.


-- 
CARL BANKS



------------------------------

Date: Wed, 12 Jan 2005 19:48:58 +0100
From: "Bernd" <blackforest2000@hotmail.com>
Subject: disk space script
Message-Id: <cs3qj0$p3q$04$1@news.t-online.com>

Hello Newsgroup,

Anyone has a little Perlscript which could
give me the disk space left on all disks on a windows
system (nt, w2k, w3k servers?)?
And best of, the Disk space all in all? on each Disk?
Google did not help that much in this case.

Bernd




------------------------------

Date: 12 Jan 2005 17:23:25 GMT
From: xhoster@gmail.com
Subject: Re: effective sort on two fields in both searchorders (no FAQ !)
Message-Id: <20050112122325.834$g9@newsreader.com>

peter pilsl <pilsl@goldfisch.at> wrote:
> $val={a=>[1,2],
>        b=>[5,9],
>        c=>[2,4],
>        ...}
>
> I need to sort the keys on the two fields (first field and then second
> field), so I use:
>
> my @sort1= sort {
>                   $val->{$a}->[0] <=> $val->{$b}->[0] ||
>                   $val->{$a}->[1] <=> $val->{$b}->[1]
>                  } keys %$val;
>
> So far so good. Now I need - in the very next step - to do a second sort
> with opposite sort-order (second field and then first field)
>
> my @sort2= sort {
>                   $val->{$a}->[1] <=> $val->{$b}->[1] ||
>                   $val->{$a}->[0] <=> $val->{$b}->[0]
>                  } keys %$val;
>
> The true $val is very big and I'm sure there is a much more efficient
> (and complex) way to get both searchorders in one step without doing all
> the <=>-operations twice.

I very much doubt it.  You could caches some of the comparisons, but the
caching overhead would probably be much greater than the savings.

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service                        $9.95/Month 30GB


------------------------------

Date: Wed, 12 Jan 2005 17:50:11 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: effective sort on two fields in both searchorders (no FAQ !)
Message-Id: <cs3nmu$dtb$1@sun3.bham.ac.uk>



peter pilsl wrote:
> 
> 
> $val={a=>[1,2],
>       b=>[5,9],
>       c=>[2,4],
>       ...}
> 
> I need to sort the keys on the two fields (first field and then second 
> field), so I use:
> 
> my @sort1= sort {
>                  $val->{$a}->[0] <=> $val->{$b}->[0] ||
>                  $val->{$a}->[1] <=> $val->{$b}->[1]
>                 } keys %$val;
> 
> So far so good. Now I need - in the very next step - to do a second sort 
> with opposite sort-order (second field and then first field)
> 
> my @sort2= sort {
>                  $val->{$a}->[1] <=> $val->{$b}->[1] ||
>                  $val->{$a}->[0] <=> $val->{$b}->[0]
>                 } keys %$val;
> 
> 
> The true $val is very big and I'm sure there is a much more efficient 
> (and complex) way to get both searchorders in one step without doing all 
> the <=>-operations twice.

I do not think you are going to easily find any way to make it more 
efficient.



------------------------------

Date: Wed, 12 Jan 2005 17:57:33 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: GLOB vs IO::Handle
Message-Id: <cs3o4q$e63$1@sun3.bham.ac.uk>



Sisyphus wrote:

> Anno Siegel wrote:
> 
>>
>>> By this point I get the distinct feeling that I just don't know
>>> enough about this wheel to mess around with reinventing it.  What's
>>> the tried-and-true idiom for doing what I want to do?
>>
>>
>>
>>     if ( defined fileno $x ) {
>>         # it's an open file handle
>>     }
>>
>> Anno
> 
> 
> from 'perldoc -f fileno':
>   (Filehandles connected to memory objects via new features of
>    "open" may return undefined even though they are open.)

I was going to point that out too but experimentation shows that in 
practice they return -1.  This "feels right" so I suspect it will not 
change in future and I suspect perlfunc will catch up sooner or later.

Of course fileno() on a tied handle could return anything or even die.



------------------------------

Date: 12 Jan 2005 17:30:07 GMT
From: xhoster@gmail.com
Subject: Re: Looking for strategies for performance improvements
Message-Id: <20050112123007.572$y8@newsreader.com>

lvirden@gmail.com wrote:
> A perl developer stopped by this morning with this question.
> He has a new trainee that is learning Perl.  One of the early tasks
> he has a need to complete is this.
>
> He has an application that reads through terabytes of information,
> searching for particular patterns and combinations.  The program
> runs for days.  However, as the time that the program runs progresses,
> it appears to produce results less frequently than expected.

What do you mean by "less frequently"?  Do you mean it isn't finding all
the matches that it should, or do yo mean that it still finds what it
should but is getting slower and slower about doing so?

> When he notices this, he stops the application, starts it back up where
> things left off, and the application returns to producing results at
> the frequency expected - until, of course, the next time 8 or 10 or
> whatever hours have gone by...
>
> What tools might be available to a newbie perl developer that would
> assist in analysing and improving an application exhibiting this sort of
> behavior?

use strict;
use warnings;

And then, on unix-like systems, top and/or ps to see if the programs memory
use is growing without bound.  If it is, go find the memory leak and fix
it.

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service                        $9.95/Month 30GB


------------------------------

Date: 12 Jan 2005 16:16:40 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Perl IDEs
Message-Id: <cs3ih8$pss$1@mamenchi.zrz.TU-Berlin.DE>

Mothra  <Mothra@mothra.com> wrote in comp.lang.perl.misc:
> "Bernard El-Hagin" <bernard.el-haginDODGE_THIS@lido-tech.net> wrote in 
> news:Xns951F9B54EE7CCelhber1lidotechnet@62.89.127.66:
> 
> > Thomas Kaufmann <merman@snafu.de> wrote:
> > 
> >> Hi there,
> >> 
> >> I'm a Perl-Newbie and I looking for good and modern Perl-IDEs. Can
> >> you help me? 
> > 
> > 
> > Console + screen + vim. Oh wait, you said modern. xterm + screen + vim.
> 
> vim?  what's wrong with vi?  or ed?

The one good thing about IDEs is the ability to point your editor to
the place where an error occurred without having to type in the line
number (and possibly filename).

Vim (as opposed to vi and other clones) has the QuickFix feature that
supports this.  QuickFix can be used with Perl through the module
Vi::QuickFix, available from CPAN, author yours truly.

Anno


------------------------------

Date: 12 Jan 2005 16:31:16 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Problem splitting lines from file input
Message-Id: <cs3jck$pss$4@mamenchi.zrz.TU-Berlin.DE>

Mothra  <Mothra@mothra.com> wrote in comp.lang.perl.misc:
> I'm trying to parse a log file using ';' as a newline and then wherever 
> I find items inside '(..)', indenting those lines thus:

Sounds like a job for Text::Balanced.

Anno


------------------------------

Date: 12 Jan 2005 17:08:33 +0100
From: Arndt Jonasson <do-not-use@invalid.net>
Subject: Re: Waiting for non-child processes
Message-Id: <yzd1xcqocji.fsf@invalid.net>


anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) writes:
> Arndt Jonasson  <do-not-use@invalid.net> wrote in comp.lang.perl.misc:
> > 
> > "Ben Veal" <zen8533@zen.co.uk> writes:
> > > Can anyone tell me how I can wait for a non-child process to complete?
> > > (waitpid doesn't work).
> > 
> > If the OS is Unix, you can use 'kill' with the 0 signal to find out
> > whether a process exists, given its PID.
> 
> ...provided you are allowed to signal the other process at all.  You
> must be the same user or superuser for that.

You will get an error return value from the system call if you don't
own the process, but you can distinguish the cases by looking at
'errno' ($! in Perl).


------------------------------

Date: 12 Jan 2005 16:21:44 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Waiting for non-child processes
Message-Id: <cs3iqo$pss$2@mamenchi.zrz.TU-Berlin.DE>

Arndt Jonasson  <do-not-use@invalid.net> wrote in comp.lang.perl.misc:
> 
> anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) writes:
> > Arndt Jonasson  <do-not-use@invalid.net> wrote in comp.lang.perl.misc:
> > > 
> > > "Ben Veal" <zen8533@zen.co.uk> writes:
> > > > Can anyone tell me how I can wait for a non-child process to complete?
> > > > (waitpid doesn't work).
> > > 
> > > If the OS is Unix, you can use 'kill' with the 0 signal to find out
> > > whether a process exists, given its PID.
> > 
> > ...provided you are allowed to signal the other process at all.  You
> > must be the same user or superuser for that.
> 
> You will get an error return value from the system call if you don't
> own the process, but you can distinguish the cases by looking at
> 'errno' ($! in Perl).

You are right, I keep forgetting this.  It's less elegant than

   if ( kill 0, $pid ) { # process exists

but it works.

Anno


------------------------------

Date: 12 Jan 2005 16:26:25 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Waiting for non-child processes
Message-Id: <cs3j3h$pss$3@mamenchi.zrz.TU-Berlin.DE>

Ben Veal <zen8533@zen.co.uk> wrote in comp.lang.perl.misc:
> 
> "Anno Siegel" <anno4000@lublin.zrz.tu-berlin.de> wrote in message
> news:cs3ent$m46$1@mamenchi.zrz.TU-Berlin.DE...
> > Ben Veal <zen8533@zen.co.uk> wrote in comp.lang.perl.misc:
> > > Can anyone tell me how I can wait for a non-child process to complete?
> > > (waitpid doesn't work).
> >
> > That's an OS question, not a Perl question.  It can't be reasonably
> > answered without more information.

[...]

> The processes show up with ps as my processes, and I can get their pid's and
> kill them, but I can't do fg on them.

In that case, "kill 0, $pid" is definitely the way to go.

Anno


------------------------------

Date: Wed, 12 Jan 2005 17:14:38 +0000
From: chris-usenet@roaima.co.uk
Subject: Re: Waiting for non-child processes
Message-Id: <ug2gb2-8u9.ln1@moldev.cmagroup.co.uk>

>> If the OS is Unix, you can use 'kill' with the 0 signal to find out
>> whether a process exists, given its PID.

Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote:
> ...provided you are allowed to signal the other process at all.  You
> must be the same user or superuser for that.

Not strictly true on any UNIX-type system that I've used. You can send
signal 0 to any process and get one of three [*] probable results:

    1	OK - process is owned by you and exists
    2	Permission denied - process exists but owned by someone else
    3	No such process - process doesn't exist

So by checking for either (1) or (2), and contrasting with (3), you can
determine whether a process exists regardless of whether you own it

or not.
Regards,
Chris

[*] There can be other errors but it's unlikely you'll see them


------------------------------

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.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

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 7637
***************************************


home help back first fref pref prev next nref lref last post