Hello Monks. I just moved a perl script from a macbook air to a PC. I'm getting the following error though: can't locate object method "attr" via package "Mojo::Collection". I've been goggling and saw a similar error where someone used attrs vs. attr and changed it and had success but no such simple luck and fix for me. I'm thinking the Activestate Perl in the Windows box maybe has a newer version of Mojo::Collection and that might be causing the issue. The script simply pulls html and parses and reformats. Anyway here's the code that's throwing the error:

my $calls_dir = "Bing/"; opendir( my $search_dir, $calls_dir ) or die "$!\n"; my @html_files = grep /\.html$/i, readdir $search_dir; closedir $search_dir; foreach my $html_files (@html_files) { my %seen = (); my $current_file = $calls_dir . $html_files; open my $FILE, '<', $current_file or die "$html_files: $!\n"; my $dom = Mojo::DOM->new( scalar slurp $calls_dir . $html_file +s ); print $calls_dir . $html_files; open my $fh, '>', "Bing/1Parsed/Html/${html_files}.result.txt" or die $!; for my $csshref ( $dom->find('a[href]')->attr('href')->each ) +{ my $cssurl = URI->new($csshref)->abs( $calls_dir . $html_f +iles ); $fh->print("$html_files\n"); $fh->print("$cssurl\n"); } }

lots of people smarter than me so please let me know if you see something obvious that this newb is doing wrong or another way that I can code/fix what I'm trying to do that won't throw an error. Thanks!


In reply to can't locate object method "attr" via package "Mojo::Collection" by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.