Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Im running a script that works in everything including my Unix server and My NT server except for when I run it starting in the NT server webroot (f:\inetpub\wwwroot\) it gives me the following message:
Use of unitialized value in hash element at F:\Perl\bin\scriptname.pl +line 32. Use of unitialized value in hash element at F:\Perl\bin\scriptname.pl +line 32. Use of unitialized value in hash element at F:\Perl\bin\scriptname.pl +line 32. Can't locate object method "host" via package "URI::_foreign" at F:\Perl\bin\scriptname.pl line 32.
If I run this script starting in any of the NT server webroot and other directories (f:\inetpub\wwwroot\nextDirectory) it works with no problems. It just seems to not work when I run it from web root on my NT server. Here are the modules I am using on my NT server on Perl 5.8.
use strict; use warnings; use HTML::LinkExtor; use URI; use File::Find;
Here is part of my link Extractor that is not working:
my $base = 'http://webroothere.com/'; my %servers; my $p = HTML::LinkExtor->new; $p->parse_file($File::Find::name); foreach ($p->links) { # for each link found... my ($tag, %attrs) = @$_; foreach my $a (keys %attrs) { # for each attribute of link my $url = URI->new_abs($attrs{$a}, $base); next unless $url->scheme =~ /^http/; $servers{$url->host}++; #THIS IS THE LINE IT SEEMS TO ERROR + ON
Any ideas on why this is happening????

Replies are listed 'Best First'.
Re: Problem on NT server webroot only
by BrowserUk (Patriarch) on Jul 18, 2003 at 00:00 UTC

    It might be worth adding a test to see if your URI object is actually being created.

    ... my $url = URI->new_abs($attrs{$a}, $base) or warn "Couldn't create URI for $attrs{$s}:$base : $! ", $ +^E||''; ...

    I would have expected that you would be seeing other errors before this if the URI wasn't being created, but maybe it will show something that will help clarify the problem.


    Examine what is said, not who speaks.
    "Efficiency is intelligent laziness." -David Dunham
    "When I'm working on a problem, I never think about beauty. I think only how to solve the problem. But when I have finished, if the solution is not beautiful, I know it is wrong." -Richard Buckminster Fuller

      Thanks you answered my problem!