[26259] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 8443 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Sep 22 11:05:36 2005

Date: Thu, 22 Sep 2005 08:05:06 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Thu, 22 Sep 2005     Volume: 10 Number: 8443

Today's topics:
        @_ aliasing <mpapec@nohome.com>
    Re: https with LWP::UserAgent <richard@zync.co.uk>
    Re: https with LWP::UserAgent <newsAT@screenlightDOT.com>
    Re: LWP::Simple and Cookies not working <evil666overlord@yahoo.co.uk>
    Re: Problem in Executing system command in a forking se (Anno Siegel)
    Re: Problem in Executing system command in a forking se <djames@thehub.com.au>
    Re: Problem in Executing system command in a forking se <vek@station02.ohout.pharmapartners.nl>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 22 Sep 2005 15:32:54 +0200
From: Matija Papec <mpapec@nohome.com>
Subject: @_ aliasing
Message-Id: <bdc5j11mmthd95j0qtkak8uqkiu9vuo2m3@4ax.com>


Is there a perl version which prints 5 in case when,
perl -le 'sub f {my $a = shift; $a=5} f(my $b=1); print $b'

I was almost sure that shift() should not break the aliasing.



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

Date: Thu, 22 Sep 2005 14:46:59 +0100
From: Richard Gration <richard@zync.co.uk>
Subject: Re: https with LWP::UserAgent
Message-Id: <pan.2005.09.22.13.46.58.100503@zync.co.uk>

On Wed, 21 Sep 2005 17:47:09 +0000, one man army wrote:

> Hi All-
> 
>   I am an infrequent user of Perl, but have succeeded in a few endeavors.
> I have a script that reads data from a series of web pages. But now I 
> want to modify it to handle an HTTPS page.
> 
>   I looked briefly in UserAgent.pm

That way lies pain and death. Well, pain anyway. You haven't specified
your OS, so I'll say how it is for mine, Linux.

Using LWP with the https protocol is as simple as

my $ua = LWP::UserAgent->new;
my $req = HTTP::Request->new(GET => 'https://secure.tld');
my $res = $ua->request($req);

The key on *nix is to have some SSL libraries installed to do the hard
work. LWP itself doesn't have any SSL code.

If LWP finds a 3rd party SSL library, such as openssl, when it is
installed then it will be capable of fetching from https URLs. If not,
then you will see an error like 'unknown protocol' or similar.

This could well be different on winders et al.

HTH
Rich


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

Date: Thu, 22 Sep 2005 14:48:32 GMT
From: one man army <newsAT@screenlightDOT.com>
Subject: Re: https with LWP::UserAgent
Message-Id: <newsAT-8A4CCA.07503022092005@newsclstr02.news.prodigy.com>

Aha!  I am using Perl 5.8.1 on the FreeBSD derivative, Mac OS X/Darwin.
How do I install the SSL Library? I have a folder called /Library/Perl, 
then :
5.8.1
   File
   lwptut.pod
   lwpcook.pod
   Regexp
   Net
   LWP.pm
   LWP
   WWW
   URI.pm
   URI
   Bundle
   HTTP
   HTML
   darwin-thread-multi-2level
HTML-LinkExtractor-0.13
HTML-Tagset-3.04
HTML-Parser-3.45
URIC-2.02
libwww-perl-5.69
Regexp-Common-2.120
libnet-1.19
URI-1.35


In article <pan.2005.09.22.13.46.58.100503@zync.co.uk>,
 Richard Gration <richard@zync.co.uk> wrote:

> On Wed, 21 Sep 2005 17:47:09 +0000, one man army wrote:
> 
> > Hi All-
> > 
> >   I am an infrequent user of Perl, but have succeeded in a few endeavors.
> > I have a script that reads data from a series of web pages. But now I 
> > want to modify it to handle an HTTPS page.
> > 
> >   I looked briefly in UserAgent.pm
> 
> That way lies pain and death. Well, pain anyway. You haven't specified
> your OS, so I'll say how it is for mine, Linux.
> 
> Using LWP with the https protocol is as simple as
> 
> my $ua = LWP::UserAgent->new;
> my $req = HTTP::Request->new(GET => 'https://secure.tld');
> my $res = $ua->request($req);
> 
> The key on *nix is to have some SSL libraries installed to do the hard
> work. LWP itself doesn't have any SSL code.
> 
> If LWP finds a 3rd party SSL library, such as openssl, when it is
> installed then it will be capable of fetching from https URLs. If not,
> then you will see an error like 'unknown protocol' or similar.
> 
> This could well be different on winders et al.
> 
> HTH
> Rich


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

