Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8026203
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T23:24:47+00:00 2026-06-04T23:24:47+00:00

I Have a html file stored on the disk(The file is This ) .

  • 0

I Have a html file stored on the disk(The file is This) . I want to remove all the html tags of images. This is what i have tried so far.

#!/usr/bin/perl -w
use HTML::TagFilter;
my $tf = new HTML::TagFilter;

open READ, "D:\\Scripts\\file.html" or die "Couldn't open file: $!"; 
$string1 = join("", <READ>); 
close READ;

my $self = HTML::TagFilter->new(deny => {img => {'all'}});
open (MYFILE, '>D:\\Scripts\\remove.html');
print MYFILE $tf->filter($string1);
close (MYFILE); 

If i just run this program it prints

Odd number of elements in anonymous hash at remove everything else.pl line 9.
Parsing of undecoded UTF-8 will give garbage when decoding entities at C:/Perl64
/site/lib/HTML/TagFilter.pm line 499.

The file is stored but it does not have the image tags removed(The line 9 is where i apply the filter). What am i doing wrong here.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T23:24:50+00:00Added an answer on June 4, 2026 at 11:24 pm

    First of all you should always use strict and use warnings at the start of your program, especially before asking for help to fix it.

    You have created two HTML::TagFilter objects: $tf which has no filters and $self which removes <img> elements. You have used $tf to process the HTML so your data is unchanged.

    This code works, with the corrections I have mentioned and a couple of others.

    use strict;
    use warnings;
    
    use HTML::TagFilter;
    
    my $tf = HTML::TagFilter->new(deny => {img => {all => []}});
    
    my $html = do {
      open my $fh, 'D:\Scripts\file.html' or die "Couldn't open file: $!";
      local $/;
      <$fh>;
    };
    
    open my $out, '>', 'D:\Scripts\remove.html' or die "Unable to open output file: $!";
    print $out $tf->filter($html);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have html-file. I have to replace all text between this: [%anytext%]. As I
I have HTML page, CSS, JAVA and images all stored in my SQLite database.
I have a html file (contains some text and one image) stored @ /sdcard/test
i have html file of size upto 1GB. and i want to upload the
I have following Html file with javascript. This gives me error that testCircle is
In firefox I have opened a locally stored file with the file:// protocol (file:///c:/temp/foo.html)
I have an html file stored in my SQL database as binary. The html
I have a file called count.php . this is where count.php is stored (the
i Have this piece of code for load a json file stored in the
I have a html file stored in my assets folder say /assets/something.html. Now I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.