previous page: Perl Modules
page up: Development
next page: Old Projects

Perl Scripts

Here are some Perl scripts that I coded years ago, when I was just starting with Perl. They just work, even if the code is not so pretty.

  • mail-lib.txt - If you submit a lot of email thru the scripts you will want to use this library, since it uses SMTP to talk directly to the mailhost and you don't get the overhead of loading a client mail program like sendmail each time you send email.
    Check if you have SMTP running by 'telnet mailhost 25' on Unices, replace mailhost with your mailhost server, in many cases it would be the name of your server.
  • cgidie-lib.txt - This little lib assigns a subroutine to SIG{__DIE__} so when something wrong happens during the run of your script, you will not get the ugly "Error Occured" message but a nice html with complete information: what was the error, where the script was called from and other parameters, and the most important with email link so user can easily report to you about it and include all the info you will ever need to locate the error.
    Also you will not need that custom Cgierror() subroutine people use everywhere. just use die() and it'll produce the same thing as you did with Cgierror() but with no extra coding.
    It also knows to handle the shell vs browser mode. so if you debug the script from shell you will never see the html around the error but the sole error message
  • ls2html.txt- script to create index.html recursively in all subdirectories to include all images so you can view all of them at once. You can modify the maching patten to collect any type of the files. This is also a good example of making recursive scripts just write your own subroutine to do something for each dir/file and you can run it recursively now.
  • replace.txt- script to replace pieces of code in sequence of files (options: -case insensitive/sensitive, -global ,-backup the original file
  • condense.txt - Script to remove the redundant empty lines (generally when you turn html file to text file)
  • hex2bin.txt - Converts hex number to binary representation and prints each hex symbol as XXXX binary
  • parg2html.txt - Converts input file with paragraphs of text separated by newlines into set of files named pattern.DD.html one paragraph per file packed in standard html headers. where DD is the number of the paragraph
  • setrights.txt - Runs recursilvely on one of your dirs and sets regular files access modes and directories access modes. You can change the modes by modifying the patterns.
  • tagstrip.txt - Strips HTML <TAG>s from html files. It's not 100% works yet, but it's better than doing it by hand. (It makes troubles when you have recursive <!-- <TAG > -->)
  • imgextract.txt - This program extracts image path/filename from your html source and prints it out the sorted and unique results As well supposed that your system has "uniq" and "sort" utilities. (was written when starting using perl so no internal function has been used) Now program supports following patterns: <IMG SRC=""> and <BODY BACKGROUND="">
  • findpat.txt - Script that browses recursively all the dirs down the one you have called from Finds all the pattern occurencies you need, Prints the name of the file with relative path, lines where is has found and the lines themselves
  • fixhtml.txt - Breaks lines with \n after each ">" closing tag (except ">\n") So you can read the source of the html file if someone produced it with cgi which spit all in one line.
  • recurs.txt - This script executes recursively on subdirs the command you supply as a parameter

Scripts by Other Authors.

  • rename.txt- (by Larry Wall)   Does mv *.c *.cc by rename.pl 's/\.c/\.cc/' *.c
  • traceroute.txt - (by Marc Spitzler)   Does Ping and Traceroute thru CGI (you will need CGI.pm)

previous page: Perl Modules
page up: Development
next page: Old Projects