[19613] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1808 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Sep 24 18:10:35 2001

Date: Mon, 24 Sep 2001 15:10:14 -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: <1001369414-v10-i1808@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Mon, 24 Sep 2001     Volume: 10 Number: 1808

Today's topics:
    Re: Pre spawning in perl (Kevin J. Schmidt)
    Re: pretty printing a web page lvirden@yahoo.com
        removing a remainder from a number (Larry S)
    Re: removing a remainder from a number <rsherman@ce.gatech.edu>
    Re: removing a remainder from a number <ren@tivoli.com>
    Re: removing a remainder from a number <jurgenex@hotmail.com>
    Re: Script to copy websites <bigbart5@hotmail.com>
    Re: Setting cookies <wizard@psychodad.com>
    Re: Setting cookies <mdudley@execonn.com>
    Re: threads <mb@buntstift.at>
    Re: threads <mb@buntstift.at>
    Re: Update: (Perl) programming contest loosely based on <tsee@gmx.net>
    Re: What do I need for programming Perl <comdog@panix.com>
    Re: What good is the hyphen for named parameters? <uri@sysarch.com>
    Re: What good is the hyphen for named parameters? (Clinton A. Pierce)
    Re: What good is the hyphen for named parameters? <bart.lateur@skynet.be>
    Re: What good is the hyphen for named parameters? <bart.lateur@skynet.be>
        Windows2000: CPAN.pm woes <alicia090677@hotmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 24 Sep 2001 13:19:01 -0700
From: kschmidt@mindspring.com (Kevin J. Schmidt)
Subject: Re: Pre spawning in perl
Message-Id: <92541e99.0109241219.1e1193ec@posting.google.com>

I want to do a similar task, except I need the parent to be able to
restart any child/children that die, as each child performs a specific
task that must be as fault tolerant as possible. Each child is
responsible for monitoring a host. When the parent spawns N children,
it records the host along with the child's PID. The parent would need
to get the PID of the dead child so it can do a look up for the host
that the dead child was monitoring, then restart a new child. Can
someone post some basic Perl code to take care of this? I have code
that is able to start N children and it works just fine. But I'm
seeing a problem when any of the children terminiate too quickly, i.e.
right away. If all the children start up and stay up, then all works
well. Also, I can't post any code as this is a proprietary
application. Sorry. But I think the problem is with how/when I'm
calling waitpid and/or how I'm setting up $SIG{CHLD}.

Thanks,
-Kevin

mjd@plover.com (Mark Jason Dominus) wrote in message news:<3bab5f1a.3654$304@news.op.net>...
> In article <3ba939ee.6532$5c@news.op.net>,
> Mark Jason Dominus <mjd@plover.com> wrote:
> >I think you will want to follow an outline something like this:
> 
> There were some errors:  I had the arguments to 'accept' in the
> wrong order, and I forget to check for a 0 return from 'waitpid'.
> I also forgot to put a loop in to handle_clients; without this,
> children handle only one client each before exiting.
> 
> This version appears to work correctly.  (That is, I have tested it.)
>


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

Date: 24 Sep 2001 18:11:18 GMT
From: lvirden@yahoo.com
Subject: Re: pretty printing a web page
Message-Id: <9ont06$1mr$2@srv38.cas.org>


According to Desrosiers, Benoit [CAR:9F53:EXCH] <benoitd@americasm01.nt.com>:
:but it's not enought. The main content on the page is a table. And some of
:its cells are multilines so I can't just print it sequentialy.
:
:If I use the print button on Netscape or on IE, I only get the left part of
:the page.
:What I would like is something that would reduce the size of what is being
:printed and fit it on one page.

The good news is that <URL: http://www.tdb.uu.se/~jan/ >
should point you on to the home page of html2ps .  The bad news is that
you need several pieces to get html to print AND you still have
to be careful, because as the scaling starts to occur, if the page is too
large, all you see are tiny dots on the page ... makes reading it a bit
tough.
-- 
-- 
"I know of vanishingly few people ... who choose to use ksh." "I'm a minority!"
<URL: mailto:lvirden@cas.org> <URL: http://www.purl.org/NET/lvirden/>
Even if explicitly stated to the contrary, nothing in this posting


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

