Wednesday, August 8, 2007

Perl Tips

  1. Installing perl modules on Windows NT having Activestate perl

METHOD 1

1. COMPRESS

You can use WinZip (shareware) to decompress and unpack modules

2. BUILD

Does the module require compilation (i.e. does it have files that end in .xs, .c, .h, .y, .cc, .cxx, or .C)? If it does, you're on your own. You can try compiling it yourself if you have a C compiler. If you're successful, consider uploading the resulting binary to the CPAN for others to use. If it doesn't, go to INSTALL.

3. INSTALL

Copy the module into your Perl's lib directory. That'll be one of the directories you see when you type perl -e "print qq(@INC)" Usually C:\utils\Perl\site\lib


METHOD 2

ActiveState Perl comes with a command-line tool called PPM - the Perl Package Manager - that simplifies the process of installing Perl modules on NT. To get into the PPM, go to a DOS prompt, and type

ppm


You should now see a prompt that looks like:

PPM>

at which you can type commands. There are a large number of commands that you can use, and there is very good documentation for PPM that comes with your distribution of Perl, so I'll just talk about two of the functions - searching for a module, and installing that module.

To search for a module, use the search function:

search Time

The search should, by default, be case-insensitive, although you can configure this.

This will return a list of all the modules that matched this search, and the file that the module is contained in. You can then install the module with the install command

install Time-modules


PPM will take care of downloading and installing the module for you.


2. To Un-Install a package

remove the .pkg and .ppd files from C:\Utils\Perl\site\lib\ppm-conf

3. Getting information from a secure site using SSL over HTTP

Here is the Link

4. Using OLE Automation with perl (Excel Object Model etc)

OLE Automation

5. See what is the include path on perl

Get the INC variable

perl -e "print qq(@INC)

6. Multiline Comment

<<'#';

this is a

multiline

comment

#

(Note that this hash character has to be the first character and the only one in that line)

7. Profiling perl scripts

>perl -d:DProf myscript.pl

Followed by

>dprofpp

Will tell you what functions take how much time in myscript.pl


8. Exit Windows

perl -MWin32::AdminMisc -e "Win32::AdminMisc::ExitWindows(EWX_REBOOT|EWX_FORCE);"


9. Links

http://www.rcbowen.com/imho/

http://www.comp.leeds.ac.uk/Perl/scalars.html#operations

http://software.techrepublic.com.com/

CPAN

Christopher Willmot

Finance::BDT

Finance::YahooProfile

Finance::YahooQuote




"Woeful Wails" - My Dad's account of what happened in 1989 at Srinagar, Kashmir

A Shiver, a shudder goes down my spine To have lost what once was mine The merciless devils who strode the streets With guns pointing at u...