Dec 31, 2010

Finding the Roman Value

Finding the Roman Value:

use strict;

print "Enter Decimal Number: ";
chomp(my $a = <stdin>);
print "Roman Value: ". &decimalroman($a);


sub decimalroman
{
   
    my $input = shift;
    print "$input";
    my @roman = ("M", "CM", "D", "CD", "C", "XC", "L","XL", "X", "IX", "V", "IV", "I");
    my @decimal =   (1000, 900, 500,  400, 100, 90,   50,  40,  10,   9,    5,    4,   1);
    my $romanvalue = "";
   
    for(my $i = 0; $i<13; $i++)
    {
       while($input >= $decimal[$i]){
           $input -= $decimal[$i];
           $romanvalue .= $roman[$i];
       }
    }
   
    return $romanvalue;
}

Dec 29, 2010

DOS command 'ren'

rename or ren:
Renames a file. Unlike the move command, this command cannot be used to rename subdirectories, or rename files across drives.
ren filename newname
You can rename files in another directory by using the PATH parameter:
ren [[path\]filename] [newfilename]
This example renames c:\windows\filex.txt to c:\windows\filey.txt
ren c:\Windows\filex.txt filey.txt
Using a path in the destination newname will move the file to the new path, if this is on the same device. This renames the file to the c:\temp directory.
ren c:\windows\filex.txt \temp\filey.txt
On DOS with long filename support, care must be taken when directories have spaces in their names like "Documents and Settings". In these cases double-quotes are used to enclose them. Note it is necessary only to enclose blocks including spaces.
ren c:\"Documents and Settings"\"All Users"\Desktop\filex.txt filey.txt
ren "c:\Documents and Settings\All Users\Desktop\filex.txt" filey.txt
Wildcards in the destination are replaced by the corresponding part of the original name, so the command below will change the extension of the file from .doc to .txt, here myfile.doc becomes myfile.txt.
ren myfile.doc *.txt
Mass renames can be accomplished by the use of wildcards. For example, the following command will change the extension of all files in the current directory which currently have the extension htm to html:
ren *.htm *.html
In Unix, this functionality of a simple move is provided by the mv command, while batch renames can be done using the rename command.

Dec 28, 2010

Phases Of Compiler

Phases Of Compiler:

Compiler:
           Compiler is a simple program  which reads a program written in one language (i.e., High Level Language (or) Source Language) and it translates to an equivalent target program (i.e., Low Level Language).

Now we are going to  know  what are the different phases of compilers.

Phases of Compiler:

Compiler consists of 2 phases.
      
         1.Analysis Phase
         2.Synthesis phase

1.Analysis Phase :

Analysis Phase performs 3 actions namely

a)Lexical analysis - it contains a sequence of characters called tokens.Input is source program & the output is tokens.

b)syntax analysis - input is token and the output is parse tree.

c)Semantic analysis - input is parse tree and the output is expanded version of parse tree.

2.Synthesis Phase :

Synthesis Phase performs 3 actions namely

d)Intermediate Code generation - Here all the errors are checked & it produce an intermediate code.

e)Code Optimization - the intermediate code is optimized here to get the target program.

f) Code Generation - this is the final step & here the target program code is generated.

Dec 23, 2010

Globbing

Globbing a Directory:

The shell (or whatever your command-line interpreter is) takes a solitary asterisk ( * ) command-line argument and turns it into a list of all of the filenames in the current directory. So, when you say rm * , you'll remove all of the files from the current directory. (Don't try this unless you like irritating your system administrator when you request the files to be restored.) Similarly, [a-m]*.c as a command-line argument turns into a list of all filenames in the current directory that begin with a letter in the first half of the alphabet and end in .c , and /etc/host* is a list of all filenames that begin with host in the directory /etc . (If this is new to you, you probably want to read some more about shell scripting somewhere else before proceeding.)

  • The expansion of arguments like * or /etc/host* into the list of matching filenames is called globbing

  • Perl supports globbing through a very simple mechanism: just put the globbing pattern between angle brackets or use the more mnemonically named glob function.
 
Example: 

 1.) @a = </etc/host*>; 
 2.) @a = glob("/etc/host*");
 
 3.) @files = <*>;
     foreach $file (@files) 
     {
        print $file . "\n";
     }  

File Test Operators in PERL

File Test Operators in PERL:

                  Perl has many operators that you can use to test different aspects of a file. For example, you can use the -e operator to ensure that a file exists before deleting it. Or, you can check that a file can be written to before appending to it. By checking the feasibility of the impending file operation, you can reduce the number of errors that your program will encounter.

