By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,967 Members | 1,687 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,967 IT Pros & Developers. It's quick & easy.

Perl equiv to PHP file()

P: n/a
(Slightly OT.) Does anybody here who works in both PHP and Perl happen to
know whether there is a Perl equivalent to PHP's file(url)? I need to get
the HTML output of a file as served through HTTP into some form so that I
can write it locally (on the same host machine) as static HTML, and some
complicated facts about permissions on the machine I'm working on may make
it necessary to work through Perl for this part rather than PHP. I've
already posted to comp.lang.perl.misc, but it then occurred to me to post
here as well, just in case somebody here might know. Thanks!

(It's a long story, but some of it is that the PHP files stored on the same
host as HTML and Perl files are served by a distinct server. As things
stand now, a PHP that calls fopen() will give me an [onscreen] error because
of lack of permission. The administrator may or may not give me permission
to have a PHP script write an HTML file to the disk, or she may not know how
to allow permissions. She is also extremely busy and it may take her a long
time even to discuss it, and I need to get this thing running soon. This is
a Windows machine, BTW. The Perl scripts are served by the standard server,
and I'm pretty sure that Perl scripts are allowed to write files.)

Amittai Aviram

Jul 16 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
On Mon, 18 Aug 2003 13:49:04 -0400 in
<message-id:bh************@ID-124651.news.uni-berlin.de>
"Amittai Aviram" <am*****@amittai.com> wrote:
(Slightly OT.) Does anybody here who works in both PHP and Perl
happen to know whether there is a Perl equivalent to PHP's file(url)?
I need to get
the HTML output of a file as served through HTTP into some form so
that I can write it locally (on the same host machine) as static
HTML, and some complicated facts about permissions on the machine I'm
working on may make it necessary to work through Perl for this part
rather than PHP. I've already posted to comp.lang.perl.misc, but it
then occurred to me to post here as well, just in case somebody here
might know. Thanks!

Look at the LWP::Simple module and LWP::UserAgent module. Does what
you're after. AFAIK, there's no "nice easy" function wrapper for it:
use LWP::UserAgent;

[ ... ]

my $user_agent = LWP::UserAgent->new;
my $url = $domain . $def_remote;
my $res = $user_agent->request(HTTP::Request->new(GET => $url),
This is a small snippet of some Perl code I used to retrieve Zip files
from my AV vendor. The $url can be a page rather than a file though =)
HTH.

Regards,

Ian

--
Ian.H [Design & Development]
digiServ Network - Web solutions
www.digiserv.net | irc.digiserv.net | forum.digiserv.net
Programming, Web design, development & hosting.
Jul 16 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.