open(DOC, "<$doc_filename") || die "can't open doc $doc_filename: $!"; binmode(DOC); $document = ; close(DOC); while ($document =~ m{< ?(.*?) ?>}g) { $tag = $1; # find tags with links $link = ($tag =~ m{ (background|src|usemap|action|href)\s?=\s? (['"]*) ([^\2 ]+)\2 }xi)[2]; next unless (defined $link);