[18289] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 457 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Mar 9 18:10:46 2001

Date: Fri, 9 Mar 2001 15:10:13 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <984179413-v10-i457@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Fri, 9 Mar 2001     Volume: 10 Number: 457

Today's topics:
    Re: Socket and fork problem <graham@wellho.net>
    Re: Trying to capture current directory in variable <mischief@velma.motion.net>
    Re: Trying to capture current directory in variable <bart.lateur@skynet.be>
    Re: Trying to capture current directory in variable (Richard J. Rauenzahn)
    Re: Use PERL or Java? Which is faster? <mack1@u.washington.edu>
    Re: Use PERL or Java? Which is faster? <joe+usenet@sunstarsys.com>
    Re: Use PERL or Java? Which is faster? (Peter Schuller)
    Re: using Perl for B2B? <Jonathan.L.Ericson@jpl.nasa.gov>
        Weekend woes?! <jbou@bunker79.fsnet.co.uk>
    Re: Weekend woes?! (Martien Verbruggen)
    Re: Weekend woes?! <hafateltec@hotmail.com>
    Re: Weekend woes?! <Jonathan.L.Ericson@jpl.nasa.gov>
    Re: Weekend woes?! <hafateltec@hotmail.com>
    Re: Weekend woes?! (Tad McClellan)
    Re: Weekend woes?! (Tad McClellan)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Fri, 09 Mar 2001 19:14:09 +0000
From: Graham Ellis <graham@wellho.net>
Subject: Re: Socket and fork problem
Message-Id: <3AA92B81.C41F3D5B@wellho.net>

Alan,

I'm wondering if you have a timing problem here (OK - I know you have 
a timing problem ;-) ) caused by interaction by the time sharing
of your operating system and your Perl program.  Goodness - this is
going to be a hard one to explain - but let me try.

Scenario 1:

WITH the sleep statement, the accept call returns, and then goes
into the sleep.   Now you can't guarantee exactly how long a
sleep 1 will take - it may be less than or more than a second, but
it does introduce somthing of a delay.   When the delay has been
completed, the server goes into the <$connection> and can probably
proceed straight on from there since there's probably data waiting
already.

        Time taken:  how_long_sleep_took + delta

Scenario 2:

WITHOUT the sleep statement.   The accept call returns and goes
immediatelly into the <$connection>.   It's probable that no data
has arrived yet, and so the server process is suspended, and the
operating system scheduler is told to hold it off for a while and
get on with something else.   Only later when the operating system
gives another slice of time to your server (some OS's are not 
generous about this - have you even noticed how long a machine can
take to wake up when you type something in?) will the <$connection>
be fulfilled and the program carry on.

        Time taken: OS_timeshare_delay + delta

So if yor OS_timeshare_delay is greater than how_long_sleep_took,
you have the apparently bizarre situation of adding a sleep statement
to speed up your program.

This is an educated guess - I HAVE seen things like this before.  Let
me know if it's plausible / if you would like any further assistance as
you move from analysis on to looking for a solution.  This could be
an interesting one!

-- 
Graham Ellis, Well House Consultants
Melksham, Wiltshire, UK
http://www.wellho.net   graham@wellho.net


Alan Carter wrote:
> 
> Hi Peeps.
> 
> This is a section of code from a server I am writting. To put it simply.  I
> have a client program (written in C) that is executed 10's of times a
> second. This program connects to the socket  of my server and relays
> parameters from a thirdparty application to the server (which then does
> various things and eventualy stores this all in a dbase...).
> 
> That is it the client does nothing but that.!!!
> 
> The problem I am having is speed!
> 
> I need the client program to exit as soon as the server has received the
> data from it, so that the other third party program is released in good
> time.
> 
> The bottle-neck i am getting is around this section of code where the server
> forks off to allow another connection.
> 
> I am not getting good enough performance here. I can runn about 7 clients a
> second. I need to double that.
> 
> The really confuseing thing is that if i put a statement  "sleep 1;"  after
> the line that reads  "next unless my $connection = $listen_socket->accept;"
> the clients execution time halfs????????????
> ie.. It does what its supposed to do that is exit as soon as the server has
> received the data..
> 
> I am useing IO::Socket but got the same results with the old style useing
> bind etc...........
> 
> Please help me.........
> 
> I found this hard to describe I hope i have provided enough info.
> 
> (With this code I can handle 7 client connections per second ; Uncommenting
> the sleep statement produced double the connection rate.)
> 
> while (!$quit) {
>      next unless my $connection = $listen_socket->accept;
>     #sleep 1;
>      my $inbound = <$connection>;
>      $connection->close;
>      die "Can't fork: $!" unless defined (my $child = fork());
> 
>      if ($child ==0) {
>       $listen_socket->close;
>       my $rtrn = do_stuff($inbound, $dbh);
>       if ($rtrn == 1) {print "euck!! that didnt work\n";}
>          exit 0;
>       }
> }


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