A complete list of the operators:




Operator Description
-A OPERAND Returns the access age of OPERAND when the program started.
-b OPERAND Tests if OPERAND is a block device.
-B OPERAND Tests if OPERAND is a binary file. If OPERAND is a file handle,
then the current buffer is examined, instead of the file itself.
-c OPERAND Tests if OPERAND is a character device.
-C PERAND Returns the inode change age of OPERAND when the program started.
-d OPERAND Tests if OPERAND is a directory.
-e OPERAND Tests if OPERAND exists.
-f OPERAND Tests if OPERAND is a regular file as opposed to a directory,
symbolic link or other type of file.
-g OPERAND Tests if OPERAND has the setgid bit set.
-k OPERAND Tests if OPERAND has the sticky bit set.
-l OPERAND Tests if OPERAND is a symbolic link. Under DOS,
this operator always will return false.
-M OPERAND Returns the age of OPERAND in days when the program started.
-o OPERAND Tests if OPERAND is owned by the effective uid.
Under DOS, it always returns true.
-O OPERAND Tests if OPERAND is owned by the read uid/gid.
Under DOS, it always returns true.
-p OPERAND Tests if OPERAND is a named pipe.
-r OPERAND Tests if OPERAND can be read from.
-R OPERAND Tests if OPERAND can be read from by the real uid/gid.
Under DOS, it is identical to -r.
-s OPERAND Returns the size of OPERAND in bytes.
Therefore, it returns true if OPERAND is non-zero.
-S OPERAND Tests if OPERAND is a socket.
-t OPERAND Tests if OPERAND is opened to a tty.
-T OPERAND Tests if OPERAND is a text file. If OPERAND is a file handle,
then the current buffer is examined, instead of the file itself.
-u OPERAND Tests if OPERAND has the setuid bit set.
-w OPERAND Tests if OPERAND can be written to.
-W OPERAND Tests if OPERAND can be written to by the real uid/gid.
Under DOS, it is identical to -w.
-x OPERAND Tests if OPERAND can be executed.
-X OPERAND Tests if OPERAND can be executed by the real uid/gid.
Under DOS, it is identical to -x.
-z OPERAND Tests if OPERAND size is zero.


Note:
        If the OPERAND is not specified in the file test, the $ variable will be used instead.
Example:

 $filename = '/path/to/your/file.doc';
 $directoryname = '/path/to/your/directory';
 if (-f $filename) 
 {
     print "This is a file.";
 }
 if (-d $directoryname) 
 {
     print "This is a directory.";
 } 

How to get the size of a file in Perl

How to get the size of a file in Perl:

       Perl has a set of useful File Test Operators that can be used to quickly get information about the file system like the existence of a file, or the size. Lets take a quick look at how to get the file size in bytes using File Test Operators.
  
 $filename = '/path/to/your/file.doc';
 $filesize = -s $filename;
 print $filesize; 
 
Simple enough, right? First you create a string that contains the path to the file that you want to test, then you use the -s File Test Operator on it. You could easily shorten this to one line using simply: 

 print -s '/path/to/your/file.doc'; 
 
Also, keep in mind that this will always return true if a file is larger than zero bytes, but will be false if the file size is zero. It makes a handy and quick way to check for zero byte files.

Using PERL verify whether file exists

How to tell if a file exists in Perl:

If you want to check the file is exist or not means simply add the '-e' behind the file name.

For example: 

 $filename = '/path/to/your/file.doc';
 if (-e $filename) 
 {
 print "File Exists!";
 } 

 You want to check it file not exist means use 'unless' or '!' operator.

For Example: 

 unless (-e $filename) 
 {
 print "File Doesn't Exist!";
 } 

 

Dec 22, 2010

Using PERL how to convert HTML file as PDF

Converting HTML to PDF:

  • The module here I used is PDF::FromHTML.
  • It is used for converting HTML file into PDF file.
  • Refer "http://search.cpan.org/~audreyt/PDF-FromHTML-0.31/" for more information about the Module.
Example:

#Add Module..
use PDF::FromHTML;
#Create object for that Module..
my $pdf = new PDF::FromHTML( encoding => 'utf-8' );
# Loading from a file..
$pdf->load_file('source.htm');

# Or from a scalar reference:
#$input = "<html><body>sample test<br><b>deiveegan</b></body></html>";
# $pdf->load_file(\$input);

