in reply to Re: Print out random words with HTML
in thread Print out random words with HTML

Turns out you need more than just
'$array[rand @array]'
Having
$array = $array[ rand @array ]; $array2 = $array2[ rand @array2 ];
does it.
#!/usr/bin/perl #use strict; my @array = ('words', 'will', 'go', 'here'); my @array2 = ('words2', 'will2', 'go2', 'here2'); $array = "$array[rand@array]"; $array2 = $array2[rand@array2]; { print "Content-Type: text/html\n\n"; print <<EOM; <H1>$array</H1> <HR> <H1>$array2</H1> EOM exit; }

Replies are listed 'Best First'.
Re^3: Print out random words with HTML
by Athanasius (Archbishop) on Oct 12, 2016 at 05:19 UTC

    Hello Jesse Smith,

    Actually AnomalousMonk’s approach works fine:

    use strict; use warnings; my @array1 = qw( QUICK BROWN FOX ); my @array2 = qw( JUMPED UNFORTUNATE DOG ); print <<EOM; <P> The random words can go anywhere... <br> random $array1[ rand @array1 ] words $array2[ rand @array2 ] here <br> Footer text can go here!!! </P> EOM

    Output:

    Why do you think otherwise?

    Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,