[Ilugc] perl again

  • From: girishvenkatachalam@xxxxxxxxx (Girish Venkatachalam)
  • Date: Mon, 24 Dec 2012 15:05:18 +0530

More and more perl.

Perl stands for practical extraction and reporting.

It was written by Larry Wall, JPL programmer. Tcl was written by John
Ousterhout and Python by
 Guido von Rossum.

Lua was created in Brazil. It is used in gaming, embedded systems, has
a very easy interface to C
 and is an amazing language. But unfortunately I am yet to learn it.

Perl is tougher to learn since it is tightly tied to UNIX and genius
in a lot of ways.

One requires a deep appreciation of computers, algorithms, protocols,
OS and so on to make good
 use of it.

In a lot of ways Perl is like UNIX.

Let us consider some code to find a file.

Use the file command right?

No.

You can of course evoke shell commands from inside perl using,

backticks, '`' or system() or exec() or readpipe().

But you have functions for grep, basename and so on inside perl itself.

So find is done by reading:

$ perldoc File::Find

File::Find(3p)         Perl Programmers Reference Guide         File::Find(3p)

NAME
       File::Find - Traverse a directory tree.

SYNOPSIS
           use File::Find;
           find(\&wanted, @directories_to_search);
           sub wanted { ... }

           use File::Find;
           finddepth(\&wanted, @directories_to_search);
           sub wanted { ... }

           use File::Find;
           find({ wanted => \&process, follow => 1 }, '.');

DESCRIPTION
       These are functions for searching through directory trees doing work on
       each file found similar to the Unix find command.  File::Find exports
       two functions, "find" and "finddepth".  They work similarly but have
       subtle differences.

Refer to man for more details.

Copy paste examples and have fun.

-Girish

-- 
Gayatri Hitech
http://gayatri-hitech.com

Other related posts:

  • » [Ilugc] perl again - Girish Venkatachalam