Why are the PerlMonks working?
They're hacking and golfing so fine.
And thinking and singing and smiling,
Cause seeking perl wisdom takes time!


Dear fellow monks!
Above is an exemplary output of my perl poetry generator, a small piece of code I wrote to learn about multi-dimensional arrays and Win32::OLE::Excel.
It is a port of a Pascal-program I created ~20 years ago ... any hint on how may I make it more "perlish"?
best regards
Rata

#!/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]})))]." an +d ".$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(ran +d( scalar(@{$words[2]})))].",\n". "Cause ".$words[2][int(rand( scalar(@{$words[2]})))]." ".$w +ords[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 # ...

In reply to poetry generator (playing with Win32::OLE::Excel ) by Ratazong

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.