use strict; use warnings; use Win32; # Yes, this is a Win32 module: see POD use HTML::Entities qw(encode_entities); my $PERLBIN='c:\perl\bin'; use constant SOURCE=>1; my $time=time; my $file=$ARGV[0]; my $temp=$ENV{TEMP} || $ENV{TMP} || '.'; # 'cos we're being lazy and just redirecting HTML to a file # I don't think we want to use array form of 'system'. So # I'm checking that the File is a genuine file and Temp is # a genuine directory (e.g. this means that they can't contain # any shell escapes). Is this robust enough ? unless ($file && -e $file) { $file ||="no file specified"; my $error= "File doesn't exist! [$file] \n" ; Win32::MsgBox($error); die $error; } unless (-d $temp) { my $error= "Temp directory isn't a directory! [$temp] \n"; Win32::MsgBox($error); die $error; } if (SOURCE) { open (FILE, $file) or die; my @file = ; close FILE or die; open (SRC, ">$temp\\$time.src"); open (SRCHTML, ">$temp\\$time.src.html"); # prepend source file with html instructions for viewing source print SRC qq(=begin html\nView source\n\n=cut\n\n); print SRCHTML < Source of $file
	for (@file) { 
		print SRC $_;
		# encode_entities escapes any characters that might be
		# special in HTML
		print SRCHTML encode_entities($_);
	print SRCHTML <
	close SRC or die;
	close SRCHTML or die;

system qq($PERLBIN\\pod2html $file --title="POD from $file" > $temp\\$time.html);
system qq(start $temp\\$time.html);
system "pause";


=head1 NAME



A wrapper around the standard pod2html utility to view POD.

Following a thread on about Drag and Drop for calling Perl
scripts (which I think is a bad thing by the way) I thought this might be a
better use of Windows NT Shell extensions to make WinNT more useful for Perl

(Not the other way round obviously).

If you implement the WinNT registry changes listed, you should be able to 
right-click on a .pl, .pm or .pod file and choose a "View as HTML" option.  
This B open in your default browser.

=head1 WARNING

This is proof of concept.  It involves manually editing the registry.  DON'T

(I am only doing this because 

=over 4

=item *

I know why it's bad  (!)

=item *

I don't have anything too important on my Win2K box

=item *

I won't whinge at myself if it all goes 


For more warnings about how dangerous editing the registry is, try

=head1 HOW TO SET UP

I'm assuming that your perl is in C:\perl\bin\perl.exe.  If not please edit the
variable in this script, and in the registry entries I mention.

=item 1

Save this script in C:\perl\bin as

Note that you can now use the script as a wrapper around pod2html by calling {filename}

Where {filename} contains some POD.

=item 2

Open the registry. Then read again the warnings above.

 Go to 

 Make sure that keys exist for the following 

 	.pl     Perl
 	.pm     PerlModule
 	.pod    POD

 I've suggested what I think could be values in the "Default" value.  But
 If you have different values already existing then another program (a Perl
 IDE for example) may have registered them, so just make a note of what that
 value is.

 For each of the above values go to
 	My Computer\HKEY_CLASSES_ROOT\{value}
 for example

 	My Computer\HKEY_CLASSES_ROOT\Perl\Shell

 Notice that there is already a sub-key called "Open".  In Open there is a 
 subkey called "Command".
 This has a value like:
 	C:\Perl\bin\perl.exe "%1" %*

 This is the command that will be run when you double click on a Perl script
 in the GUI, or you right-click on it and choose "Open".

 Under Shell, create a key called "View POD", and under that a key called 
 "Command" Now you have a key called

 	My Computer\HKEY_CLASSES_ROOT\Perl\Shell\View POD\Command

 All we need to do is to add a command in here.  Double click on the default
 value and add the following

 	C:\Perl\bin\perl.exe C:\Perl\bin\ "%1"

 We need to put %1 (the parameter - e.g. the name of the file being viewed
 in quotes in case the name has any spaces in it!)

=item 3

Now test: right click on a .pl, .pm or .pod file.  Do you have the C
option?  Choose it.  If it opens up your POD in a browser that's good.
If not something went wrong.  Check that you typed the Registry value correctly
(I managed to type it wrong 3 times while testing).

=head1 AUTHOR, VERSION, ETC (osfameron on /

version 0.002

This is Proof Of Concept.  Use at your own risk: no warranty express or

I cannot offer any support on this, but would welcome any comments.

=head1 BUGS

If the document has no POD a blank HTML document will be opened.

Did I mention that this was test code?  Let me know!