[30396] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1639 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jun 13 16:09:47 2008

Date: Fri, 13 Jun 2008 13:09:10 -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           Fri, 13 Jun 2008     Volume: 11 Number: 1639

Today's topics:
        converting Java code to Perl (using LWP?) PugetSoundSylvia@gmail.com
    Re: DirectoryIndex not working with AuthDBI <jcharth@gmail.com>
        Has anyone compiled HPUX::pstat under hpux 11.11 using  <damercer@comcast.net>
    Re: Has anyone compiled HPUX::pstat under hpux 11.11 us <ben@morrow.me.uk>
    Re: Has anyone compiled HPUX::pstat under hpux 11.11 us <damercer@comcast.net>
    Re: How to unpack long long ? xhoster@gmail.com
    Re: How to unpack long long ? xhoster@gmail.com
    Re: How to unpack long long ? <ben@morrow.me.uk>
    Re: How to unpack long long ? <tzz@lifelogs.com>
    Re: OT: SI units pat.norton@iname.com
        Regular Expression Help <scole954387@gmail.com>
    Re: Regular Expression Help <scole954387@gmail.com>
    Re: Regular Expression Help <danrumney@warpmail.net>
    Re: Simple scrape with perl on google news <greymausg@mail.com>
    Re: Simple scrape with perl on google news <danrumney@warpmail.net>
    Re: Unwanted output using croak with eval xhoster@gmail.com
    Re: Unwanted output using croak with eval <BLOCKSPAMfishfry@your-mailbox.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Fri, 13 Jun 2008 12:56:01 -0700 (PDT)
From: PugetSoundSylvia@gmail.com
Subject: converting Java code to Perl (using LWP?)
Message-Id: <a33f923b-5a15-4071-8318-e6b3ac7a086f@d19g2000prm.googlegroups.com>

Hello all,

I've been banging my head against the wall trying to get some code
working in Perl.  I'm assuming it will need to use the LWP module, and
I've gotten some basic things working with LWP, but not the whole
thing.

I have samples in Java, shown below.  I'm stuck at the
setRequestProperty. What's the equivalent in Perl, using LWP?

I would SO appreciate any pointers on this on.

