[31624] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2883 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Mar 22 21:09:28 2010

Date: Mon, 22 Mar 2010 18:09:07 -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           Mon, 22 Mar 2010     Volume: 11 Number: 2883

Today's topics:
    Re: case study: want to print redirects when LWP::UserA <john@castleamber.com>
        case study: want to print redirects when LWP::UserAgent <bennett@peacefire.org>
    Re: FAQ 5.17 Is there a leak/bug in glob()? <brian.d.foy@gmail.com>
    Re: FAQ 7.15 How can I pass/return a {Function, FileHan <ben@morrow.me.uk>
    Re: PDF::API2 underlining text <cartercc@gmail.com>
    Re: Terms of Use    (was Re: Perl HTML searching) sln@netherlands.com
    Re: Terms of Use <john@castleamber.com>
    Re: using Bot::BasicBot with private channels <olingaa@gmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Mon, 22 Mar 2010 17:18:49 -0600
From: John Bokma <john@castleamber.com>
Subject: Re: case study: want to print redirects when LWP::UserAgent makes a  request
Message-Id: <87mxy0ndwm.fsf@castleamber.com>

Bennett Haselton <bennett@peacefire.org> writes:

> I'm trying to figure out, if I have a LWP::UserAgent object and a
> HTTP::Request object, how I can use the user-agent to request the
> request object and print out a list of HTTP redirects that it
> encounters along the way.

my $response = $ua->get( $url );

returns a HTTP::Response

HTTP::Response documentation shows a method redirects, which "Returns a
list of redirect responses that lead up to ... The list order is oldest
first ..."


> But, that's actually not the question.  What I want to know is: How do
> more experienced Perl programmers find the answers to these questions
> when they need to get something done?

use YAML::Syck;
print Dump $response;

This shows a lot of info about $response
Knowing what the get method returns (to what it's blessed) and reading
the documentation.

> I keep encountering problems
> like this, reading the documentation, hitting a dead end, and having
> to post in a forum or ask a friend.  It's hard to believe that real
> Perl programmers would have to do this for every simple question like
> this, or nothing would ever get done.

Now and then I look at the source to understand what some things do. The
documentation is not always complete. Now and then I contact authors
with a request to update the documentation. On CPAN there is also the
possibility to add annotations.

-- 
John Bokma                                                               j3b

Hacking & Hiking in Mexico -  http://johnbokma.com/
http://castleamber.com/ - Perl & Python Development


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

Date: Mon, 22 Mar 2010 13:16:22 -0700 (PDT)
From: Bennett Haselton <bennett@peacefire.org>
Subject: case study: want to print redirects when LWP::UserAgent makes a  request
Message-Id: <017ac60c-e46a-4448-a6f3-adb1bbfc1199@f14g2000pre.googlegroups.com>

I'm trying to figure out, if I have a LWP::UserAgent object and a
HTTP::Request object, how I can use the user-agent to request the
request object and print out a list of HTTP redirects that it
encounters along the way.

But, that's actually not the question.  What I want to know is: How do
more experienced Perl programmers find the answers to these questions
when they need to get something done?  I keep encountering problems
like this, reading the documentation, hitting a dead end, and having
to post in a forum or ask a friend.  It's hard to believe that real
Perl programmers would have to do this for every simple question like
this, or nothing would ever get done.

Suppose you're an experienced Perl programmer but you don't know the
answer to this particular question.  I look first in the documentation
page UserAgent.html.  I see it says "The difference from request() is
that simple_request() will not try to handle redirects or
authentication responses. The request() method will in fact invoke
this method for each simple request it sends.", so I know about the
difference between those two.

The next thing that stands out is:
"$ua->redirect_ok( $request )
This method is called by request() before it tries to follow a
redirection to the request in $request. This should return a TRUE
value if this redirection is permissible."
It's not clear whether LWP::UserAgent calls this for *every* redirect,
or just the first one.  (Taken literally, the documentation says it
will only do it for the first one -- "before it tries to follow a
redirection to the request in $request".)  But still, that would mean
I'd have to create a subclass of LWP::UserAgent to override behavior
of this function.  I'm hoping there's something easier.

So that's where I give up and ask someone.  What would you do?  Is
there something in the documentation that would make it obvious to you
what to try next?  What do I need to train myself to look for?


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

Date: Mon, 22 Mar 2010 14:34:07 -0500
From: brian d foy <brian.d.foy@gmail.com>
Subject: Re: FAQ 5.17 Is there a leak/bug in glob()?
Message-Id: <220320101434074137%brian.d.foy@gmail.com>

In article <lnhbob53qf.fsf@nuthaus.mib.org>, Keith Thompson
<kst-u@mib.org> wrote:

> PerlFAQ Server <brian@theperlreview.com> writes:
> > 5.17: Is there a leak/bug in glob()?
> >
> >     Due to the current implementation on some operating systems, when you
> >     use the glob() function or its angle-bracket alias in a scalar context,
> >     you may cause a memory leak and/or unpredictable behavior. It's best
> >     therefore to use glob() only in list context.
> 
> How old is this FAQ?  Is the leak still there?

The FAQ is pretty old, but I don't know for sure if the leak is still
there. I'll see what I can find out.

Thanks;


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

Date: Sun, 21 Mar 2010 17:24:18 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: FAQ 7.15 How can I pass/return a {Function, FileHandle, Array, Hash, Method, Regex}?
Message-Id: <2b1i77-kvm1.ln1@osiris.mauzo.dyndns.org>


Quoth PerlFAQ Server <brian@theperlreview.com>:
> 
> 7.15: How can I pass/return a {Function, FileHandle, Array, Hash,
> Method, Regex}?
> 
>     With the exception of regexes, you need to pass references to these
>     objects.

Regexen are passed as references too. qr//, like [], {} and sub {},
returns a ref to the compiled regex rather than the regex itself.

Strictly speaking it *is* possible to pass a regex directly, but the
only way to create one from Perl is to scalar-deref a qr//, and before
5.12 you have to take a ref again before you can do anything with it, so
it's not terribly useful.

>         Notice how "qr//" allows flags at the end. That pattern was compiled
>         at compile time, although it was executed later. The nifty "qr//"
>         notation wasn't introduced until the 5.005 release. Before that, you
>         had to approach this problem much less intuitively. For example,
>         here it is again if you don't have "qr//":

I think this bit could go. Anyone writing for 5004 knows they haven't
got qr//, and knows what they have to do instead.

Ben



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

Date: Mon, 22 Mar 2010 09:54:35 -0700 (PDT)
From: ccc31807 <cartercc@gmail.com>
Subject: Re: PDF::API2 underlining text
Message-Id: <75af53d3-9f44-4994-9320-7583e50e547a@g19g2000yqe.googlegroups.com>

On Mar 20, 9:00=A0am, "Peter J. Holzer" <hjp-usen...@hjp.at> wrote:
> > 'Underlined' is not a property of the character, like 'bold' or
> > 'italic'. It's just a straight line stuck underneath the line of text.
> > (It's also *really* tacky and should be avoided in anything purporting
> > to be properly typeset.) I'm sure it's straightforward to find out wher=
e
> > the text begins and ends; then just move those two points down a point
> > or so and draw a line between them.

> I remember that GEM fonts

I remember using GEM on old Amstrad machines. They had the power
supply in the back of the monitor and had problems burning up. Still,
I like GEM, especially when the alternatives on clones was DOS 3.x.

As to the underlining, I omitted it from the documents and no one said
anything, so at this point no news is good news.

Thanks, CC.


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

Date: Mon, 22 Mar 2010 13:43:03 -0700
From: sln@netherlands.com
Subject: Re: Terms of Use    (was Re: Perl HTML searching)
Message-Id: <kijfq5hj8ql2v6hiqem86up5ehu41jmvfh@4ax.com>

On Sun, 21 Mar 2010 09:56:17 +0100, "Peter J. Holzer" <hjp-usenet2@hjp.at> wrote:

[snip]

>Don't know about the US, but in Europe "a composition of ordinary ...
>information" is more strongly protected by copyright law than "a movie,
>music, literrary art". Because while the former need to be "artful and
>unique" as you say (in Austrian law the term is "Werkshöhe"), no such
>restriction exists for databases. So if you if you compile a list of the
>students of your final year in high school, that's copyrighted. Same for
>the data on craigs list.
>

I would say a "list" is just that and nothing more, not copyrighted at
all. A list of students is not unique nor copyrighted. The published
year book is copyrighted as an entity, not the parts. A list of
credit card names and numbers are not copyrighted either and are not
published for legal reasons. Besides that, lists are not unique in the
sense that they are composed of common publicly obtained (private
information or not, but obtained from public sources) items that
idividually or collectively cannot be copyrighted. You just can't
say you have invented a unique color from 24-bit registers.

The point at which something becomes copyrightable is blurred.
A word/phrase in a book? Probably not. A sequential paragraph or two
in a book? Probably so. Its unique and highly unlikey to be randomly
duplicated. That is not the case of public information that can be
filterred to create a comparable list. In this case, the dimensions
of information are too easy to duplicate, unlike that of say a few
paragraphs of a book.

It is not likely that public information can be wrapped in a list
structure and its contents declared copyrighted. Copyright label is 
attached to everything in general. It doesen't even need to be filed
with the copyright office. When in doubt, just 'say' its copyrighted
in a flimsy 'Terms Of Use', then blast it out in an uncontrolled public
fashion. Yeah, thats legal to do, but it holds no weight - especially
when the listed items themselves are not copyrighted or trademarked,
and otherwise, specifically public or general-knowlege information in
nature.

-sln


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

Date: Mon, 22 Mar 2010 17:26:02 -0600
From: John Bokma <john@castleamber.com>
Subject: Re: Terms of Use
Message-Id: <87iq8ondkl.fsf@castleamber.com>

sln@netherlands.com writes:

> On Sun, 21 Mar 2010 09:56:17 +0100, "Peter J. Holzer" <hjp-usenet2@hjp.at> wrote:
>
> [snip]
>
>>Don't know about the US, but in Europe "a composition of ordinary ...
>>information" is more strongly protected by copyright law than "a
>>movie,

If this European law is the same as the Dutch Databanken-recht "database
law", a database is protected under that law if there has been put
substantial effort into the compilation of such a database. This is
*not* copyright however, it's a separate law.

> I would say a "list" is just that and nothing more, not copyrighted at
> all. A list of students is not unique nor copyrighted. 

Correct, and under the Dutch law such a list is only protected if there
has been put a substantial effort into its compilation. So there is
probably no way you can protect a list of 500 students, but most likely
you can if such a list has thousands and thousands of students, and
effort has been put into keeping the addresses of each student actual,
etc.

IANAL,

-- 
John Bokma                                                               j3b

Hacking & Hiking in Mexico -  http://johnbokma.com/
http://castleamber.com/ - Perl & Python Development


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

Date: Sun, 21 Mar 2010 06:03:07 -0700 (PDT)
From: Olinga <olingaa@gmail.com>
Subject: Re: using Bot::BasicBot with private channels
Message-Id: <f465dd85-58ec-4d0c-b54f-5d4c74c85246@q16g2000yqq.googlegroups.com>

On Mar 21, 2:11=A0am, Tad McClellan <ta...@seesig.invalid> wrote:
> You should always, yes always, check the return value from open.
>
> Nowadays, you should also use the 3-arg form of open() along
> with a lexical filehandle:

Tad - No disagreement.


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

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:

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

Back issues are available via anonymous ftp from
ftp://cil-www.oce.orst.edu/pub/perl/old-digests. 

#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 2883
***************************************


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