[Ilugc] [TIP] perl tutorial X (some code tidbits)

  • From: girishvenkatachalam@xxxxxxxxx (Girish Venkatachalam)
  • Date: Mon, 12 Dec 2011 08:21:38 +0530

Hope you are familiar with the programming language by now.

If some of you still dunno how to execute a simple perl script,
please remember this.

$ perl foo.pl

$ cat foo.pl
for(1..1000) {
          print; print "\n";
}

You can easily accomplish many difficult tasks in text processing
 with perl even without using any regular expressions.

You can easily convert all input into upper case:

$
$ cat i.pl
while(<>) {
   print uc;
}

Perl's documentation is written in plain old documentation format (POD)
 which can be converted into pdf, text and of course the nroff man format.

You can find all these converters:

$ pod2
pod2html   pod2latex  pod2man    pod2test   pod2text   pod2usage

Perl's POD documentation can either be invoked using:

$perldoc foo.pl

if the file contains the documentation inline or even if the file that contains
 pod is in the standard search location.

$perldoc perltoc

will tell you all the topics covered by perl's installed documentation.

It is huge, massive and no amount of reading will help you learn perl
unless you
 really get down to trying perl and running it.

Perl cannot be run interactively like Python. You have to run it one
script at a time.

All perl functions are written in the perlfunc man page.

$perldoc perlfunc

But it is useless. Instead you say

$perldoc -f split

or

$ perldoc -f join

or some such thing.

Some of the perl functions you can learn today are

1)map
2) tr
3) substr
4) push
5) shift
6) pop
7) keys
8) values
9) pack
10) ord

Just google and try out the examples.

-Girish

-- 
G3 Tech
Networking appliance company
web: http://g3tech.in ?mail: girish at g3tech.in

Other related posts: