Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

like File::Fetch but not to filesystem?

0 views
Skip to first unread message

Peter Billam

unread,
Nov 27, 2009, 7:05:19 PM11/27/09
to
Greetings. I'd like to fetch a file designated by a URL, loading
it straight into a string of bytes rather than having to create
temporary files. File::Fetch offers a
fetch( [to => /my/output/dir/] )
method, which seems to mandate going to the filesystem. Is there
something similar which returns a scalar, or a filehandle that I
can read from ?

Regards, Peter

--
Peter Billam www.pjb.com.au www.pjb.com.au/comp/contact.html

J�rgen Exner

unread,
Nov 27, 2009, 7:34:34 PM11/27/09
to
Peter Billam <pe...@www.pjb.com.au> wrote:
>Greetings. I'd like to fetch a file designated by a URL, loading
>it straight into a string of bytes rather than having to create
>temporary files. File::Fetch offers a
> fetch( [to => /my/output/dir/] )
>method, which seems to mandate going to the filesystem. Is there
>something similar which returns a scalar, or a filehandle that I
>can read from ?

See 'perldoc -q HMTL':
"How do I fetch an HTML file?"
That FAQ really doesn't deal with HTML at all but with how to get a
resource that is identified by a URL.

jue

Randal L. Schwartz

unread,
Nov 27, 2009, 8:19:13 PM11/27/09
to contac...@www.pjb.com.au
>>>>> "Peter" == Peter Billam <pe...@www.pjb.com.au> writes:

Peter> Greetings. I'd like to fetch a file designated by a URL, loading
Peter> it straight into a string of bytes rather than having to create
Peter> temporary files.

use LWP::Simple;

my $bytes = get "http://example.com/some/url/here";

No temp file required.

--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<mer...@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion

Peter Billam

unread,
Nov 27, 2009, 8:40:46 PM11/27/09
to
On 2009-11-28, Randal L. Schwartz <mer...@stonehenge.com> wrote:
>>>>>> "Peter" == Peter Billam <pe...@www.pjb.com.au> writes:
>Peter> Greetings. I'd like to fetch a file designated by a URL,
>Peter> loading it straight into a string of bytes rather than
>Peter> having to create temporary files.

> use LWP::Simple;
> my $bytes = get "http://example.com/some/url/here";
> No temp file required.

and Juergen Exner wrote:
> See 'perldoc -q HMTL':
> "How do I fetch an HTML file?"

where indeed it says:
> # simplest version
> use LWP::Simple;
> $content = get($URL);

Many thanks, aptitude install libwww-perl
is the missing link I needed :-)

Thanks, regards, Peter

0 new messages