All pastes #196794 Raw Edit

Stuff

public text v1 · immutable
·published 2006-10-10 21:43 UTC
rendered paste body
#!/usr/bin/perl -w

use strict;

my @slogans;

# path to source file with all the slogans
my $sourcefile = "slogans.inc";

# path to the result-ile
my $resultfile = "slogan_day.inc";

# read sourcefile
open(FILE,"$sourcefile");
while(my $line=<FILE>) { if($line =~ m/^#/i) { next; } push(@slogans,$line); }
close(FILE);

# number of elements
my $counter = @slogans;

# random number
my $random = rand($counter-1);

# content
my $content = $slogans[$random];
chomp($content);
$content = "\<div id=\"motd\"\>$content\<\/div\>";

# write random slogan of the day into file
open(FILE,">$resultfile");
print FILE $content;
close(FILE);

# the end