# Perform the actual conversion..
$pdf->convert(
        Font        => 'arial.ttf',
        LineHeight  => 18,
        Landscape   => 2,
        );

# Write to a file:.
$pdf->write_file('Target.pdf');

# Or to a scalar reference:
# $pdf->write_file(\$output);


Some other convert parameters..


    PageWidth         640
    PageResolution    540
    FontBold          'HelveticaBold'
    FontOblique       'HelveticaOblique'
    FontBoldOblique   'HelveticaBoldOblique'
    LineHeight        12
    FontUnicode       'Helvetica'
    Font              (same as FontUnicode)
    PageSize          'A4'
    Landscape         0

PERL TK Module - Widgets 1 : Button, Entry, Label

Creating the Widgets using Tk Module:

A widget is a user interface object in X graphical user interfaces Confused? Lets just say that it is the name of the object that appears on screen There are many types widgets If you want to display a button, you use the button widget For text, you use the text widget For entry, you guessed it, the entry widget.

Syntax:

     my $WidgetVariable = $Window >WidgetType(?Option 1=>Value 1, ?Option 2=>Value 2 ??) ->pack();

widgetVariable - The widget variable of all widgets must be unique and will be used whenever that widget needs to be accessed.

options -  Each widget has some options which can be used to configure it This is usually done when the widget is declared, but it can be done afterward also.

commands - Each widget has some commands which also can be used to configure it or make it do some thing.

Before we begin, we need to know a little about the pack command I have explained this earlier but just doing it one more time so that you don't have to push the back button Pack is a geometry manager Another geometry manager is 'grid' we will explore that latter Pack is much more simpler than grid The line $hello ->pack; tells the interpreter to pack the widget called "$hello".

Button:
    This will make a button It can be configured to execute some code when the button is pushed This will usually refer to a function so when the button is pushed, the function will run An button is shown below This button is created using HTML input tag






Some Options:

text=>"TEXT"  - TEXT will be the text displayed on the button
command=>CALLBACK  -  CALLBACK will be the code that is called when the
                                           button is pushed
 

    use Tk;
    # Main Window
    my $mw = new MainWindow;
    my $but = $mw -> Button(-text => "Push Me",-command =>\&push_button); 
    $but -> pack();
    MainLoop;

    #This is executed when the button is pressed
   sub push_button 
  {
            whatever...
  }

You may have noticed that I used a slash(\) in the command callback
(-command =>\&push_button);) Make sure that the slash stays there - It pass the reference to its sub function.




Entry:

An entry is a widget that displays a oneline text string and allows the user to input and edit text in it When an entry has the input focus it displays an insertion cursor to indicate where new characters will be inserted An entry element is shown using HTML

Some Options:

width=>NUMBER
       Width of the input field NUMBER should be an integer.
 
textvariable=>\$VARIABLE
       The contents of the variable VARIABLE will be displayed in the widget If the text in
the widget is edited, the variable will be edited automatically

state=>STATE
      The state of the input field It can be normal, disabled, or readonly If it is readonly
the text can't be edited

Some Commands
Syntax Description Example
$widget ->get(); The text inside input field can be taken by this command.

$widget ->delete(FIRST?,LAST?); Delete one or more elements
                of the entry FIRST is $ent ->

$widget ->insert(index,"STRING");  Insert the characters of STRING just before the
character indicated by index Index is 0 for the first character The word "end" can be used for the last character.

Example

use Tk;
# Main Window
my $mw = new MainWindow;
#GUI Building Area
my $ent = $mw -> Entry() -> pack();
my $but = $mw -> Button(-text => "Push Me",-command =>\&push_button);
$but -> pack();
MainLoop;
 
#This is executed when the button is pressed
sub push_button 
{
       $ent -> insert('end',"Hello");
}





Dec 21, 2010

Tk Module - GUI process in PERL

Tk Module - GUI process in PERL
  • Perl/Tk (also known as pTk) is a collection of modules and code that attempts to wed the easily configured Tk 8 widget toolkit to the powerful lexigraphic, dynamic memory, I/O, and objectoriented capabilities of Perl 5 In other words, it is an interpreted scripting language for making widgets and programs with Graphical User Interfaces (GUI).

  • Tk, the extension(or module) that makes GUI programming in perl possible, is taken from Tcl/Tk Tcl(Tool Command Language) and Tk(ToolKit) was created by Professor John Ousterhout of the University of California, Berkeley Tcl is a scripting language that runs on Windows, UNIX and Macintosh platforms Tk is a standard addon to Tcl that provides
    commands to quickly and easily create user interfaces Later on Tk was used by a lot of other scripting languages like Perl, Python, Ruby etc.
