#!/usr/bin/perl -w use strict; my $homedir = $ENV{HOME}; my $file; if ( $ARGV[0] ) { $file = $ARGV[0]; } else { $file = "$homedir/.taglines"; } open(TL, "$file") || die "$file could not be read: $!\n"; my $tags = 0; while() { $tags++ if /^%$/; } my $which_tag = int(rand($tags)); $tags = 0; seek(TL, 0,0); while() { if(/^%$/) { $tags++; if($tags > $which_tag) { exit(0); } } elsif(/^;/) { } elsif($which_tag == $tags) { print("$_"); } } exit(0);