![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Tips and Tutorials Helpful articles from our Users. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Newbies problem | greenhorn | UNIX for Dummies Questions & Answers | 8 | 11-17-2008 11:37 AM |
| I am one of the newbies, please advise | sanlen | UNIX for Dummies Questions & Answers | 3 | 09-17-2007 07:45 AM |
| CPAN: using only wget to d/l modules? | dangral | Shell Programming and Scripting | 2 | 07-12-2007 12:49 PM |
| CYGWIN/CPAN install of Expect.pm | white222 | UNIX for Dummies Questions & Answers | 1 | 07-20-2005 08:27 PM |
| Specially for unix newbies | clemeot | UNIX for Dummies Questions & Answers | 2 | 09-11-2001 12:16 PM |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
PERL & CPAN Intro for Newbies
So you want to learn a unix scripting language that you'll be able to use in any situation? Perl is your answer !
This is a little intro to installing CPAN modules. If you don't know what CPAN is, check out http://search.cpan.org/. Basicly, it is a massive archive of perl libraries that will allow you to do pretty much anything. (Once I wrote a shoutcast-style streamer in perl with a web front end, automatic down sampling and ogg->mp3 conversion, but that is a whole other story.) Using CPAN is easy. Code:
-su-2.05b# perl -MCPAN -e shell /usr/local/lib/perl5/5.8.2/CPAN/Config.pm initialized. ... The -e flag tells perl to execute a command. In this case, the CPAN module exports a function called 'shell'. When you first run the CPAN shell, it'll ask you a bunch of questions about where to find a mirror, and what tar program to use, etc. You can use defaults if you don't know the answer to some of the questions. Once you are at the cpan> prompt, you can start issuing commands. '?' will list all the commands. Code:
cpan> ? Display Information command argument description a,b,d,m WORD or /REGEXP/ about authors, bundles, distributions, modules i WORD or /REGEXP/ about anything of above r NONE reinstall recommendations ls AUTHOR about files in the author's directory Download, Test, Make, Install... get download make make (implies get) test MODULES, make test (implies make) install DISTS, BUNDLES make install (implies test) clean make clean look open subshell in these dists' directories readme display these dists' README files Other h,? display this menu ! perl-code eval a perl command o conf [opt] set and query options q quit the cpan shell reload cpan load CPAN.pm again reload index load newer indices autobundle Snapshot force cmd unconditionally do cmd Lets start with a simple search. Lets say I want to find a module that will let me encrypt and decrypt messages using a blowfish cipher. I would use one of the search commands 'a, b, d, m or i' (Author, Bundle, Distribution, Module or Any). Since I know I want a module, I'll use 'm'. Code:
cpan> m /blowfish/ Module Crypt::Blowfish (D/DP/DPARIS/Crypt-Blowfish-2.09.tar.gz) Module Crypt::Blowfish_PP (M/MA/MATTBM/Crypt-Blowfish_PP-1.12.tar.gz) Module Net::SSH::Perl::Cipher::Blowfish (D/DR/DROLSKY/Net-SSH-Perl-1.25.tar.gz) 3 items found By convention, some module that are written in pure perl (no extra binary code) have a _PP postfix. Pure Perl modules are often slower then their binary counterparts, but are often more compatible and easier to install as they have no other dependancies (not even a C compiler). So I'll decide to go with the slower, easier to install version since it'll only be used to in my small program for encrypting and decrypting small amounts of data. Code:
cpan> install Crypt::Blowfish_PP Running install for module Crypt::Blowfish_PP Running make for M/MA/MATTBM/Crypt-Blowfish_PP-1.12.tar.gz ... Writing /usr/local/lib/perl/5.6.1/auto/Crypt/Blowfish_PP/.packlist Appending installation info to /usr/local/lib/perl/5.6.1/perllocal.pod /usr/bin/make install -- OK I need to learn the API, so I'll go to http://search.cpan.org and search for the new module I just installed. It leads me to a nicely formatted manual-like page (http://search.cpan.org/~mattbm/Crypt...Blowfish_PP.pm) Now, I am not going to write a simple encrypt/decrypt tool for you (unless you really bug me to), needless to say, it's easy to do. Infact, less then 15 lines of code should do it. The point is, CPAN is easy to use, the modules are often great, and most importantly, its fun because you can do alot with very little. |
| Sponsored Links | ||
|
|
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|