Perl equiv to PHP file()

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Amittai Aviram

    Perl equiv to PHP file()

    (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



  • Ian.H [dS]

    #2
    Re: Perl equiv to PHP file()

    On Mon, 18 Aug 2003 13:49:04 -0400 in
    <message-id:bhr3ik$28ld9 $1@ID-124651.news.uni-berlin.de>
    "Amittai Aviram" <amittai@amitta i.com> wrote:
    [color=blue]
    > (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![/color]


    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.ne t | forum.digiserv. net
    Programming, Web design, development & hosting.

    Comment

    Working...