>>>>> "AG" == Agnello George <agnello.dso...@gmail.com> writes:
AG> is there a better way of writing this script this is not a script but a short code snippet. there are many ways to redo this. many questions could be asked as well. AG> my @resultss = qw( 0 1 2 3 4 5 ) ; is that always a fixed list? could @jvalue have more then 6 entries? if you want all of @jvalue you don't need @resultss at all. AG> foreach ( @resultss) { foreach ( 0 .. 5 ) { or if you want all of @jvalue: foreach ( 0 .. $#jvalue ) { and you should use a named var for the loop counter: foreach $j_ind ( 0 .. $#jvalue ) { AG> if ( defined( $jvalue{$_}){ AG> $status .= $jvalue{$_} ; AG> } AG> } that part is just getting the defined values from an array. grep is a way to do that with a list. join can merge them and then you append them to $status. now we don't even need the loop counter: $status .= join( '', grep defined, @jvalue ) ; that is the whole thing in one fairly clear line of code. perl is very nice this way. uri -- Uri Guttman ------ u...@stemsystems.com -------- http://www.sysarch.com -- ----- Perl Code Review , Architecture, Development, Training, Support ------ --------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com --------- -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/