Date: Fri, 09 Mar 2001 19:56:35 -0000
From: Chris Stith <mischief@velma.motion.net>
Subject: Re: Trying to capture current directory in variable
Message-Id: <taidbjohh42q96@corp.supernews.com>

Tom Scheper <tom@power.net.uk> wrote:
> On Fri, 9 Mar 2001 17:11:59 +0200, "Michael Rolfe"
> <mumble[anti-spam]@maths.uct.ac.za> shed a beam of light on us:

>>Hi.
>>
>>I am a Perl newbie writing a program that does a tree-walk; I want to store
>>the original working directory in a variable (without using files, as write
>>access may not be assumed).  The motivation is to change back to that
>>directory as part of program completion.
>>
>>I am using ActiveState perl, v5.6.0 under Windows 98.
>>
>>It seems to me that what I should do is
>>
>>$OriginalDirectory = `cd` ;

> `cd` doesn't return anything. The reason why you might see a path if
> you type it in the shell you're using is because your shell shows it,
> not the cd command. Try doing it this way:

It does return something for me, and I'm testing on Windows 98 SE
with:

    C:\WINDOWS>perl -v

    This is perl, v5.6.0 built for MSWin32-x86-multi-thread
    (with 1 registered patch, see perl -V for more detail)

    Copyright 1987-2000, Larry Wall

    Binary build 623 provided by ActiveState Tool Corp.
    http://www.ActiveState.com
    Built 16:27:07 Dec 15 2000

The following works for me:

    perl -e "$OD = `cd`; print $OD;"

> $OriginalDirectory=chomp(`pwd`);

> There will more than likely be a perl equivalent, which is better to
> use, but I don't know by heart what it is.

How about a Windows equivalent, since that's where the user is.
There is no `pwd' command on Windows 98.

The OP might try

    $OriginalDirectory = `command /c cd`;

which launches a new command interpreter, runs the command,
then exits the CI and returns. It also works for me, albeit
more slowly and with more overhead.

But, since this is Perl, and the interpreter comes with many,
many standard modules, one of them being Cwd, I'd suggest that
Michael and Tom both read up on Cwd.

Type the following at a command prompt:

    `perldoc Cwd'

Chris

-- 
Christopher E. Stith
Disclaimer: Actual product may not resemble picture in ad in any way.



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

Date: Fri, 09 Mar 2001 20:25:07 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Trying to capture current directory in variable
Message-Id: <40fiat0ljra2hijpic7kue0l9v2uhotjqb@4ax.com>

"Michael Rolfe" <mumble[anti-spam]@maths.uct.ac.za> wrote:

>I am a Perl newbie writing a program that does a tree-walk; I want to store
>the original working directory in a variable (without using files, as write
>access may not be assumed).  The motivation is to change back to that
>directory as part of program completion.

	use Cwd; my $curdir = cwd; print "Current directory: $curdir\n";

But, as Randal Schwartz already wrote: when writing a directory tree
walker program, you first response should be File::Find.


-- 
	Bart.


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

Date: 9 Mar 2001 22:04:04 GMT
From: nospam@hairball.cup.hp.com (Richard J. Rauenzahn)
Subject: Re: Trying to capture current directory in variable
Message-Id: <984175443.648880@hpvablab.cup.hp.com>