Sylvia

    public TestLogin() throws IOException {
        if (Debug) System.out.println("TestLogin: Logging in...");
        /** Send the HTTPS request */
        URL url_login = new URL(Profile.Protocol+"://"+    /** i.e,
either http or https */
            Profile.Hostname+"/api/login.php"+             /** the
actual website, like TestSite.org  */
            "?name="+Profile.UserID+                       /** site
specific parameter  */
            "&pass="+Profile.Password+                     /** site
specific parameter  */
            "&service_type="+Profile.ServiceType);         /** site
specific parameter  */
        URLConnection urlcon_login = url_login.openConnection();
        String auth = Profile.FWUser+":"+Profile.FWPassword;
        urlcon_login.setRequestProperty("Authorization", "Basic "+
Base64.encode(auth.getBytes()));
        /** Get the HTML response and parse it */
        BufferedReader inbuf_login;
        inbuf_login = new BufferedReader(
        new InputStreamReader(urlcon_login.getInputStream()));
        if (inbuf_login != null) parse(inbuf_login);
        inbuf_login.close();
        if (Debug) System.out.println("TestLogin: Login completed
(Session ID = " + Profile.SessionID+")");
    }



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

Date: Fri, 13 Jun 2008 08:55:14 -0700 (PDT)
From: joe <jcharth@gmail.com>
Subject: Re: DirectoryIndex not working with AuthDBI
Message-Id: <8087252e-e27f-431e-8af7-ee682b357ea3@a1g2000hsb.googlegroups.com>

Got it to work. I consolidated all directives for the parent and child
folder and the problem went away.

On Jun 12, 4:32 pm, joe <jcha...@gmail.com> wrote:
> On Jun 12, 3:21 pm, smallpond <smallp...@juno.com> wrote:
>
> > joe wrote:
> > > Hello I manage to get AuthDBI to work but now the directory does not
> > > recognize index.php or index.htm when typingwww.domain.com i get

> > > 403 and I get a list of files if I add  Options Indexes. I believe it
> > > could be related to not having perlhander but if I add apache::asp as
> > > the perlhandler it does not work. Any suggestions? Thanks
>
> > 403 Access Forbidden - not a perl problem.  Look at the web server error logs.
>
> Thanks for the reply. I dont see any related error in the logs. But if
> I type something likewww.domain.com/index.htm
> it works. If I typewww.domain.com/orwww.domain.comit does not
> display the   DirectoryIndex index.php or index.htm or index.html
> files by defaul. The directoryindex directive works everywhere but not
> in the authDBI protected folder. Ill try to disable other modules may
> be it is just a conflict or a priority issue.
>
>
>
> > ** Posted fromhttp://www.teranews.com**



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

Date: Fri, 13 Jun 2008 12:39:02 -0500
From: "Dan Mercer" <damercer@comcast.net>
Subject: Has anyone compiled HPUX::pstat under hpux 11.11 using aCC
Message-Id: <6Iednbte-bEvLc_VnZ2dnUVZ_gidnZ2d@comcast.com>

when I do the "perl Makefile.PL" I get a makefile for gcc which doesn't 
build:

    cc1: error: unrecognized option '-Wdeclaration-after-statement'

going into the Makefile to change gcc to aCC just creates more errors.

   $ gcc --version
   gcc (GCC) 3.3.2

To compound matters our perl used to be located in /usr/local but was moved 
to
another directory path.  Ironically,  I wrote a pstat program some years ago 
(under
HP-UX 10.20 that was later ported to 10.30 and 11.01) but I haven't gotten 
it
to compile under 11.11 (haven't really had the time to play with it) and was 
hoping this
would give me some of the same capability.

BTW,  can anyone explain why CPAN testers would try to test this very 
specific
hpux module under Linux and Solaris?  Is it just an automated submission 
process?
HPUX is very peculiar in it's process table handling.

TIA,

Dan Mercer



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

Date: Fri, 13 Jun 2008 19:36:53 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Has anyone compiled HPUX::pstat under hpux 11.11 using aCC
Message-Id: <5brai5-1de.ln1@osiris.mauzo.dyndns.org>

[f'ups set to clpm]

Quoth "Dan Mercer" <damercer@comcast.net>:
> when I do the "perl Makefile.PL" I get a makefile for gcc which doesn't 
> build:
> 
>     cc1: error: unrecognized option '-Wdeclaration-after-statement'
> 
> going into the Makefile to change gcc to aCC just creates more errors.

You have to build perl modules with the same compiler used to build your
perl.

>    $ gcc --version
>    gcc (GCC) 3.3.2

If you have gcc why are you trying to build with aCC?

> To compound matters our perl used to be located in /usr/local but was
> moved to another directory path.

That is a really bad idea. While it is possible to build perl so it's
relocatable, it's unlikely your version was built that way.

> BTW, can anyone explain why CPAN testers would try to test this very
> specific hpux module under Linux and Solaris? Is it just an automated
> submission process? HPUX is very peculiar in it's process table
> handling.

Yes, it's automated. CPAN testers test all new uploads. You can get NA
reports instead of FAIL reports if you put something like

    $^O eq 'HP-UX' or die "OS unsupported";
    
in your Makefile.PL (the exact message *is* important).

Ben

-- 
"Faith has you at a disadvantage, Buffy."
"'Cause I'm not crazy, or 'cause I don't kill people?"
"Both, actually."
                                                         [ben@morrow.me.uk]


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

Date: Fri, 13 Jun 2008 14:13:23 -0500
From: "Dan Mercer" <damercer@comcast.net>
Subject: Re: Has anyone compiled HPUX::pstat under hpux 11.11 using aCC
Message-Id: <vJqdncto4cxSW8_VnZ2dnUVZ_srinZ2d@comcast.com>

"Ben Morrow" <ben@morrow.me.uk> wrote in message 
news:5brai5-1de.ln1@osiris.mauzo.dyndns.org...
> [f'ups set to clpm]
>
> Quoth "Dan Mercer" <damercer@comcast.net>:
>> when I do the "perl Makefile.PL" I get a makefile for gcc which doesn't
>> build:
>>
>>     cc1: error: unrecognized option '-Wdeclaration-after-statement'
>>
>> going into the Makefile to change gcc to aCC just creates more errors.
>
> You have to build perl modules with the same compiler used to build your
> perl.
>
>>    $ gcc --version
>>    gcc (GCC) 3.3.2
>
> If you have gcc why are you trying to build with aCC?

Because gcc didn't work.  It's likely our perl was not built locally and was 
either
gotten through HP or the HP-UX Porting Archive,  so compiling with the same
exact version of the compiler would not be possible.  Indeed,  a check of 
perl -V
indicates gccversion 4.2.0,  so it was almost certainly from the Porting 
Archive.
So,  do I need to get 4.2.0?  And will it work even then?

Are you truly a Buffy fan?  The wife and I got into the Buffverse when we 
happened
to catch the reruns of Angel on TNT from the first episode and got hooked.
Tonight we have a special treat - two episodes we missed before (the DVR
giveth and the DVR taketh away) featuring Faith.

Thanks,

Dan Mercer

>
>> To compound matters our perl used to be located in /usr/local but was
>> moved to another directory path.
>
> That is a really bad idea. While it is possible to build perl so it's
> relocatable, it's unlikely your version was built that way.
>
>> BTW, can anyone explain why CPAN testers would try to test this very
>> specific hpux module under Linux and Solaris? Is it just an automated
>> submission process? HPUX is very peculiar in it's process table
>> handling.
>
> Yes, it's automated. CPAN testers test all new uploads. You can get NA
> reports instead of FAIL reports if you put something like
>
>    $^O eq 'HP-UX' or die "OS unsupported";
>
> in your Makefile.PL (the exact message *is* important).
>
> Ben
>
> -- 
> "Faith has you at a disadvantage, Buffy."
> "'Cause I'm not crazy, or 'cause I don't kill people?"
> "Both, actually."
>                                                         [ben@morrow.me.uk]




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

Date: 13 Jun 2008 15:51:30 GMT
From: xhoster@gmail.com
Subject: Re: How to unpack long long ?
Message-Id: <20080613115132.073$oZ@newsreader.com>

Golan <ghadad@gmail.com> wrote:
> How do i unpack "long long" int  type ( 8 bytes )  ?

Whose long long?  You can look into either l! or q.

>
> this unpack("l8",$var) returns spaces .

That is trying to unpack 8 separate longs, not one 8-byte long long.

> but unpack("l4,substr($var,4)) returns the correct value .

That is a syntax error.

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.


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

Date: 13 Jun 2008 15:59:45 GMT
From: xhoster@gmail.com
Subject: Re: How to unpack long long ?
Message-Id: <20080613115947.349$sA@newsreader.com>

Ben Morrow <ben@morrow.me.uk> wrote:
> Quoth Ted Zlatanov <tzz@lifelogs.com>:
> > On Thu, 12 Jun 2008 18:20:55 +0100 Ben Morrow <ben@morrow.me.uk> wrote:
> >
> > BM> Quoth Golan <ghadad@gmail.com>:
> > >> How do i unpack "long long" int  type ( 8 bytes )  ?
> >
> > BM> 'q'. Note that your perl needs to be built with 64bit integers.
> >
> > That seems like an unnecessary restriction.  Is it really impossible
> > for a 32-bit Perl to decode 64-bit numbers?  We know the endianness, is
> > there anything else needed?
>
> Err... a type to hold the value in?

It could return the answer as a PV holding a string representation of the
number, with empty NV and IV slots.  If the NV or IV slots need to be used
later on, it would be converted the way Perl always does such conversions.

> While you can hold numbers greater
> than 2**32 in a NV, NVs only have 53 bits of precision (or, at least,
> they do here) so they can't hold values up to 2**64 with integer
> precision.
>
> If you know the endianness and know the value will be small, or if you
> use bigint, you can easily unpack as two longs and combine them.

Or it *could* do it for you.  :)

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.


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

Date: Fri, 13 Jun 2008 17:24:07 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: How to unpack long long ?
Message-Id: <7ijai5-ht8.ln1@osiris.mauzo.dyndns.org>


Quoth Ted Zlatanov <tzz@lifelogs.com>:
>
> If bigint is a pragma now, why not change pack/unpack to DTRT with `q'
> on 32-bit when bigint is in use?  It seems much nicer than just giving
> up (though the slowdown might be unexpected for the end user, so perhaps
> pack/unpack should be overridden only on demand).

bigint support is... imperfect. The only thing actually changed is the
representation of literal numeric values specified in the source; this
will propagate into other values through arithmetic overloading. Even
when bigint is in effect, unpack doesn't return bigint values:

    ~% perl -Mbigint -le'print ref unpack "l", pack "l", 63'

    ~% perl -Mbigint -le'print ref 0 + unpack "l", pack "l", 63'
    Math::BigInt

and pack will cast bigints to IVs (using '0+' overloading) before
packing, so you can never pack a value larger than an IV. The only way
around this would be for perl to support a complete set of 'packl',
'packq', &c. overloads, which is probably not worth it.

Of course, if you wish to write Math::BigInt::Pack, with appropriate
exports, you're more than welcome... :).

Ben

-- 
        I must not fear. Fear is the mind-killer. I will face my fear and
        I will let it pass through me. When the fear is gone there will be 
        nothing. Only I will remain.
ben@morrow.me.uk                                          Frank Herbert, 'Dune'


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

Date: Fri, 13 Jun 2008 13:18:59 -0500
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: How to unpack long long ?
Message-Id: <863anh8agc.fsf@lifelogs.com>

On Fri, 13 Jun 2008 17:24:07 +0100 Ben Morrow <ben@morrow.me.uk> wrote: 

BM> Quoth Ted Zlatanov <tzz@lifelogs.com>:
>> 
>> If bigint is a pragma now, why not change pack/unpack to DTRT with `q'
>> on 32-bit when bigint is in use?  It seems much nicer than just giving
>> up (though the slowdown might be unexpected for the end user, so perhaps
>> pack/unpack should be overridden only on demand).

BM> bigint support is... imperfect. The only thing actually changed is the
BM> representation of literal numeric values specified in the source; this
BM> will propagate into other values through arithmetic overloading. Even
BM> when bigint is in effect, unpack doesn't return bigint values:

BM>     ~% perl -Mbigint -le'print ref unpack "l", pack "l", 63'

BM>     ~% perl -Mbigint -le'print ref 0 + unpack "l", pack "l", 63'
BM>     Math::BigInt

BM> and pack will cast bigints to IVs (using '0+' overloading) before
BM> packing, so you can never pack a value larger than an IV. The only way
BM> around this would be for perl to support a complete set of 'packl',
BM> 'packq', &c. overloads, which is probably not worth it.

BM> Of course, if you wish to write Math::BigInt::Pack, with appropriate
BM> exports, you're more than welcome... :).

I would if I knew the Perl internals.  Do you think it's realistic to
attempt it otherwise?  I've always worked above that level mostly due to
lack of time to explore deeper :)

For pack/unpack it seems sufficient to convert every 64-bit number to
two 32-bit numbers and encode those sequentially (and vice versa).  So
only the `q' template needs to be modified.  Hmm, maybe this is getting
into perl5-* list land and I should go ask there.

Ted


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

Date: Fri, 13 Jun 2008 10:20:51 -0700 (PDT)
From: pat.norton@iname.com
Subject: Re: OT: SI units
Message-Id: <c2e9bd20-b006-4812-b01d-73c9812dbe4b@s50g2000hsb.googlegroups.com>

J=FCrgen Exner wrote:
>Oh, come on. Don't be so hard. They are making great progress.

Indeed. The US military has had a large part to play in normalising
the use of the metric system, at least for units of distance.


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

Date: Fri, 13 Jun 2008 09:01:25 -0700 (PDT)
From: "S. Cole" <scole954387@gmail.com>
Subject: Regular Expression Help
Message-Id: <326ab1cd-b649-4946-894b-af04d5b5bbf8@e53g2000hsa.googlegroups.com>

Hey,

Can someone help create one/two regular expression(s) for this?


code:
<table width=100%% class='list'
cellpadding=2 cellspacing=0>
<tr bgcolor='#E5ECF9'>
<td colspan=3><font size=-1>&nbsp;<b>Languages</b></font></td></tr><tr
><td align=right valign=center  width=1px style='padding: 5 3 5 10;
border-left: hidden; border-bottom: hidden;'>
<font size=-1>1.</font></td>
<td align=left valign=center  style='border-bottom: hidden;'
style='padding: 5 3 5 3'><font size=-1>English</font></td><td
valign=center style='padding: 2 3 2 3; border-right: hidden; border-
bottom: hidden;' ><table class=bar cellspacing=0 width=100
height=4><td bgcolor=4684ee ></table>
<table class=bar cellspacing=0 width=30 height=4><td bgcolor=dc3912 ></
table>
</td>
</tr>
</table>


I want to pull out the width value located here:

<table class=bar cellspacing=0 width=100 height=4>

and

<table class=bar cellspacing=0 width=30 height=4>


It doesn't matter if it's done in one expression and the result is
separated with a ,  (ie results = 100,30)  or two expressions... one
putting the width value of one and the other pulling the width value
of the other.

If anyone can help, it would be greatly appreciated.

Shannon


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

Date: Fri, 13 Jun 2008 09:07:11 -0700 (PDT)
From: "S. Cole" <scole954387@gmail.com>
Subject: Re: Regular Expression Help
Message-Id: <ede49024-6aef-463f-b99b-c9a0574b4239@m73g2000hsh.googlegroups.com>

I forgot to mention.. the code

 <table class=bar cellspacing=0 width=xx height=4>

is mentioned multiple times throughout the entire page... so the
expression can't just take that code only and extract it...

It has to somehow reference the section (english) of the page as well.

Shannon

30 height=4>

On Jun 13, 2:01 pm, "S. Cole" <scole954...@gmail.com> wrote:
> Hey,
>
> Can someone help create one/two regular expression(s) for this?
>
> code:
> <table width=100%% class='list'
> cellpadding=2 cellspacing=0>
> <tr bgcolor='#E5ECF9'>
> <td colspan=3><font size=-1>&nbsp;<b>Languages</b></font></td></tr><tr><td align=right valign=center  width=1px style='padding: 5 3 5 10;
>
> border-left: hidden; border-bottom: hidden;'>
> <font size=-1>1.</font></td>
> <td align=left valign=center  style='border-bottom: hidden;'
> style='padding: 5 3 5 3'><font size=-1>English</font></td><td
> valign=center style='padding: 2 3 2 3; border-right: hidden; border-
> bottom: hidden;' ><table class=bar cellspacing=0 width=100
> height=4><td bgcolor=4684ee ></table>
> <table class=bar cellspacing=0 width=30 height=4><td bgcolor=dc3912 ></
> table>
> </td>
> </tr>
> </table>
>
> I want to pull out the width value located here:
>
> <table class=bar cellspacing=0 width=100 height=4>
>
> and
>
> <table class=bar cellspacing=0 width=30 height=4>
>
> It doesn't matter if it's done in one expression and the result is
> separated with a ,  (ie results = 100,30)  or two expressions... one
> putting the width value of one and the other pulling the width value
> of the other.
>
> If anyone can help, it would be greatly appreciated.
>
> Shannon



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

Date: Fri, 13 Jun 2008 12:16:08 -0400
From: Dan Rumney <danrumney@warpmail.net>
Subject: Re: Regular Expression Help
Message-Id: <48529d3a$0$31724$4c368faf@roadrunner.com>

S. Cole wrote:
[snip]
> 
> It doesn't matter if it's done in one expression and the result is
> separated with a ,  (ie results = 100,30)  or two expressions... one
> putting the width value of one and the other pulling the width value
> of the other.
> 
> If anyone can help, it would be greatly appreciated.
> 
> Shannon

I've not used this module, but perhaps HTML::DOM (available on CPAN) 
might be a more appropriate fit than using regular expressions.

If you're trying to pull this information programatically, that suggests 
to me that you're probably not authoring the source itself. So you've 
not control over it's precise format (whitespace, use of FONT elements, etc)

Using HTML::DOM might be your best bet for ensuring that you can pull 
out the relevant information without getting broken by changes in the HTML.


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

Date: 13 Jun 2008 16:26:09 GMT
From: greymaus <greymausg@mail.com>
Subject: Re: Simple scrape with perl on google news
Message-Id: <slrng558d3.ho1.greymausg@maus.org>

On 2008-06-13, greymaus <greymausg@mail.com> wrote:
>>
>> Can anybody give me a hand and provide me the code?
>>
>> If you can provide me the code where I can configure the variables:
>>
>> "URL"
>> "search string"
>> "target file"
>>
>> and I can get it running ( I have a website with full perl
>> capabilities) on my own, you get US$10 to a paypal account. ;-)
>>
>> Thanx, -n
>
> 1)
> You can do that very easily with the libwww modules, or more upmarket
> WWW::Mechanize. Read them up.
>
> 2) Google will _not_ like that. And Google is one of the wealthiest
> enteties on the planet. 
>
> 3) Getting too many results down too quickly will have your _real_ (URL)
> address blocked either for a short or long period from Google.
>
> send an unmungable munged email account.
>
>
Source of a sample News.google.com page weighs in at 180k
(like the main Google page), news.google.com is a javascript
mess. And those do not do javascript; 
HOWEVER;

#!/usr/bin/perl -w
use WWW::Mechanize;
$search_string=$ARGV[0];
print "$search_string";
$start=10;
open T, ">>.gnewslog" or die "No .gnewslog\n";

$mech=WWW::Mechanize->new(cookie_jar=>undef);
$mech->agent_alias("Windows IE 6");
$mech->get("http://www.news.google.com/news?hl=en&ned=us&q=$search_string&btnG=Search");
@links=$mech->links();
foreach $j (@links){
	$p=$j->url_abs();
	unless (($p=~/google/) || ($p=~/java/)){
	print T "$p\n";}
	}
$index=$start+10;
for($start=10;$start>$index;$start+=10){
$mech->get("http://www.news.google.com/news?hl=en&ned=us&q=$search_string&btnG=Search&start=$start");
@links=$mech->links();
foreach $j (@links){
	$p=$j->url_abs();
	unless (($p=~/google/) || ($p=~/java/)){
	print T  "$p\n";}
	}
sleep 10;	
$index+=10;
}
close T;

Anyway, the rest is left to the student.





-- 
Greymaus
The Republic says \"No\"
Big Ian for president.


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

Date: Fri, 13 Jun 2008 13:00:58 -0400
From: Dan Rumney <danrumney@warpmail.net>
Subject: Re: Simple scrape with perl on google news
Message-Id: <4852a7bd$0$31720$4c368faf@roadrunner.com>

greymaus wrote:
> On 2008-06-13, jjquery <nevenbartel@gmail.com> wrote:
  [snip]
> 
> 1)
> You can do that very easily with the libwww modules, or more upmarket
> WWW::Mechanize. Read them up.
> 
> 2) Google will _not_ like that. And Google is one of the wealthiest
> enteties on the planet. 

Confirmed by their Terms of Service:

5.3 You agree not to access (or attempt to access) any of the Services 
by any means other than through the interface that is provided by 
Google, unless you have been specifically allowed to do so in a separate 
agreement with Google. You specifically agree not to access (or attempt 
to access) any of the Services through any automated means (including 
use of scripts or web crawlers) and shall ensure that you comply with 
the instructions set out in any robots.txt file present on the Services.

http://www.google.com/accounts/TOS

> 
> 3) Getting too many results down too quickly will have your _real_ (URL)
> address blocked either for a short or long period from Google.
> 

I'm guessing that what the OP is trying to do is measure some-thing, 
-one or event's impact on daily news, so I'm guessing they won't be 
hitting Google at high frequency. Unless, of course, they're sending 
lots of different search strings... in which case the probably will 
catch Google's attention.

Perhaps a more appropriate approach to solving the OP's business problem 
would be to look at the services Google already provides.

Google Alerts, perhaps?


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

Date: 13 Jun 2008 15:39:47 GMT
From: xhoster@gmail.com
Subject: Re: Unwanted output using croak with eval
Message-Id: <20080613113949.034$Zq@newsreader.com>

fishfry <BLOCKSPAMfishfry@your-mailbox.com> wrote:
> Consider this program:
>
> #!/usr/local/bin/perl -w
> use strict;
>
> use Carp;
>
> foo();
> print "done\n";
>
> sub foo {
>     eval {
>         bar();
>     };
>     print 'In foo(), following eval ... $@', " = $@\n";
> }
>
> sub bar {
>     croak "croaking in bar()\n";
> }
>
> Clearly the intent is that foo() wants to handle the case of bar()
> failing. Yet, this program produces the output:
>
> In foo(), following eval ... $@ = croaking in bar()
>  at ./err2 line 17
>         main::bar() called at ./err2 line 11
>         eval {...} called at ./err2 line 10
>         main::foo() called at ./err2 line 6
>
> done
>
> Is there a way to suppress the output of croak?

In this case, there is no output of croak.  Due to the eval, croak stuffs a
message into $@.  You print the contents of $@.


> Clearly this is a
> situation where I want to handle the failure myself, and not show this
> croak output to the enduser.

If you don't want the contents of $@ printed, then don't do print it.  It
doesn't get much simpler than that!

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.


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

Date: Fri, 13 Jun 2008 10:12:28 -0700
From: fishfry <BLOCKSPAMfishfry@your-mailbox.com>
Subject: Re: Unwanted output using croak with eval
Message-Id: <BLOCKSPAMfishfry-69DE3C.10122813062008@comcast.dca.giganews.com>

In article <20080613113949.034$Zq@newsreader.com>, xhoster@gmail.com 
wrote:

> fishfry <BLOCKSPAMfishfry@your-mailbox.com> wrote:
> > Consider this program:
> >
> > #!/usr/local/bin/perl -w
> > use strict;
> >
> > use Carp;
> >
> > foo();
> > print "done\n";
> >
> > sub foo {
> >     eval {
> >         bar();
> >     };
> >     print 'In foo(), following eval ... $@', " = $@\n";
> > }
> >
> > sub bar {
> >     croak "croaking in bar()\n";
> > }
> >
> > Clearly the intent is that foo() wants to handle the case of bar()
> > failing. Yet, this program produces the output:
> >
> > In foo(), following eval ... $@ = croaking in bar()
> >  at ./err2 line 17
> >         main::bar() called at ./err2 line 11
> >         eval {...} called at ./err2 line 10
> >         main::foo() called at ./err2 line 6
> >
> > done
> >
> > Is there a way to suppress the output of croak?
> 
> In this case, there is no output of croak.  Due to the eval, croak stuffs a
> message into $@.  You print the contents of $@.
> 
> 
> > Clearly this is a
> > situation where I want to handle the failure myself, and not show this
> > croak output to the enduser.
> 
> If you don't want the contents of $@ printed, then don't do print it.  It
> doesn't get much simpler than that!
> 


OOPS! Operator error.

Thanks all.


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

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 V11 Issue 1639
***************************************


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