Home > Archive > PERL Beginners > May 2006 > No Such File Error on Simple Scrape
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
No Such File Error on Simple Scrape
|
|
| kc68@cornell.edu 2006-05-22, 7:00 pm |
| When I execute the script below, I get the error message "No such file or
directory at simple2.pl line 21." Line 21 is the Open OUT statement.
This script parallels a tutorial script that does work and I don't see the
error. It does print to the screen if I comment out the Open OUT line.
Thanks in advance.
#!/bin/perl
use strict;
use WWW::Mechanize;
my $output_dir = "c:/training/bc";
my $starting_url = "http://clerk.house.gov/members/olmbr.html";
my $browser = WWW::Mechanize->new();
$browser->get( $starting_url );
$browser->submit();
{
open OUT, ">output_dir/simple2.html" or die "Can't open file: $!";
print OUT $browser->content;
close OUT;
}
close PAGE;
print $browser->content;
| |
| Timothy Johnson 2006-05-22, 7:00 pm |
|
One simple thing you might want to start doing is including the filename
in your error message. Quite often this message means that either
you're not in the starting directory you think you're in or part of your
filename is being interpreted as something other than what you intended.
my $file =3D "output_dir/simple2.html";
open OUT,">$file" or die "Can't open '$file' for writing: $!";
-----Original Message-----
From: kc68@cornell.edu [mailto:kc68@cornell.edu]=20
Sent: Monday, May 22, 2006 2:50 PM
To: beginners@perl.org
Subject: No Such File Error on Simple Scrape
When I execute the script below, I get the error message "No such file
or =20
directory at simple2.pl line 21." Line 21 is the Open OUT statement. =20
This script parallels a tutorial script that does work and I don't see
the =20
error. It does print to the screen if I comment out the Open OUT line.
Thanks in advance.
<snip>
open OUT, ">output_dir/simple2.html" or die "Can't open file: $!";
<snip>
| |
| Jaime Murillo 2006-05-22, 7:00 pm |
| On Monday 22 May 2006 14:49, kc68@cornell.edu wrote:
> When I execute the script below, I get the error message "No such file or
> directory at simple2.pl line 21." Line 21 is the Open OUT statement.
> This script parallels a tutorial script that does work and I don't see the
> error. It does print to the screen if I comment out the Open OUT line.
> Thanks in advance.
>
> #!/bin/perl
>
> use strict;
>
> use WWW::Mechanize;
>
> my $output_dir = "c:/training/bc";
>
> my $starting_url = "http://clerk.house.gov/members/olmbr.html";
>
> my $browser = WWW::Mechanize->new();
>
> $browser->get( $starting_url );
>
>
> $browser->submit();
>
>
> {
>
> open OUT, ">output_dir/simple2.html" or die "Can't open file: $!";
Maybe the directory 'output_dir' does not exists. perl wont create
directories unless you tell it to by using the mkdir function.
>
> print OUT $browser->content;
>
> close OUT;
>
> }
>
> close PAGE;
>
> print $browser->content;
| |
| kc68@cornell.edu 2006-05-22, 7:00 pm |
| On Mon, 22 May 2006 18:00:25 -0400, Jaime Murillo <jmurill0@pacbell.net>
wrote:
> On Monday 22 May 2006 14:49, kc68@cornell.edu wrote:
>
> Maybe the directory 'output_dir' does not exists. perl wont create
> directories unless you tell it to by using the mkdir function.
>
>
That's it: I needed $output_dir/simple2.html - missing the $ Now have to
start working on the regex as I got the page with "No matches found"
| |
| John W. Krahn 2006-05-22, 7:00 pm |
| kc68@cornell.edu wrote:
> When I execute the script below, I get the error message "No such file
> or directory at simple2.pl line 21." Line 21 is the Open OUT
> statement. This script parallels a tutorial script that does work and
> I don't see the error. It does print to the screen if I comment out
> the Open OUT line. Thanks in advance.
>
> #!/bin/perl
>
> use strict;
>
> use WWW::Mechanize;
>
> my $output_dir = "c:/training/bc";
>
> my $starting_url = "http://clerk.house.gov/members/olmbr.html";
>
> my $browser = WWW::Mechanize->new();
>
> $browser->get( $starting_url );
>
>
> $browser->submit();
>
>
> {
>
> open OUT, ">output_dir/simple2.html" or die "Can't open file: $!";
Does the directory 'output_dir' exist in the current directory or did you
intend to use the variable $output_dir instead?
> print OUT $browser->content;
>
> close OUT;
>
> }
>
> close PAGE;
Where did you open the PAGE filehandle?
> print $browser->content;
John
--
use Perl;
program
fulfillment
| |
| Dr.Ruud 2006-05-22, 7:00 pm |
| kc68@cornell.edu schreef:
> my $output_dir = "c:/training/bc";
> [...]
> open OUT, ">output_dir/simple2.html" or die "Can't open file: $!";
^
Maybe you meant $output_dir?
^
--
Affijn, Ruud
"Gewoon is een tijger."
|
|
|
|
|