"Michael Rolfe" <mumble[anti-spam]@maths.uct.ac.za> writes:
>Hi.
>
>I am a Perl newbie writing a program that does a tree-walk; I want to store
>the original working directory in a variable (without using files, as write
>access may not be assumed).  The motivation is to change back to that
>directory as part of program completion.

Just in case you meant, "to change back to the directory *after* program
completion," you don't need to do anything.  When the Perl program
exits, it will return to the original directory (which batch files
*don't* do.)

I guess DOS batch files are one reason many are surprised that they
can't change the environment from within a Perl script.

Rich

-- 
Rich Rauenzahn ----------+xrrauenza@cup.hp.comx+ Hewlett-Packard Company
Technical Consultant     | I speak for me,     |   19055 Pruneridge Ave. 
Development Alliances Lab|            *not* HP |                MS 46TU2
ESPD / E-Serv. Partner Division +--------------+---- Cupertino, CA 95014


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

Date: Fri, 9 Mar 2001 11:00:09 -0800
From: andrew smith <mack1@u.washington.edu>
Subject: Re: Use PERL or Java? Which is faster?
Message-Id: <Pine.A41.4.33.0103091059010.152904-100000@homer35.u.washington.edu>


mod_perl is much faster than EJB, but come on, who needs speed?
the architecture planing and technologies offered by java totally
outweigh it's speed problem


Andrew Smith
Student Software Developer
Ed-Tech Development Group
University of Washington

On Fri, 9 Mar 2001, [iso-8859-1] Thorbj=F8rn Ravn Andersen wrote:

> Matt Sergeant wrote:
> >
> > Thorbj=F8rn Ravn Andersen wrote:
> > >
> > > Daniel Berger wrote:
> > >
> > > > As for speed, I have *yet* to see a Java app that was as fast or fa=
ster than Perl/Tk,
> > > > or Perl in general for that matter.
> > >
> > > I parse XML with Java because it is a _lot_ faster than with Perl.
> >
> > Not necessarily, since Perl can interface to C based parsers. See the w=
ork
> > being done on Orchard right now. Though yes, in the general case and wi=
th
> > currently released libraries this tends to be true.
>
> Don't get me wrong.  I would much rather have a free choice, but the
> current mature technologies available to me as a Perlprogrammer is
> simply not fast enough.
>
> I'm keeping an eye on it though.
> --
>   Thorbj=F8rn Ravn Andersen              "...sound of...Tubular Bells!"
>   http://bigfoot.com/~thunderbear
>



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

Date: 09 Mar 2001 14:26:51 -0500
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: Use PERL or Java? Which is faster?
Message-Id: <m3k85yd9qc.fsf@mumonkan.sunstarsys.com>

andrew smith <mack1@u.washington.edu> writes:

> mod_perl is much faster than EJB, but come on, who needs speed?
> the architecture planing and technologies offered by java totally
> outweigh it's speed problem

Well that clears it all up for me now - thanks a ton.
Java wins this round 3 to 1.

Round 411,911 of the glorious francophile debate 
coming soon to a theater near you.

F'ups set.
-- 
Joe Schaefer                 "Language is the dress of thought."
                                               -- Samuel Johnson


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

Date: 9 Mar 2001 21:49:45 GMT
From: peter.schuller@infidyne.com (Peter Schuller)
Subject: Re: Use PERL or Java? Which is faster?
Message-Id: <98bj5p$s24$1@hecate.umd.edu>

>mod_perl is much faster than EJB, but come on, who needs speed?
>the architecture planing and technologies offered by java totally
>outweigh it's speed problem

Note that it's not really a good comparioson at all, if we're talking
language speed. mod_perl compiles perl code. Perl code then gets executed
and outputs text.

That's nothing compared to the kind of stuff that goes on with EJBs,
servlets, jsps, whatever.

-- 
/ Peter Schuller, InfiDyne Technologies HB

PGP userID: 0x5584BD98 or 'Peter Schuller <peter.schuller@infidyne.com>'
Key retrival: Send an E-Mail to getpgpkey@scode.infidyne.com
E-Mail: peter.schuller@infidyne.com Web: http://scode.infidyne.com



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

Date: 09 Mar 2001 21:04:58 +0000
From: Jon Ericson <Jonathan.L.Ericson@jpl.nasa.gov>
Subject: Re: using Perl for B2B?
Message-Id: <86g0gm8xhh.fsf@jon_ericson.jpl.nasa.gov>

Hermel Michaud <hermel_michaud@hotmail.com> writes:

> Hello, I don't know Perl too much...Im currently learning Java Server
> Programming for building b2b applications.
> I want to specialize in building b2b for small and medium companies.
> Someone told me Java technologie is too complicated for my needs and
> recommended Perl.
> I would appreciate it if someone can tell me if this is true...
> Is Perl ideal for building b2b web sites?

It depends on your situation:

1) If you aren't a programmer, but want to be, you should consider
learning a general, beginner's programming language.  Whether or not
Perl counts is open to debate.  I taught myself BASIC and learned
Pascal at school.  Throwing the web server into the mix is a mistake
in my opinion.