Date: 24 Sep 2001 12:51:46 -0700
From: dime0000@yahoo.com (Larry S)
Subject: removing a remainder from a number
Message-Id: <8fd7acb0.0109241151.7f4d1d1b@posting.google.com>

i dont know why i cant figure this out

all i want to do is:

$sum = $number1 / $number2;
get rid of remainder in $sum.

the books over here stink :)

thanks!


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

Date: Mon, 24 Sep 2001 16:01:52 +0500
From: Robert Sherman <rsherman@ce.gatech.edu>
Subject: Re: removing a remainder from a number
Message-Id: <3BAF12A0.3D818E45@ce.gatech.edu>

Larry S wrote:
> 
> i dont know why i cant figure this out
> 
> all i want to do is:
> 
> $sum = $number1 / $number2;
> get rid of remainder in $sum.
> 
> the books over here stink :)
> 
> thanks!

perldoc -f int

$sum = $number1 / $number2;
int($sum);


-- 
robert sherman
css, cee
georgia institute of technology
atlanta, ga, usa


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

Date: 24 Sep 2001 14:58:14 -0500
From: Ren Maddox <ren@tivoli.com>
Subject: Re: removing a remainder from a number
Message-Id: <m3zo7kfjjd.fsf@dhcp9-161.support.tivoli.com>

On 24 Sep 2001, dime0000@yahoo.com wrote:

> i dont know why i cant figure this out
> 
> all i want to do is:
> 
> $sum = $number1 / $number2;
> get rid of remainder in $sum.

  $sum = int($number1 / $number2);

-- 
Ren Maddox
ren@tivoli.com


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

Date: Mon, 24 Sep 2001 13:46:40 -0700
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: removing a remainder from a number
Message-Id: <3baf9bb1$1@news.microsoft.com>

"Larry S" <dime0000@yahoo.com> wrote in message
news:8fd7acb0.0109241151.7f4d1d1b@posting.google.com...
> i dont know why i cant figure this out
> all i want to do is:
>
> $sum = $number1 / $number2;
> get rid of remainder in $sum.

maybe you are looking for
    $sum = int ($number1 / $number2);
Details see perldoc -f int

> the books over here stink :)
May I suggest some air freshener?

jue




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

Date: Mon, 24 Sep 2001 20:28:38 +0100
From: "Bart" <bigbart5@hotmail.com>
Subject: Re: Script to copy websites
Message-Id: <1001360424.21557.1.nnrp-08.d4e563b8@news.demon.co.uk>

Thanks for all your replies, but will any of these work on a
more complex website(s), i.e. 5000+ of .asp .php pages,
and even dynamically generated webpages?

Many thanks in advance.

Bart.




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

Date: Mon, 24 Sep 2001 13:36:52 -0500
From: "Michael D. Kirkpatrick" <wizard@psychodad.com>
Subject: Re: Setting cookies
Message-Id: <3BAF7D44.E7878B45@psychodad.com>

Marshall Dudley wrote:

