in reply to Read webpage into a variable

What does the "html extension" have to do with it?

Have you tried using get()?

Also see WWW::Mechanize and RFC 2616.

Replies are listed 'Best First'.
Re^2: Read webpage into a variable
by liverpaul (Acolyte) on Nov 21, 2011 at 09:23 UTC
    Yeah, I've used get() but it didn't work, so I assumed (maybe incorrectly?) that it was because the webpage doesn't have an extension.

      So maybe consider investigating how it "didn't work".

        By saying it "didn't work" I mean it doesn't respond. I don't get any messages that give me a hint (I'm using use warnings; and use diagnostics;). Update, solution:
        The problem was with my function.
        sub extract_html_to_temp_file #url, path&file { my $temp_var = ""; my $url = $_[0]; chomp($url); my $filename = $_[1]; chomp($filename); open(OUTPUT_FILE,">$filename") or die "COULDN'T OPEN FILE!!!, $!\n +"; $_ = get($url);#read HTML file contents into variable $temp_var = $_; print OUTPUT_FILE $temp_var; close(OUTPUT_FILE); }
        After the line $temp_var = $_; I had several lines of code that stripped the string of things I didn't want, eg. $temp_var = s/ / /g; etc. I have no idea why this would be a problem, but once I removed these lines the function worked.
        The fact that my function worked for webpages with an extension and not for webpages without an extension caused me to look for the wrong kind of solution.
        Thanks for the reply :-)