>>>>> "BF" == Brian Fraser <[email protected]> writes:
BF> On Fri, Apr 29, 2011 at 4:27 AM, Agnello George <[email protected]>wrote: >> Hi All >> >> is there a better way of writing this script >> >> BF> "Better" is fairly subjective - And with only a part of the program, there BF> isn't much that can be said. Is $status a global variable, or lexical? BF> On the other hand, if you mean more idiomatic way.. That's also subjective BF> :P But here's my stab at it: BF> my $status = join '', grep defined $jvalue{$_}, qw( 0 1 2 3 4 5 ); to pick a nit, the OP had $status .= also why use qw for sequential numbers when a range will do? so you can streamline yours with a slice: my $status = join '', grep defined, @jvalue{ 0 .. 5 } ; the only difference from mine is your is limited to the first 6 elements and my used the whole array. without more from the OP you can't tell which one is better suited. uri -- Uri Guttman ------ [email protected] -------- http://www.sysarch.com -- ----- Perl Code Review , Architecture, Development, Training, Support ------ --------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com --------- -- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected] http://learn.perl.org/
