Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: File Find error

by chip (Curate)
on Jun 23, 2003 at 18:36 UTC ( [id://268271]=note: print w/replies, xml ) Need Help??


in reply to File Find error

Trying to open a directory as a file is not OK on some operating systems, and almost never helpful anyway. I suggest the first thing in LinkRoutine, after assigning to $name, should be:

   return unless -f $name;

    -- Chip Salzenberg, Free-Floating Agent of Chaos

Replies are listed 'Best First'.
Re: Re: File Find error
by Anonymous Monk on Jun 23, 2003 at 18:55 UTC
    I added as you requested and now dont get an error message but also I dont get any output at all. Please advise what else I need to do to get this work:
    use HTML::LinkExtor; use LWP::Simple; use File::Find; sub LinkRoutine { my $name = $File::Find::name; return unless -f $name; open ( FH, $name ) or die "error $!: $name\n"; while(my $line = <FH>) { $base_url = $name; $parser = HTML::LinkExtor->new(undef, $name); $parser->parse(get($name))->eof; @links = $parser->links; foreach $linkarray (@links) { @element = @$linkarray; $elt_type = shift @element; while (@element) { ($attr_name, $attr_value) = splice(@element, 0 , 2); $seen{$attr_value}++; } } close(FH) } } find( \&LinkRoutine, "/perl/bin" ); for (sort keys %seen) { print $_, "\n"; }
      I suspect you don't want to break your file up into individual lines before HTML parsing them. :-) To test whether that's the problem, put:

        local $/;

      before the 'while my $line' loop.

          -- Chip Salzenberg, Free-Floating Agent of Chaos

        Thanks,
        I tried that and it still gives me no output. Any other suggestions??

Log In?
Username:
Password:

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

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

    No recent polls found