Download the Random Text script to display random quotes, tips, or text snippets on your website using Server Side Includes.
Version 1.0 | Perl CGI Script
| Filename | Description | View |
|---|---|---|
README |
Installation instructions and documentation | View |
rand_text.pl |
Main Random Text CGI script | View |
quotes.txt |
Sample text file with example quotes | View |
rand_text.pl to your cgi-bin directoryquotes.txt to a web-accessible directorychmod 755 rand_text.plrand_text.pl to set the path to your text file<!--#exec cgi="/cgi-bin/rand_text.pl"-->Edit the following variables in rand_text.pl:
$textfile = "/path/to/quotes.txt"; # Path to your text file
$separator = "%%"; # Separator between quotes
Format your text file with quotes separated by %% on its own line:
The only way to do great work is to love what you do. - Steve Jobs
%%
Innovation distinguishes between a leader and a follower. - Steve Jobs
%%
Your time is limited, don't waste it living someone else's life. - Steve Jobs
%%
Stay hungry, stay foolish. - Steve Jobs
<!--#exec cgi="/cgi-bin/rand_text.pl"-->
<div class="quote-of-the-day">
<!--#exec cgi="/cgi-bin/rand_text.pl"-->
</div>
<style>
.quote-of-the-day {
font-style: italic;
padding: 15px;
border-left: 4px solid #007bff;
background: #f8f9fa;
margin: 20px 0;
}
</style>
Pass the filename as a query parameter:
<!-- Display random quote -->
<!--#exec cgi="/cgi-bin/rand_text.pl?file=quotes.txt"-->
<!-- Display random tip -->
<!--#exec cgi="/cgi-bin/rand_text.pl?file=tips.txt"-->
<!-- Display random testimonial -->
<!--#exec cgi="/cgi-bin/rand_text.pl?file=testimonials.txt"-->
<script src="/cgi-bin/rand_text.pl"></script>
Requires modifying the script to output JavaScript instead of HTML.
Display random links or banners on your site.
Show random images or graphics dynamically.
Display current date and time via SSI.