> I am unable to set a cookie using a perl script.  This is the script:
>
>         print "Set-Cookie: AFFILIATE=$affiliate; ";
>         print "expires=$expdate; " if ($expires);
>         print "domain=www.king-cart.com; ";    #works if I leave this line
> out
>         print "path=/; \n";
>
> If I leave out the domain line, it will set cookies fine.  Mind you I am not
> retreiving cookies to see if they are set, I am reviewing them on the local
> hard drive, so I am certain that they are not being set when that line is in
> there. In fact the date and time on the cookie file does not get updated so I
> know Netscape is not even trying to set the cookie.
>
> Why will Netscape NOT set the cookie when I specify a domain I want the
> cookie availabe from?  The only restriction is the two periods, which the
> domain has.  I have been using cookies for years, but never seen this problem
> before.
>
> http://home.netscape.com/newsref/std/cookie_spec.html says:
>
> domain=DOMAIN_NAME
>      When searching the cookie list for valid cookies, a comparison of the
> domain attributes of the cookie is made with the
>      Internet domain name of the host from which the URL will be fetched. If
> there is a tail match, then the cookie will go
>      through path matching to see if it should be sent. "Tail matching" means
> that domain attribute is matched against the tail
>      of the fully qualified domain name of the host. A domain attribute of
> "acme.com" would match host names
>      "anvil.acme.com" as well as "shipping.crate.acme.com".
>
>      Only hosts within the specified domain can set a cookie for a domain and
> domains must have at least two (2) or three (3)
>      periods in them to prevent domains of the form: ".com", ".edu", and
> "va.us". Any domain that fails within one of the seven
>      special top level domains listed below only require two periods. Any
> other domain requires at least three. The seven
>      special top level domains are: "COM", "EDU", "NET", "ORG", "GOV", "MIL",
> and "INT".
>
>      The default value of domain is the host name of the server which
> generated the cookie response.
>
> Any assistance would be appreciated.
>
> Thanks,
>
> Marshall

Try checking out:
http://search.cpan.org/doc/RGEOFFREY/CGI-Thin-0.52/lib/CGI/Thin/Cookies.pm

Maybe that module will do exactly what you want to do...




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

Date: Mon, 24 Sep 2001 12:32:44 -0400
From: Marshall Dudley <mdudley@execonn.com>
To: "Rob - Rock13.com" <rob_13@excite.com>
Subject: Re: Setting cookies
Message-Id: <3BAF602B.513C8947@execonn.com>

Yes, that is the problem.  All the documents I had read up to that point
said that if you set the domain to the domain of the server that is to
read the cookie, it will work.  I need to set the cookie on one server,
and read it from another.  I finally found a document that said that you
cannot do that.

So I am no trying to send the cookie in the GET request I am sending
from the perl program.  However, I am not having any luck doing that
either. :<

How do you send a cookie from perl?  This is the code I am testing:



"Rob - Rock13.com" wrote:

> Marshall Dudley <news:3BAE11F6.572D172B@execonn.com>:
>
> > I am unable to set a cookie using a perl script.  This is the
> > script:
> >         print "Set-Cookie: AFFILIATE=$affiliate; ";
> >         print "expires=$expdate; " if ($expires);
> >         print "domain=www.king-cart.com; ";    #works if I
> >         leave this line
> > out
> >         print "path=/; \n";
> >
> > If I leave out the domain line, it will set cookies fine.
> > Why will Netscape NOT set the cookie when I specify a domain I
> > want the cookie availabe from?
>
> Sounds like, perhaps, NN is rejecting cookies that are not returned
> to the domain they're set from. That is, if you are not testing the
> script when its installed on king-cart.com it will fail.
>
> --
> Rob - http://rock13.com/
> Web Stuff: http://rock13.com/webhelp/



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

Date: Mon, 24 Sep 2001 22:18:27 +0200
From: Buchleitner Martin <mb@buntstift.at>
Subject: Re: threads
Message-Id: <20010924221827.1c665f11.mb@buntstift.at>

On Mon, 24 Sep 2001 23:51:58 +1000
mgjv@tradingpost.com.au (Martien Verbruggen) wrote:

Thanks for this Informations.
This software i want to develop should be like an IRC-Client.
The Differenze is, that the Server is using HTTP-Output and 
can also be recieved with a Browser.

I did not want to use Perl and Threads because i read that
it is still under develop.

I have to read perlipc and also something about fork.

thanks, martin


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

Date: Mon, 24 Sep 2001 22:21:46 +0200
From: Buchleitner Martin <mb@buntstift.at>
Subject: Re: threads
Message-Id: <20010924222146.6d7eb16a.mb@buntstift.at>

On Mon, 24 Sep 2001 23:51:58 +1000
mgjv@tradingpost.com.au (Martien Verbruggen) wrote:

> No, you don't. You could spawn children to deal with that.


> I'm a bit afraid that that is not nearly enough information to design
a
> piece of software.

