Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

perl script

  • 02-08-2000 01: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