in reply to BWTDI: Better Way To Do It?

my ( $qty, $type, $face ) = shift =~ m/(^\d+)d(\d+)(.*s$)?/i or croak +"Invalid parameters to Dice::Dice->grab: $!"; $face &&= 1; my @dice = map Die->get($type,$face), 1..$qty; return bless { dice => \@dice }, $class;

Replies are listed 'Best First'.
Re: Re: BWTDI: Better Way To Do It?
by coreolyn (Parson) on Jan 15, 2001 at 00:34 UTC

    Ok so it works and I've been playing with

    $face &&= 1;
    and I think finally get how that's working. (Never used && outside of a conditional before -- cool). But I don't see how it's not popping a 'uninitialized warning' on $face in the map statement when I supply '3d6' as an arg as opposed to 3d6s. If I pop a debugging
    print "$face\n";
    afterwords it does pop an unitialized warning, and I would have expected it to print a '0'.

    coreolyn -- arm tired from head scratchin :)

      Die->get checks if ( $faced && $faced == 1 ) {
Re: Re: BWTDI: Better Way To Do It?
by coreolyn (Parson) on Jan 14, 2001 at 22:52 UTC

    Damn! Now that's efficiency! I was trying to get that (.s$)? forever! I knew that dot star was bad but couldn't get it to work any other way. Thanks :)

    I'm still worried that it'll blow under -w for an undef'd $face, but I'm off to play.

    coreolyn

Re: Re: BWTDI: Better Way To Do It?
by chipmunk (Parson) on Jan 15, 2001 at 09:13 UTC
    Er... I don't think you want to include $! in that error message... :)

    ($! should only be used after an error return that indicates a system error.)