Hello World:

Let us begin, as all other tutorials begin, with the "Hello World" program Create a file called "Hellopl" and enter the following into it.

#!/usr/local/bin/perl
use Tk;
# Main Window
my $mw = new MainWindow;
my $label = $mw -> Label(-text=>"Hello World") -> pack();
my $button = $mw -> Button(-text => "Quit",
-command => sub { exit })
-> pack();
MainLoop;


The first line
#!/ usr/local/bin/perl is not needed in windows In Linux, it tells the name of the script language processor In our case it is perl Don't understand what that means? Don't worry your gray cells over it Just put it at the top of the file

The second line use Tk; tells the interpreter that our program will use the Tk module This line is an absolute must in all GUI programs you make using perl When the interpreter encounters this line, it will load the Tk components that we will be using to create our program.
The third line This is a comment Any line that starts with a '#' char is a comment Comments are not of any use in the program It is used by programmer to talk to themselves A programmer cannot be expected to remember every thing a script does So he uses a comment to write it down Next time he edits the script, he can read the comment and understand what the program is for It is good practice to make as much comments as possible

The fourth line:                                                                                                                                           my $mw = new MainWindow;, will create a window into which the GUI elements will be placed The variable $mw is a object of type 'MainWindow' We will have to use this element when we want to place any widget inside it

The fifth line,   

$mw -> Label(-text=>"Hello World") -> pack(); makes a label and writes "Hello world" in it You can change the text to any thing you like Note the structure of the command $
label This variable assigned to that particular widget Ever widget must have a UNIQUE variable This name will be used when ever that widget must be accessed $mw -> $mw is the MainWindow's object We will be placing our label widget inside this window  Label(-text=>"Hello World") ' Label' is the name of the widget A widget is a user interface object in X graphical user interfaces Confused? Lets just say that it is the name of the object that appears on screen There are many other widgets too If you want to display a button, you use the button widget For text, you use the text widget For entry, you guessed it, the entry widget If you want, you can see more about widgets text=>"Hello World" The option for this widget This option says that this widget must be given the text "Hello World" Options change according to the widgets a button widget will not have all the options of the label widget and  vise versa But there will be many common ones Please note that operator used here is '=>' as opposed to the one used earlier '>' in $mw -> One uses the minus() sign while the other uses the equals(=) sign Do not confuse between these two You can keep writing other options can also be written here For example, let us make a label for showing the text "Hello World" The other lines are same as the Hello World program.


$mw -> Label(-text=>"Hello World",-font=>"courierfont",-relief=>"raised") ->
pack();

In this example, a lot more options are used The font option is used to tell which font must be used to make the text and the relief option tells whether the text should appear raised, sunken, flat etc To know all the options for a particular widget, read the manual that comes with Perl It lists every widget and every option they have If you are going to program in Perl, you will find your self peeking into the manual every few minutes The most important and most commonly used options are listed here All options must separated by a comma But as you have noted, this line is a little difficult to read As the number of options increase, the more difficult to read it So a more readable version is

$mw -> Label(-text=>"Hello World",-font=>"courierfont",-relief=>"raised")-> pack();

Next comes the -> pack(); This will pack the widget '$label' into the window '$mw' 'pack' is a geometry manager Another geometry manager is 'grid' Personally, I like grid better Once again, putting all this in one line is an eye sore so you can put this part in the next line


          my $label = $mw -> Label(-text=>"Hello World")-> pack();

In this case, pack has no options within it But that is not always the case


          my $label = $mw -> Label(-text=>"Hello World")-> pack(-side=>"left",-anchor=>'w');

You don't have to pack the widget in the same line of creating it but it is convenient in small programs You can pack the widget later using the widget's variable For example


my $label = $mw -> Label(-text=>"Hello World");
#We created the widget
$label -> pack(-side=>"left", -anchor=>'w');
#We pack it in another line


So we have the final syntax of how to create and display a widget
my $WidgetVariable = $Window -> WidgetType(?Option 1=>Value 1, ?Option 2=>Value2 ??)
-> pack();

The next three lines

my $button = $mw -> Button(-text => "Quit",-command => sub { exit })-> pack();

