I am in my learning stages of perl and I am creating a website that implements my progress. This is a script that obviously prints my quote of the day. My question is really a request for comments on my approach. Am I doing anything extra that could be left out? What can I do to improve this? I played around with rand() a bunch of ways until I found out I could use rand the way I did. I know this is a simple script, but I think starting out small is good so I can move what I learn to the bigger scripts :)
Methods I used prior to final choice:
srand;
$index = rand(0..10);
print "$quotes[$index]";
----------
srand;
@rquotes = rand(@quotes);
print "$rquotes[3]";
.... and some others you can see I went through some testing and retesting of ideas until I got one that worked, so I just want to know if my methods are good for learning perl better. Basically I would just like any comments, tips, or criticisms from all. :)
#!/usr/bin/perl -w
use strict;
srand;
my $quotes_file = '../quotes/quotes.txt';
open (QFILE, "<$quotes_file")
|| die "Error: could not open $quotes_file:$!\n";
my @quotes = <QFILE>;
my $quote = $quotes[rand(@quotes)];
print "Content-Type: text/html\n\n";
print "$quote";