#!/usr/bin/perl -w use strict; use Win32::OLE qw(in with); use Win32::OLE::Const 'Microsoft Excel'; my $Excel = Win32::OLE->new('Excel.Application', 'Quit'); my $sheet = $Excel->Workbooks->Open($ARGV[0])->Sheets->item("words"); # note to myself: add error handling here! my @words; foreach my $col('A'..'F') { my $row=1; my @list = (); my @value = (); do { @value= $sheet->Range("$col".$row++)->{'Value'}; if (defined ($value[0])) { push (@list, $value[0]); } } while(defined ($value[0])); push (@words, \@list); } my $rhyme = int(rand( scalar(@{$words[4]}) )); my $poem = $words[0][int(rand( scalar(@{$words[0]})))]." are ".$words[1][int(rand( scalar(@{$words[1]})))]." ".$words[2][int(rand( scalar(@{$words[2]})))]."?\n". "They're ".$words[2][int(rand( scalar(@{$words[2]})))]." and ".$words[2][int(rand( scalar(@{$words[2]})))]." ".$words[4][$rhyme].".\n". "And ".$words[2][int(rand( scalar(@{$words[2]})))]." and ".$words[2][int(rand( scalar(@{$words[2]})))]." and ".$words[2][int(rand( scalar(@{$words[2]})))].",\n". "Cause ".$words[2][int(rand( scalar(@{$words[2]})))]." ".$words[3][int(rand( scalar(@{$words[3]})))]." ".$words[5][$rhyme]."!\n"; print ("$poem\n"); $Excel->Speech->speak($poem); # let us hear it! exit 0; #Provide the name of an Excel-file as parameter! #Excel content (in a sheet called "words"): # # A B C D E F #Why the PerlMonks coding perl wisdom in vain is pain #Where the people hacking c-sharp like none is fun #How the fanboys smiling unix so fine takes time # great coders thinking posix # small thinkerslearning shell scripts # code monkeys asking java # writing # pasting # ...