Perl Monk, Perl Meditation | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
I don't see the need for declaring your variables on one line and assigning to them on the next, or the if/else as you could do ...
... to reduce 9 lines of code to just 2. Granted, that destroys the value of $qty in the process, but it's easy to preserve by substituting for 1 .. $qty (as Mirod suggests) for the while $qty--. You may also want to tighten up your regular expression (the .*-thing has been beaten to death), especially if the only optional argument following the second number is an 's'. As an alternative to the use of a regexp to pass arguments though, I'd personally be more inclined to pass them seperately rather (ie, grab( -dice => 3, -sides => 6, -face => 0 ); or even grab( qw( 3 d 6 s ) );), possibly coupling them with defaults if they aren't set. --k. In reply to Re: BWTDI: Better Way To Do It?
by Kanji
|
|