Date: Thu, 22 Sep 2005 07:53:50 -0400
From: "EvilOverlord" <evil666overlord@yahoo.co.uk>
Subject: Re: LWP::Simple and Cookies not working
Message-Id: <e70f400fdbe2b04d2c6f371f13a65adb@localhost.talkaboutprogramming.com>

Thanks for the advice, I'd love to not re-invent the wheel if I could avoid
it. 

Sadly, the perl ebay search modules are of little use to me as I need to
perform a <b>completed item</b> search.

The ebay search module for completed items was removed after ebay changed
their system to ensure you were logged in before searching for completed
items.

Non-completed item searches in current auctions, shops, etc do not have
the login restriction and hence the perl modules continue to work for
those.

Basically, the reason for wanting this is to write a small program that
takes a list of item titles and tells me the percentage chance of a sale,
average selling price and average listing price for each of the items
passed to it. To do this I must search for completed auctions, not current
ones.




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

Date: 22 Sep 2005 07:29:33 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Problem in Executing system command in a forking server
Message-Id: <dgtmgt$406$2@mamenchi.zrz.TU-Berlin.DE>

vikrant  <vikrantREMOVE@DELETEsaysnetsoft.com> wrote in comp.lang.perl.misc:
> hi
> 
> I am trying to store the return value of system command after execution
> in a forking server.
> 
> The command executes successfully

How do you know that?

> but returns "-1". In case of failure,
> it returns the same value 
> "-1", like when i am replacing "date" with "data" in system command.

Is "date" on the search path of the process that's trying to execute
it?

> From my understanding, it 
> should return -1 only in case of failure. How do go about distinguishing
> between a success and 
> failure call while using the system commnad?

See perldoc -f system.  Note the third paragraph beginning with "The
return value is..."

Anno
-- 
If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article.  Click on 
"show options" at the top of the article, then click on the 
"Reply" at the bottom of the article headers.


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

Date: Thu, 22 Sep 2005 17:38:50 +1000
From: Damian James <djames@thehub.com.au>
Subject: Re: Problem in Executing system command in a forking server
Message-Id: <slrndj4nsa.7gt.djames@stumble.qimr.edu.au>

On Thu, 22 Sep 2005 11:38:23 +0530, vikrant said:
> I am trying to store the return value of system command after execution in a forking server.
> 
> The command executes successfully but returns "-1". In case of failure, it returns the same value 
> "-1", like when i am replacing "date" with "data" in system command. From my understanding, it 
> should return -1 only in case of failure. How do go about distinguishing between a success and 
> failure call while using the system commnad?

Well, do you know what it returns on success?

perl -e 'printf "[%d]\n", system "date"'

> ...
>     my $sDatecmd=system("date");
>     $sNew_Socket->send($sDatecmd);

How about:

     $sNew_Socket->send($sDatecmd? "Failed" : "Succeded");

Though perhaps you actually wanted the *output* of the date
command? See perldoc -q "output of a command".

You might also care to try the builtins instead:

  perl -le 'print scalar localtime'

So the above would be

  my $date = scalar localtime;
  $sNew_Socket->send($date);

--Damian


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

Date: 22 Sep 2005 11:25:05 GMT
From: Villy Kruse <vek@station02.ohout.pharmapartners.nl>
Subject: Re: Problem in Executing system command in a forking server
Message-Id: <slrndj554g.2vu.vek@station02.ohout.pharmapartners.nl>

On Thu, 22 Sep 2005 11:38:23 +0530,
    vikrant <vikrantREMOVE@DELETEsaysnetsoft.com> wrote:


> hi
>
> I am trying to store the return value of system command after execution in a forking server.
>
> The command executes successfully but returns "-1". In case of failure, it returns the same value 
> "-1", like when i am replacing "date" with "data" in system command. From my understanding, it 
> should return -1 only in case of failure. How do go about distinguishing between a success and 
> failure call while using the system commnad?
>
> Code:-
> -----------------------------------------------------------------------------------
> #!/usr/bin/perl -w
> use strict;
> use IO::Socket;
> use IO::Select;
>
> $SIG{CHLD} = 'IGNORE';


This is the root of your problem.  It is imperative that SIG{CHLD} be set
back to default if you ever use system, backticks or open a pipe to a
program.  Otherwise the wait() called from these functions will wait for
all child processes to exit and then return -1 with errno set to ECHILD.


Villy


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

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


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