Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

perl script

Options
  • 02-08-2000 1:44pm
    #1
    Closed Accounts Posts: 5


    Hi Guys,

    I hope you can help me. I urgently need a perl script that will basically take a bunch of files in a specific directory and go through each one to strip out a tag. Do you know where I can get such a script or can anyone outline a simple one here? I have tried all the usual script sources on the net and can't find one.


Comments

  • Closed Accounts Posts: 202 ✭✭Karla


    If you want something that will scan for HTML files in a single directory and strip one tag from each of those files then try this one. It doesn't overwrite the original file but creates a new one with a *.html.notag extension.
    #!/usr/bin/perl -w
    
    @html_files = glob("*.html");    # Finds all html files in a dir
    
    foreach $file (@html_files) {
    
       @html = ();
    
       open(HTML, "<$file") or die $!;
       @html = <HTML>;
       close(HTML) or die $!;
    
       for (@html) { s/<TITLE>//gi; }
    
       open (FILE, ">$file.notag") or die $!;
       print FILE @html;
       close(FILE) or die $!;
    }
    

    If you want to strip all the tags from a file then look into the HTML::* modules, most likely HTML::Parse and HTML::FormatText modules.

    Hope this helps some.

    Karla


Advertisement