|
print_source.pl
|
– |
I wrote this perl script and I'm using it on my website wherever you see the option to click on a title to see the source-code (e.g. program.html—this page). The way
it works is that it reads in the parmed source-file and modifies some of the elements to make them browser-friendly—for example, substituting entities for < and > brackets,
<br> for newline, and spaces for tab—then displays it in the browser to look just like it does in the editor.
|
|
|
Create link
create_link.pl |
– |
At times I have wanted to download a file that is embedded in the HTML of a webpage and I would have to create a
little webpage with a link to the file so I could use the Save Target As option on the the right mouse button context menu.
This script will allow you to just type in the URL and a web link is created automatically. Since
creating it I have found it useful for other things, for instance, at work I wanted my initial Perl script in
one application to show a button to go back to the previous webpage if the script is called from a link (using
$ENV{'HTTP_REFERER'}), but not if the script was run from a shortcut or typed into the address bar of the
browser. I used the Create link script to quickly create a link to call my script for the test. |
|
|
My songs
|
– |
I am always telling people about songs I have on my smartphone (previously iPod), so to share some of these songs with others I
uploaded them to a folder on my web server and wrote a script to show a list of the songs in that folder.
Please note: I used to share these as playable MP3s
playsongs.pl.
but they had to be removed from the server (see explanation) so the My songs page has been changed.
All the songs on my smartphone are stored in a folder on my PC (named "ipod" because before my smartphone
these songs were played on an iPod), and to show a list of those songs I wrote two scripts:
|
|
– |
I am also using this same process to display a list of the eBooks I have on my phone.
|
|
|
Expand/contract list
plus_minus.pl
|
– |
I wanted to try to emulate the old Windows Explorer, where if a folder has a sub-folder you get a button in front of it that you click on to expand the tree. This
changes to a (minus) which you can click on to contract it.
Because of the stateless nature of Perl, coding this was a little more elaborate than I anticipated when I started working on it, but I
accomplished it.
|
|
|
Mypics
showpics.pl
show_thumbs.pl
|
– |
When I started taking digital photos, first with a camera then with my phone, I wanted to show some friends the photos I was taking so I made a script to list them dynamically as links. When I present photographs
on a webpage I usually create a thumbnail of the photo to click on to see an enlargement, so I wrote a Perl script (show_thumbs.pl) to create the
thumbnails dynamically, specifying a width attribute on the <img> tag
for the thumbnail which creates a height with the same aspect ratio as the original image. One
consideration when using this technique is that all the image files have to download completely before the page is entirely formatted
with the thumbnails, but most people I know have high-speed Internet connections now so that was not a problem. The
Mypics webpage runs both of these using Ajax
(that is one of the best methods to embed Perl in HTML pages). I have since cloned these scripts to show photos I take with my cellphone.
|
|
|
Reunion Photos
skip.pl |
– |
My high school classmate Skip sent me 68 printed photos from a class reunion, which I had offered to scan in and put on my Class Reunion page. There were so many photos that rather than create thumbnails individually like I had done for all the rest of
the photos on my Reunion page I decided to clone show_thumbs.pl
above to create them, and I am using Ajax to put them on the reunion page.
|
|
|
|
– |
One technique I like to use on my website is having a simple HTML template use Ajax
to call perl to format the content. This is especially useful when you have a lot of items you wish to list or display and you don't
want to tediously create all the HTML to present them. You can put them in a single folder and have perl read and list them. You can
even dynamically create thumbnails (show_thumbs.pl) for photos, which I do on some of these pages.
|
|
|
log_visits.pl
|
– |
I log visits to pages on my website. |
|
|
view_log.pl
|
– |
I wrote this script to display the logs of visits to my website. I cloned
print_source.pl
but modified it to reverse the order of the log data to display the most recent visits at the top.
|
|
|
Videos
|
– |
I used to show all videos on my website in popups using Perl scripts.
(I now show each video in a webpage template using Javascript that gives you
a URL for the video you can share with others.)
Using Popups
play_flv.pl |
··· |
I wrote this script to play Flash videos (flv files) on my server with this Flash Video Player.
Example usage: <a href="cgi-bin/play_flv.pl?filename=somefile.flv&width=400&height=360&title=Window%20Title">
To see local flv in popup . . .
Letterman Top 10
Now see using my template.
|
show_video.pl |
··· |
I wrote this script to play other video formats, including mpg, wmv, and avi.
Example usage: <a href="cgi-bin/show_video.pl?filename=somefile.wmv&width=400&height=360&title=Window%20Title">
To see local wmv in popup . . .
Granny air bag
Now see using my template.
|
video_embed.pl |
··· |
Most of the videos on my website are on my server, but sometimes I like to link to videos on a remote site like YouTube, showing them in my own popups.
Some browsers don't like linking directly to the videos in JavaScript, so I wrote this script to play the videos using <object> and <embed> tags.
Example usage: <a href="cgi-bin/video_embed.pl?video=http://www.youtube.com/v/6gmP4nk0EOE?autoplay=1&width=400&height=360&title=Window%20Title">
You have to know the path to the video ("http://www.youtube.com/v/..."), which is often shown in the <embed> instructions on the remote video page.
If the URLs to videos already have CGI characters (which would be confused with my usage), I replace ? with | and & with ` and they will be restored in video_embed.pl.
Please note. Sometimes you are prohibited from embedding an uploaded video in a webpage so this will not work with those.
To see remote video in popup . . .
Monty Python
Now see using my template.
|
This HTML link calls the popup function with the video to play.
<a href="cgi-bin/play_flv.pl?filename=somefile.flv&width=500&height=375&title=Window%20Title"
onClick="showVideo(this.href,520,385);return false;">
This JavaScript creates a popup containing the output from the Perl script that is specified in the first parameter in the link.
function showVideo(ref, width, height) {
var parms = 'width=' + width + ',height=' + height + ',left=200,top=200,resizable=yes'
var target = 'myvideo'; // using the same target name makes all videos use the same window object
popupWindow=window.open(ref, target, parms);
// make the window dimensions slightly larger than the video
var wplus = 10;
var hplus = 55;
// increase height for IE7 to accomodate location toolbar
var ie7 = ((document.all) && (navigator.appVersion.indexOf("MSIE 7.") != -1));
if (ie7) {
hplus = 90;
}
var rwdth = width + wplus;
var rhght = height + hplus;
popupWindow.resizeTo(rwdth,rhght);
popupWindow.focus();
}
|
|