Showing posts with label Special Perl. Show all posts
Showing posts with label Special Perl. Show all posts

Friday, August 13, 2010

Converting POD To html ( Plain Old Documentation to HTML Conversion)

First you should know what is POD, so for Writing Documentation in Perl Modules Check Article "Plain OLD Documentation". After reading this article you will know what is POD and then point comes to convert it to distributable format i.e. html format, so no one will have to look into your perl code and one can know what all is there in that particular module.

There is a module in Perl Called as "pod2html" which gives details on how to convert pod to html.
 Following is the command line for converting pod 2 html :

 pod2html --help --htmlroot= --infile=
                           --outfile=  --podpath=:...:
                           --podroot= --libpods=:...:
                           --recurse --norecurse --verbos
                           --index --noindex --title=

--htmlroot: Root path when creating HTML File from pod.
--infile: Specify the pod file name to convert to html 
--outfile: HTML Filename to be created, if not given then output will go to STDOUT
--index : Creates index at TOP of HTML File (Default)
--noindex: Oppsite of "--index", don't create index at top
--recurse: Recurse into subdirectories specified in podpath(default)
--norecurse: Do not recurse
--title: Title of resulting HTML File
--verbose: Display progress messages
--podroot: Base directory for finding library pods



Example: pod2html --infile=Test.pm --outfile=Test.html --header --index --backlink="Go Back to Top"

 For further study: POD::HTMLPlain OLD Documentation



Friday, July 30, 2010

Replacing ^M character at end of line using VI editor ( ^H, ^G and so on..)

Some time these characters are placed when you convert file from DOS format to Linux format. These characters can be viewed only with Vi editor or either typing "cat -v" command for that file in command prompt. These characters are called control characters.

These characters can be deleted using ":%s/.$//g" command from VI prompt.
To replace character use it like ":%s/.$/replace/g" Press Ctrl Q+M, and this will character will come up. In some other format it can be typed using ctrl V+M.

But before doing all this do ":set ff=dos", to change file format to DOS.

At last a simple trick for Gvim on Windows XP:
:%s/\r/\r/g
This replaces unix carriage return by windows CRLF.

following is the list of Ctrl characters:

Hex Name
0x00 NUL
0x01 SOH, Control-A
0x02 STX, Control-B
0x03 ETX, Control-C
0x04 EOT, Control-D
0x05 ENQ, Control-E
0x06 ACK, Control-F
0x07 BEL, Control-G
0x08 BS, backspace, Control-H
0x09 HT, tab, Control-I
0x0a LF, line feed, newline, Control-J
0x0b VT, Control-K
0x0c FF, form feed, NP, Control-L
0x0d CR, carriage return, Control-M
0x0e SO, Control-N
0x0f SI, Control-O
0x10 DLE, Control-P
0x11 DC1, XON, Control-Q
0x12 DC2, Control-R
0x13 DC3, XOFF, Control-S
0x14 DC4, Control-T
0x15 NAK, Control-U
0x16 SYN, Control-V
0x17 ETB, Control-W
0x18 CAN, Control-X
0x19 EM, Control-Y
0x1a SUB, Control-Z

Monday, March 22, 2010

Setting environment variable using Perl Programs

Most of the time you may need to add the path of some directories where your code files are present or even your perl modules are there, and you want to use them.

Since %ENV is a special Hash in Perl, which contains values for all of your environment variables. So you can set any variables just like other hash variable in Perl.
So you can add following directories in your Path variable as:

$ENV{PATH} = 'C:\bin; C:\mymodule';

In this way it will replace your previous path to the one you are adding, but that will be till the program runs.

For Adding path in addition to existing path do it like following:

my $path = $ENV{PATH};
$path = $path . ';C:\bin; C:\mymodule';
$ENV{PATH} = $path;
print "\n\n $ENV{PATH}";


Similarly other variables can also be set.
You can check whether it's added or not by :

print $ENV{PATH};