> So far, I am guessing that you have one client application that needs
to
> read from and write to a web server simultaneously. There's only ever
> one reader and one writer? And what determines what's being read and
> what's being written? if the reader triggers the writes, maybe a fork
> would do? Or if the writer triggers the read (less likely) maybe a
fork
> would do as well. Do these readers and writers need to communicate
with
> each other?

> Many, many questions that need to be answered before you can even
design
> how you want to implement your software.

>> now i want to use threads to handle my problem.
>> the user should be able to send data to the server
>> while the program is still reading from the server.
>> how may i do this?

> If you insist that you want to use threads, then you should
familiarize
> yourself with thread programming, make sure you have a Perl that can
> deal with threads, and use them.

>> i read the perldoc perlthrtut but i am not sure
>> what i sould do now.

> perlthrtut is hardly an extensive tutorial on how threads work, and
how
> to use them. BTW, did you notice the first paragraph in the
DESCRIPTION
> section?  Threading is experimental. It's different in the ActiveState
> distros from the standard distribution (Threads.pm, have you read its
> documentation?). I have not used threads in Perl, simply because it is
> not ready for production work yet.

> Have you had a look at perlipc to see what sorts of interprocess
> communication you could use?

> Martien
> -- 
> Martien Verbruggen              | 
> Interactive Media Division      | 
> Commercial Dynamics Pty. Ltd.   | What's another word for Thesaurus?
> NSW, Australia                  | 

-- 


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

Date: Mon, 24 Sep 2001 22:46:52 +0200
From: "Steffen Müller" <tsee@gmx.net>
Subject: Re: Update: (Perl) programming contest loosely based on the prisoners' dilemma
Message-Id: <9oo63e$ni5$01$1@news.t-online.com>

"Ilmari Karonen" <iltzu@sci.invalid> schrieb im Newsbeitrag
news:998108759.18440@itz.pp.sci.fi...

[snip]

> I'd suggest, however, that you think about the details some more first.
> The best way to hook people onto something like this is to have a full
> set of rules ready so that they can start thinking about strategies as
> soon as they find out about the contest.

[snip]

Well, there's still a lot of thinking to do, but you might want to have a
look at http://lightning.prohosting.com/~teehsee/progcontest/ for some
(not-so-well-written?) source code and task description.
I haven't had loads of time to work on this since I announced it, so don't
expect leaps.

I am still looking for folks to help with this project.

Steffen





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

Date: Mon, 24 Sep 2001 15:14:20 -0500
From: brian d foy <comdog@panix.com>
Subject: Re: What do I need for programming Perl
Message-Id: <comdog-D505C3.15142024092001@news.panix.com>

In article <eb65a3a6.0109240754.6638f960@posting.google.com>, 
johnbtipton@hotmail.com (Johnny Tipton) wrote:

> I'm a newbie to Perl. I, normally, use Javascript, ASP, and VB. I need
> to learn Perl for my job. What all do I need to run a program from my
> desktop (compiler, editor, books, etc)?

if you are using Windows, as it appears that you are, start at

    http://www.activestate.com

and perhaps the book

    Learning Perl on Win32 Systems

-- 
brian d foy <comdog@panix.com> - Perl services for hire
CGI Meta FAQ - http://www.perl.org/CGI_MetaFAQ.html
Troubleshooting CGI scripts - http://www.perl.org/troubleshooting_CGI.html



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

Date: Mon, 24 Sep 2001 18:33:38 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: What good is the hyphen for named parameters?
Message-Id: <x7lmj4bfqc.fsf@home.sysarch.com>

>>>>> "BL" == Bart Lateur <bart.lateur@skynet.be> writes:

  BL> I don't see the point for using hyphens for "named parameters" for
  BL> subroutines. Although it doesn't prevent bareword quoting on the left
  BL> side of a "=>", it doesn't appear to add anything else. So what are they
  BL> good for?

as others have stated it is probably borrowed from tcl/tk and perl/tk as
well as shells. in stem i don't use the - prefix on named params. i
don't think it is useful. some like it to visually mark that token as a
param name.

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture and Stem Development ------ http://www.stemsystems.com
Search or Offer Perl Jobs  --------------------------  http://jobs.perl.org


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

