Lists (HUMOR)

C. Abney cabney at cyberpass.net
Sat May 27 22:08:28 CDT 2000


~sdpm~
Well... I thought it was pretty funny. Thought I'd put Eugene's stuff in there.
And someone might even think it's useful, even if it is a joke <g>

(0)[0318]$ ln -s sail fail
(0)[0318]$ cat sail
#! /usr/bin/perl -w
# Sorts/tails monitor logs ascending, by timestamp, where log has format:
# 5/25/2000 17:28:37 HostA 2250.16 2136.20 0  0
# Changes behavior according to how it is called

use strict;

my $name = $0;
$name =~ s/^.*?([^\/]+)$/$1/;

my $numlines;

if ($#ARGV == 1) {
	$numlines = shift;
} else {
	$numlines = 10;
}

my $file = shift
	or die usage();

open DATA, "< $file"
	or die "could not open $file: $!";
my @log =  <DATA>;
close DATA
	or die "could not close $file: $!";

# How to check this is a number?
if ( @log < $numlines ) {
	$numlines = @log;
}
$numlines = -$numlines;

if ($name eq "sail") {
	@log = map {$_->[0]} sort {
		$a->[3] <=> $b->[3]
			||
		$a->[1] <=> $b->[1]
			||
		$a->[2] <=> $b->[2]
			||
		$a->[4] <=> $b->[4]
			||
		$a->[5] <=> $b->[5]
			||
		$a->[6] <=> $b->[6]
	} map { [$_,split /[\/\s+:]/] } @log;
}

print for (@log)[$numlines..-1];

sub usage
{
	return	"fail: A Fat tAIL\n",
		"  Usage:\n\t",
		"fail [n] <logfile>\n",
		"or\n",
		"sail: A Sorting(Slow) tAIL\n",
		"  Usage:\n\t",
		"sail [n] <logfile>\n";
}


CA
-- 
Einstein himself said that God doesn't roll dice. But he was wrong. And
in fact, anyone who has played role-playing games knows that God
probably had to roll quite a few dice to come up with a character like
Einstein.  -- Larry Wall                                     C. Abney


~sdpm~

The posting address is: san-diego-pm-list at hfb.pm.org

List requests should be sent to: majordomo at hfb.pm.org

If you ever want to remove yourself from this mailing list,
you can send mail to <majordomo at happyfunball.pm.org> with the following
command in the body of your email message:

    unsubscribe san-diego-pm-list

If you ever need to get in contact with the owner of the list,
(if you have trouble unsubscribing, or have questions about the
list itself) send email to <owner-san-diego-pm-list at happyfunball.pm.org> .
This is the general rule for most mailing lists when you need
to contact a human.




More information about the San-Diego-pm mailing list