paritybit.ca

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit add953da7ec3e8e9981a8cb33212310aef35b1fd
parent c4a0e9fd25840e3efc87f0a0b76c31fc1bf0fa80
Author: Jake Bauer <jbauer@paritybit.ca>
Date:   Wed, 27 May 2020 18:32:16 -0400

Progress with gopherize

Diffstat:
Mgopherize | 31+++++++++++++++----------------
1 file changed, 15 insertions(+), 16 deletions(-)

diff --git a/gopherize b/gopherize @@ -22,38 +22,37 @@ use strict; use warnings; our $VERSION = "0.1.0"; -package Gopherize; +package Gopherizer; use base "HTML::Parser"; +our @Links; + sub text { my ($self, $text) = @_; - # print original text - print $text; -} - -sub comment { - my ($self, $comment) = @_; - #print original text w/ comment marker - print ""; } sub start { my ($self, $tag, $attr, $attrseq, $origtext) = @_; - #print original text - print $origtext; + if ($tag eq 'a') { + print "URL: ", $attr->{ href }, "\n"; + } } sub end { my ($self, $tag, $origtext) = @_; - #print original text - print $origtext; } -my $parser = new HTMLStrip; - +my $parser = new Gopherizer; my @files = @ARGV; foreach my $file (@files) { - open($file) or warn "Could not open $file"; + print "Opening $file\n"; + open(my $fh, "<:encoding(UTF-8)", $file) + or do { + warn "Could not open $file: $!"; + next; + }; + print "Parsing $file\n"; $parser->parse_file($file); + close($fh); }