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!