Date: Mon, 24 Sep 2001 19:36:19 GMT
From: clintp@geeksalad.org (Clinton A. Pierce)
Subject: Re: What good is the hyphen for named parameters?
Message-Id: <3baf880e.23958310@localhost>

On Mon, 24 Sep 2001 14:57:53 +0100, "Simon Oliver"
<simon.oliver@umist.ac.uk> wrote:
>And to use bare quoting you must use the => notation:
>

Umm, no you don't.  :)

The - operator is interesting.  If followed by an identifier, the
identifier is quoted like so:

	use warnings;
	use strict;
	my $r;
	$r=-woo;
             print $r;    # prints "-woo"

Throws no warnings, strict doesn't have a problem with it at all.  It
kind of enables you to have these barewords floating around your
program and not get bitched at by strict and -w.

Keep in mind though that if this "bareword" corresponds to a function,
then the function's evaluated, the return value negated, and stuck in
place.  And it matters where the function is declared at too.

	use strict;
	use warnings;
	my $r;
	$r=-fortune;
	print $r;       # prints "-fortune"
             sub fortune { "Bad Dog!" }
             $r=-fortune; # Ambiguous use warning  (deservedly so!)
             print $r;       # prints "Bad Dog!"


    Clinton A. Pierce              Teach Yourself Perl in 24 Hours  *and*
  clintp@geeksalad.org         Perl Developer's Dictionary 
"If you rush a Miracle Man,     for details, see http://geeksalad.org
        you get rotten Miracles." --Miracle Max, The Princess Bride


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

Date: Mon, 24 Sep 2001 19:52:21 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: What good is the hyphen for named parameters?
Message-Id: <if3vqtg2cep8ej2b69chm6p5v4p2r7lbu6@4ax.com>

Stephen O. Lidie wrote:

>-option also turns on Perl's auto-quoting
>mechanism, which reduces the use of quotes.

It does not. I think I've quite demonstrated that already. If there are
any counter examples, I'd like to see them.

>Plus, the hypens make it
>very obvious what is an option and what is the option's value.

It doesn't, not to me. If you're claiming that named "options" can be
recognised by the hyphen prefix, as opposed to ordinary strings: that
presupposes that ordinary strings can never start with a hyphen. In
general, I don't buy that. If, for example, the string represents a file
name, then it's very likely that this is true. Well: not on a Mac.

-- 
	Bart.


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

Date: Mon, 24 Sep 2001 19:57:28 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: What good is the hyphen for named parameters?
Message-Id: <7u3vqt42tt8ko3m4h7vc4addqnr74mv76l@4ax.com>

Clinton A. Pierce wrote:

>            sub fortune { "Bad Dog!" }
>             $r=-fortune; # Ambiguous use warning  (deservedly so!)
>             print $r;       # prints "Bad Dog!"

Actually, it prints

	-Bad Dog!

with a hyphen upfront.

Actually, your examples are the first to show that "-name" is indeed
somewhat special. So it helps in autoquoting, but it doesn't go as far
as "=>". Hmm...

-- 
	Bart.


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

Date: 24 Sep 2001 15:42:56 -0400
From: Alicia <alicia090677@hotmail.com>
Subject: Windows2000: CPAN.pm woes
Message-Id: <9oo2c0$qkr$1@panix3.panix.com>



I just downloaded ActiveState's ActivePerl, and tried to use CPAN.pm
in interactive mode.  When I requested

  cpan> install MIME::Lite

(eventually) I got

  Running make test
  'test' is not recognized as an internal or external command,
  operable program or batch file.
     test -- NOT OK
  Running make install
    make test had returned bad status, won't install without force


There's no make on this machine, nor a whole bunch of other standard
Unix programs that CPAN.pm seems to need (gzip, etc.).  I suppose I
could try to install cygwin, or the like, etc., to create an adequate
Unix facsimile in this Windows machine, but first I would like to make
sure there's no other way to get CPAN.pm to work on a Windows
installation.  Is that so?  If not, how must I configure CPAN.pm to
run under windows?

Thanks,

a.


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

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


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