#!/usr/bin/perl sub get_random_line { my ($file) = @_; my $line; # inscrutable random line algorithm -- from the camel book # $. is the number of the last line accessed open FORTUNES, "$BUCKY_FORTUNES/$file" or error("Could not access fortune $file"); srand; rand($.) < 1 && ($line = $_) while ; close FORTUNES; chomp $line; return $line; } 1;