#!/usr/bin/perl # file: random.pl #always use warnings and strict use warnings; use strict; #useful for debugging, but turn off for production use CGI::Carp qw(carpout fatalsToBrowser); #path to your file my $quotes = 'file.txt'; # open for reading open(QUOTE, "$quotes") or die "Can't open $quotes: $!\n"; #read a random line my $line; srand; rand($.) < 1 && ($line = $_) while ; #splits on tab...change as needed my ($quote, $author) = split("\t", $line); #return output print "Content-type: text/plain\n\n"; print "$quote \n$author\n";