#!/usr/bin/perl my $quotefile = "/my/quote/file/lives/here.txt"; my $separator = ""; ######################################## package randomizer; use FileHandle; use HTML::Entities; use vars '$line'; use strict; sub start { my $fh = FileHandle->new; $fh->input_file_separator( $separator ) if $separator; $fh->open( $quotefile ) or die "Open $quotefile: $!"; # see the Perl Cookbook for why this works rand($fh->input_line_number) < 1 && ($line = $_) while <$fh>; encode_entities( $line ); 1; } 1; # start(); print $randomizer::line;