2) If you aren't a programmer, and either don't want to be or want to
get started right away, hire an experienced programmer.  Ask her
opinion, which is much more important to you than the opinion of some
random person on a newsgroup.

3) If you are a programmer, what makes b2b differant from other sorts
of web sites?  Perl is very widely used for generating dynamic content.

Jon


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

Date: Fri, 9 Mar 2001 20:56:48 -0000
From: "James Boulter" <jbou@bunker79.fsnet.co.uk>
Subject: Weekend woes?!
Message-Id: <98bg53$c41$1@newsg1.svr.pol.co.uk>

Dear all,

I wandered if it was actually possible to tell if a date in the past was a
weekend day using something like perl's localtime function.

Thank you
James

PLEASE FEEL UNDER NO OBLIGATION TO REPLY TO THIS E-MAIL EVEN IF YOU HAVE AN
ANSWER.





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

Date: Sat, 10 Mar 2001 08:52:01 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Weekend woes?!
Message-Id: <slrn9aik41.stm.mgjv@martien.heliotrope.home>

On Fri, 9 Mar 2001 20:56:48 -0000,
	James Boulter <jbou@bunker79.fsnet.co.uk> wrote:
> Dear all,
> 
> I wandered if it was actually possible to tell if a date in the past was a
> weekend day using something like perl's localtime function.

Yes. And you can also do it for dates in the future.

Transform your 'date' into a time, as accepted by localtime, and read
the locatlime documentation:

($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($time);
                                  ^^^^^
$wday is 6 for Saturday and 0 for Sunday.

How to get your date into $time?

If you have separate fields for year, month and day, you could use
timelocal from the Time::Local module. If you have a weird string, you
could use one of the various date parsing modules. It's enormously hard
to give good advice here, because you have not given us a shrimp of an
inkling of what your input data is like.

> PLEASE FEEL UNDER NO OBLIGATION TO REPLY TO THIS E-MAIL EVEN IF YOU HAVE AN
> ANSWER.

PLEASE DO NOT SHOUT AT US. IT IS EXTREMELY IMPOLITE. 

YOUR POST WAS NOT EMAIL, IT WAS A POST TO USENET, A PUBLIC FORUM.
ANYONE IS FREE TO ANSWER TO IT WHEN THEY WANT. MANY PEOPLE WITH
OBSESSIVE COMPULSIVE DISORDER POST HERE. DO YOU WANT TO DENY THEM THE
RIGHT TO ANSWER?

Impolite and cruel.

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | In a world without fences, who needs
Commercial Dynamics Pty. Ltd.   | Gates?
NSW, Australia                  | 


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

Date: Sat, 10 Mar 2001 07:51:37 +1000
From: "Copenhagen" <hafateltec@hotmail.com>
Subject: Re: Weekend woes?!
Message-Id: <Zfcq6.335$k2l.8257735@news.randori.com>

Sure is.  You would need to figure out how many seconds since 1 Jan 1970 and
plug that into localtime.  See perldoc perlfunc | grep localtime for more
info.

"James Boulter" <jbou@bunker79.fsnet.co.uk> wrote in message
news:98bg53$c41$1@newsg1.svr.pol.co.uk...
> Dear all,
>
> I wandered if it was actually possible to tell if a date in the past was a
> weekend day using something like perl's localtime function.
>
> Thank you
> James
>
> PLEASE FEEL UNDER NO OBLIGATION TO REPLY TO THIS E-MAIL EVEN IF YOU HAVE
AN
> ANSWER.
>
>
>




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

Date: 09 Mar 2001 21:52:26 +0000
From: Jon Ericson <Jonathan.L.Ericson@jpl.nasa.gov>
Subject: Re: Weekend woes?!
Message-Id: <863dcm8vad.fsf@jon_ericson.jpl.nasa.gov>

"James Boulter" <jbou@bunker79.fsnet.co.uk> writes:

> I wandered if it was actually possible to tell if a date in the past was a
> weekend day using something like perl's localtime function.

I believe that there are several modules at cpan.org that would be of
use.  You can also get the day of the week with something like:

$ perl -MTime::Local -e 'print scalar localtime(timelocal(0,0,0,30,10,1973))'
Fri Nov 30 00:00:00 1973

[I was born on a Friday?!?  I thought for sure it was a Wednesday.
Wow, I just went from "full of woe" to "works hard for a living".
Hmm... cal(1) says Friday as well.]

> PLEASE FEEL UNDER NO OBLIGATION TO REPLY TO THIS E-MAIL EVEN IF YOU HAVE AN
> ANSWER.

OK, BUT WHY ARE WE YELLING?  :) (Actually this sentence causes me
nothing but confusion.)

