Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
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 = <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\n<a href="file://$temp/$time.src.html">Vi +ew source</a>\n\n=cut\n\n); print SRCHTML <<EOF_HEAD; <html> <head><title>Source of $file</title></head> <body> <pre> EOF_HEAD for (@file) { print SRC $_; # encode_entities escapes any characters that might be # special in HTML print SRCHTML encode_entities($_); }; print SRCHTML <<EOF_FOOT; </pre> </body></html> EOF_FOOT close SRC or die; close SRCHTML or die; $file="$temp\\$time.src"; } system qq($PERLBIN\\pod2html $file --title="POD from $file" > $temp\\$ +time.html); system qq(start $temp\\$time.html); system "pause"; =head1 NAME podview =head1 DESCRIPTION A wrapper around the standard pod2html utility to view POD. Following a thread on about Drag and Drop for callin +g 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 fo +r Perl programming. (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" opt +ion. This B<should> open in your default browser. =head1 WARNING This is proof of concept. It involves manually editing the registry. + DON'T DO THIS! (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 wrong. =back 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 c +alling {filename} Where {filename} contains some POD. =item 2 Open the registry. Then read again the warnings above. Go to My Computer\HKEY_CLASSES_ROOT 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 wha +t 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 cal +led "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 d +efault 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 vi +ewed 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<V +iew Pod> 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 / www.perlmonks.or +g) version 0.002 This is Proof Of Concept. Use at your own risk: no warranty express o +r implied. 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! =cut

In reply to Win32: Shell extension for viewing POD (proof of concept) by osfameron

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others chilling in the Monastery: (4)
    As of 2014-12-27 04:55 GMT
    Find Nodes?
      Voting Booth?

      Is guessing a good strategy for surviving in the IT business?

      Results (176 votes), past polls