Example 1 - System administration

With it's file handling, pattern matching and reporting facilities, Perl has proven to be a superb system administration/maintenance tool. Typical uses that are well suited to Perl include:

A last log analyser

Perl is ideal for analysis and reporting of the multitude of log files and other text files that abound on any typical Unix system.

For example, here is a very simple script that reports the number of logins for each user, with the resulting example output:

  User      Count
  --------  -----
  ftp       2
  david     25
  graeme    606
  marg      16
  nick      20
  reboot    54
  root      62
  runlevel  27
  shutdown  24
  tracy     123
  wtmp      1

Next - Perl & Linux Updated: 5 December, 1995