in reply to Print out random words with HTML

Here-docs use "standard" double-quotish interpolation, so I don't see why

print <<EOM; <P> The random words can go anywhere... <br> random $array[ rand @array ] words $array2[ rand @array2 ] here <br> Footer text can go here!!! </P> EOM
wouldn't work. Have you tried it?


Give a man a fish:  <%-{-{-{-<

Replies are listed 'Best First'.
Re^2: Print out random words with HTML
by Jesse Smith (Acolyte) on Oct 12, 2016 at 05:07 UTC
    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; }

      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,