in reply to Pulling HTML from a remote site and writing a portion of it to a file on server

You don't say what environment this is working in. Is this a standalone Perl application? Anyway, opening the file for output would help (you're opening it for input). And if this is in a CGI, you might try using CGI::Carp.

Also, you're processing $data, but not setting it anywhere. Did you mean to use $_ instead?

  • Comment on Re: Pulling HTML from a remote site and writing a portion of it to a file on server

Replies are listed 'Best First'.
Re: Re: Pulling HTML from a remote site and writing a portion of it to a file on server
by Whitey (Novice) on Jun 23, 2001 at 22:43 UTC
    This is running on Unix. It is a script that is called from a cron job.Here is an updated script. Can you offer some help? Nothing is writtten to the file.
    #!/usr/bin/perl use strict; use LWP::Simple; use LWP::UserAgent; my $data = get("http://www.cyrusoilandgas.com"); my ($wanted) = $data =~ /<!---------------PETROLEUM----------------->\ +s*(.*)\s*<map name="BbgELogin2">/s; open (FH,"./file.txt") ||die"$!"; print FH $data; close FH;
      This is because of your open. Try:
      open(FH, ">file.txt") || die "$!\n";

      BTW, didn't you post your node twice?