Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: LWP::UserAgent with development website

by TheHobbit (Pilgrim)
on Sep 18, 2004 at 12:32 UTC ( [id://391985]=note: print w/replies, xml ) Need Help??


in reply to LWP::UserAgent with development website

Hi,

Just an idea, but it will not surprise me if it was the good one. The problem could be in using a relative path to get the file. The path is relative to the current working directory of the Apache process handling your request, and this will almost certainly be not what you think it is. Try replacying the relative path with the absolute one. Moreover, using relative paths is almost always a BadThing, exactly because you cannot know what would you get at runtime.

Using cat, while strictly possible, may not be advisable. The slurp solution proposed, eg.

open FOO,$path; print <FOO>

are better, but they ask for the interpreter to slurp the whole file before sending it. If the file is relatively small this is not a problem, and the above solution is good, even if this one

{ local $/; open FOO,$path; $text = readline FOO; close FOO; } print $text;

is better IMHO.

But if the file is big then:

print while (<FOO>);

will likely be a better idea.

Hoping it wil help.

Greetings


Leo TheHobbit

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://391985]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (10)
As of 2024-03-28 12:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found