in reply to Re^2: two dice question
in thread two dice question

Or (with modular help) skip the multiple heredocs:

my $dice = YAML::Syck::Load( <<'EOT' ); --- - |- --------- | | | # | | | --------- - |- --------- | # | | | | # | --------- - |- --------- | # | | # | | # | --------- - |- --------- | # # | | | | # # | --------- - |- --------- | # # | | # | | # # | --------- - |- --------- | # # | | # # | | # # | --------- EOT print $dice->[int(rand(@{$dice}))], "\n";

(Using Anonymonk's better looking (IMHO) dice from below)

Replies are listed 'Best First'.
Re^4: two dice question
by ikegami (Patriarch) on Jul 17, 2007 at 17:12 UTC
    No need to learn and load a complex module for that!
    my @dice = split /^--\n/m, <<'EOT'; --------- | | | # | | | --------- -- --------- | # | | | | # | --------- -- ... -- --------- | # # | | # # | | # # | --------- EOT

      Ah, but then your dice have leading spaces in front of them. :)

      my @dice = map { (my $t = $_) =~ s/^\s+(?=\S)//gm; $t } split( /^--\n/ +m, <<'EOT' ); ... EOT

        The OP had the spaces too, so I presume they're supposed to be there.

        What's the purpose of (?=\S) in your regexp?