Jon


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

Date: Sat, 10 Mar 2001 08:00:14 +1000
From: "Copenhagen" <hafateltec@hotmail.com>
Subject: Re: Weekend woes?!
Message-Id: <6ocq6.347$k2l.6619368@news.randori.com>


"Martien Verbruggen" <mgjv@tradingpost.com.au> wrote in message
news:slrn9aik41.stm.mgjv@martien.heliotrope.home...
> On Fri, 9 Mar 2001 20:56:48 -0000,
> James Boulter <jbou@bunker79.fsnet.co.uk> wrote:
> > Dear all,
> >
[SNIP]
> > PLEASE FEEL UNDER NO OBLIGATION TO REPLY TO THIS E-MAIL EVEN IF YOU HAVE
AN
> > ANSWER.
>
> PLEASE DO NOT SHOUT AT US. IT IS EXTREMELY IMPOLITE.
>
> YOUR POST WAS NOT EMAIL, IT WAS A POST TO USENET, A PUBLIC FORUM.
> ANYONE IS FREE TO ANSWER TO IT WHEN THEY WANT. MANY PEOPLE WITH
> OBSESSIVE COMPULSIVE DISORDER POST HERE. DO YOU WANT TO DENY THEM THE
> RIGHT TO ANSWER?

OUCH... Lots of yelling going on here. Lol.




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

Date: Fri, 9 Mar 2001 17:04:11 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Weekend woes?!
Message-Id: <slrn9aikqq.hum.tadmc@tadmc26.august.net>

Martien Verbruggen <mgjv@tradingpost.com.au> wrote:
>On Fri, 9 Mar 2001 20:56:48 -0000,
>	James Boulter <jbou@bunker79.fsnet.co.uk> wrote:

>> PLEASE FEEL UNDER NO OBLIGATION TO REPLY TO THIS E-MAIL EVEN IF YOU HAVE AN
>> ANSWER.


>MANY PEOPLE WITH
>OBSESSIVE COMPULSIVE DISORDER POST HERE. 


Hi!


>DO YOU WANT TO DENY THEM THE
>RIGHT TO ANSWER?


I didn't have an answer yet felt obliged to reply,
so I followed up anyway. 

Some people just don't take direction very well.


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Fri, 9 Mar 2001 16:35:17 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Weekend woes?!
Message-Id: <slrn9aij4l.hum.tadmc@tadmc26.august.net>

James Boulter <jbou@bunker79.fsnet.co.uk> wrote:
>
>PLEASE FEEL UNDER NO OBLIGATION TO REPLY TO THIS E-MAIL EVEN IF YOU HAVE AN
                                             ^^^^^^^^^^^
>ANSWER.


This is not email.

This is news.

News is not email.


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

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


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