will create and display a button Here the widget variable is '$button' When we look at the options, we will find two options ' text' and 'command' The given text is Quit so the button will have the text "Quit" on it The command option determines what should happen when the user click on the button You can specify a function to execute when the user clicks on the button In this case the program will exit when this button is pressed One can also call functions that you
have created from here

#!/usr/local/bin/perl
use Tk;
# Main Window
my $mw = new MainWindow;
my $label = $mw -> Label(-text=>"Hello World") -> pack();
my $button = $mw -> Button(-text => "Quit",
-command =>\&exitProgam)
-> pack();
MainLoop;
sub exitProgam {
$mw->messageBox(-message=>"Goodbye");
exit;
}


The next line MainLoop:

is the Main Loop or the Event Loop Its job is to invoke callbacks in response to events
such as button presses or timer expirations If this line is missing, the program will run and exit with out waiting for the user to do any thing This is another one of those 'absolute musts' of Perl/Tk programming




Module Constructors and Destructors

PERL Constructors and Destructors:

Perl has constructors and destructors that work at the module level as well as the class level. The module constructor is called the BEGIN block, while the module destructor is called the END block. 

  • The BEGIN Block
  • The END Block
BEGIN BLOCK:

The BEGIN block is evaluated as soon as it is defined. Therefore, it can include other functions using do() or require statements. Since the blocks are evaluated immediately after definition, multiple BEGIN blocks will execute in the order that they appear in the script.
For Example (export.pl):
  • Define a BEGIN block for the main package.
  • Display a string indicating the begin block is executing.
  • Start the Foo package.
  • Define a BEGIN block for the Foo package.
The Perl code is (export.pl):
BEGIN {

    print("main\n");

}



package Foo;

    BEGIN {

        print("Foo\n");

    }
This program displays:
main
Foo
END BLOCK:
The END blocks are the last thing to be evaluated. They are even evaluated after exit() or die() functions are called. Therefore, they can be used to close files or write messages to log files. Multiple END blocks are evaluated in reverse order. 

