Support Forums

Full Version: HTML perl script
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

if ($#ARGV != 1) {
    print q{
|                                                           |
|                  Coded by Ace - 2011                      |
|                     |
|                                                           |
|   Syntax - "output file" "number of html files"   |
|                                                           |
|                [Usage: myfile 3]                  |

#Take the arguments in the input command and define them as our variables to use
$filename = $ARGV[0];
$filecount = $ARGV[1];

#Define a loop to loop through this script until we reach
#a $num that is equal to the one specified in the arguments
#--(This will loop through as long as the $num is less than and/or equal to $filecount)
for ($num=1; $num <= $filecount; $num++) { #As long as $num is less than or equal to $filecount increment $num

    open(HTML, ">$filename$num.html"); #Open the file we're trying to write to

    if($num==$filecount) {
    $next = 1; #choose 1 as the number
    } else {
    $next = $num+1; #if 1 is taken then the add 1

    #Here's where we add the information to the opened HTML file
    print HTML "<html>\n<head>\n<title>$filename$num</title>\n</head>\n<body>\n";
    print HTML "<a href=\"$filename$next.html\">Link to $filename$num</a>\n";
    print HTML "<p>Automatically Generated by - Created by Ace</p>\n";
    print HTML "</body>\n</html>\n";
    #We are finished with editing/creating this file
#(Onto the next file if $num has not reached $filecount
#Repeat until we hit the $filecount argument specified in the command

Here's my newest little script in perl. It's nothing really advaned, but it's quick for something simple. What this does is it will take parameters specified in the arguments of the command line for the script to determine html file creation requirements. These requirements include two variables that gets taken from the input command as an argument from the command line, such as a filename for the html's created, and a number of files to create with the html file extension.

Something like:
Code: ace 3

Will tell the script to output 3 html files all linked to each other with the filename of ace and a filenumber before the file extension.

So it would output:
- ace1.html
- ace2.html
- ace3.html

And all are linked to each other.

I've commented out my entire script so that it's easy enough for you to follow along.

For use, the syntax stays the same as long as you have the pl file saved as on your local storage. Otherwise it would just be the name of the pl script followed by the last half of the syntax i've provided, which should be obvious.

If you save this script as, then instead of the syntax being it would be Pretty simple.
Thanks for the great script Ace. Always HQ and helpful. Big Grin
Thank you for the awesome script im going to try that in 2 mins!
Thanks for the script man. <3     
nice!! thank you for this script dude!!
Seems like A awesome script im
Going to try it out.