END { 
print("main\n"); 

package Foo; 
END { 
print("Foo\n"); 
}

This program displays:

Foo 
Main 

Note: 

         Signals that are sent to your script can bypass the END blocks. So, if your script is in danger of stopping due to a signal, be sure to define a signal-handler function. See Chapter 13, "Handling Errors and Signals," for more information.




Dec 20, 2010

POD (Plain Old Documentation)

The perldoc program expects your documentation to be in POD format. The pod format has a few (very few) tags that you use to markup plain text. As an aside, the Perl compiler ignores POD commands so they can be used for extended comments inside your code.
Here is a list of some of the tags, with some HTML tags that are similar in spirit:
POD tag HTML equivalent Description
=head1 <H1> Primary heading.
=head2 <H2> Secondary heading.
=over N <UL> or <OL> Indent N spaces until it finds a =back tag. The convention is generally to indent in multiples of 4, so you see =over 4 a lot.
=back </UL> or </OL> Indicates that you are done with indenting.
=item <LI> Indicates a list item. The convention is to use =over to begin a list, and =back to end it. Generally you do =item *, which puts bullets in front of each list item.
=cut </HTML> Indicates the end of a POD section.
For more information on POD, type perldoc perlpod at a UNIX prompt. There's not much to POD, and it will behoove you to know it inside & out.

Example:

=head1 NAME

NewModule - Perl module for hooting

=head1 SYNOPSIS

  use NewModule;
  my $hootie = new NewModule;
  $hootie->verbose(1);
  $hootie->hoot;  # Hoots
  $hootie->verbose(0);
  $hootie->hoot;  # Doesn't hoot
  

=head1 DESCRIPTION

This module hoots when it's verbose, and doesn't do anything 
when it's not verbose.  

=head2 Methods

=over 4

=item * $object->verbose(true or false)

=item * $object->verbose()

Returns the value of the 'verbose' property.  When called with an
argument, it also sets the value of the property.  Use a true or false
Perl value, such as 1 or 0.

=item * $object->hoot()

Returns a hoot if we're supposed to be verbose.  Otherwise it returns
nothing.

=back

=head1 AUTHOR

Ken Williams (ken@mathforum.org)

=head1 COPYRIGHT

Copyright 1998 Swarthmore College.  All rights reserved.

This library is free software; you can redistribute it and/or
modify it under the same terms as Perl itself.

=head1 SEE ALSO

perl(1).

=cut

Packages and Modules in PERL and what is the difference between those

What are Packages?

  • A package is a collection of code which lives in its own namespace
  • A namespace is a named collection of unique variable names (also called a symbol table).
  • Namespaces prevent variable name collisions between packages
  • Packages enable the construction of modules which, when used, won't clobbber variables and functions outside of the modules's own namespace

The Package Statement

  • package statement switches the current naming context to a specified namespace (symbol table)
  • If the named package does not exists, a new namespace is first created.

$i = 1; print "$i\n"; # Prints "1"
package foo;
$i = 2; print "$i\n"; # Prints "2"
package main;
print "$i\n"; # Prints "1"
  • The package stays in effect until either another package statement is invoked, or until the end of the end of the current block or file.
  • You can explicitly refer to variables within a package using the :: package qualifier

$PACKAGE_NAME::VARIABLE_NAME

For Example:
$i = 1; print "$i\n"; # Prints "1"
package foo;
$i = 2; print "$i\n"; # Prints "2"
package main;
print "$i\n"; # Prints "1"

print "$foo::i\n"; # Prints "2"

BEGIN and END Blocks

You may define any number of code blocks named BEGIN and END which act as constructors and destructors respectively.
BEGIN { ... }
END { ... }
BEGIN { ... }
END { ... }
  • Every BEGIN block is executed after the perl script is loaded and compiled but before any other statement is executed
  • Every END block is executed just before the perl interpreter exits.
  • The BEGIN and END blocks are particularly useful when creating Perl modules.

What are Perl Modules?

A Perl module is a reusable package defined in a library file whose name is the same as the name of the package (with a .pm on the end).
A Perl module file called "Foo.pm" might contain statements like this.
#!/usr/bin/perl

package Foo;
sub bar { 
   print "Hello $_[0]\n" 
}

sub blat { 
   print "World $_[0]\n" 
}
1;
Few noteable points about modules
  • The functions require and use will load a module.
  • Both use the list of search paths in @INC to find the module (you may modify it!)
  • Both call the eval function to process the code
  • The 1; at the bottom causes eval to evaluate to TRUE (and thus not fail)

The Require Function

A module can be loaded by calling the require function
#!/usr/bin/perl

require Foo;

Foo::bar( "a" );
Foo::blat( "b" );
Notice above that the subroutine names must be fully qualified (because they are isolated in their own package)
It would be nice to enable the functions bar and blat to be imported into our own namespace so we wouldn't have to use the Foo:: qualifier.

The Use Function

A module can be loaded by calling the use function
#!/usr/bin/perl

use Foo;

bar( "a" );
blat( "b" );
Notice that we didn't have to fully qualify the package's function names?
The use function will export a list of symbols from a module given a few added statements inside a module
require Exporter;
@ISA = qw(Exporter);
Then, provide a list of symbols (scalars, lists, hashes, subroutines, etc) by filling the list variable named @EXPORT: For Example
package Module;

require Exporter;
@ISA = qw(Exporter);
@EXPORT = qw(bar blat);

sub bar { print "Hello $_[0]\n" }
sub blat { print "World $_[0]\n" }
sub splat { print "Not $_[0]\n" }  # Not exported!

1;

Create the Perl Module Tree

When you are ready to ship your PERL module then there is standard way of creating a Perl Module Tree. This is done using h2xs utility. This utility comes alongwith PERL. Here is the syntax to use h2xs
$h2xs -AX -n  Module Name

# For example, if your module is available in Person.pm file
$h2xs -AX -n Person

This will produce following result
Writing Person/lib/Person.pm
Writing Person/Makefile.PL
Writing Person/README
Writing Person/t/Person.t
Writing Person/Changes
Writing Person/MANIFEST
Here is the descritpion of these options
  • -A omits the Autoloader code (best used by modules that define a large number of infrequently used subroutines)
  • -X omits XS elements (eXternal Subroutine, where eXternal means external to Perl, i.e. C)
  • -n specifies the name of the module
So above command creates the following structure inside Person directory. Actual result is shown above.
  • Changes
  • Makefile.PL
  • MANIFEST (contains the list of all files in the package)
  • README
  • t/ (test files)
  • lib/ ( Actual source code goes here
So finally you tar this directory structure into a file Person.tar and you can ship it. You would have to update README file with the proper instructions. You can provide some test examples files in t directory.

Installing Perl Module

Installing a Perl Module is very easy. Use the following sequence to install any Perl Module.
perl Makefile.PL
make
make install
The Perl interpreter has a list of directories in which it searches for modules (global array @INC)