in reply to simple array condition

i'm not exactly sure what you're looking for.
will something like this work?

if( defined @array[9..13] ) { for( @array[9..13] ) { my_sub( $_ ) if $_ ne ''; } }

~Particle ;Þ

Replies are listed 'Best First'.
Re: Re: simple array condition
by kappa (Chaplain) on Apr 04, 2002 at 14:31 UTC
    There's something very wrong happening or I am smoking crack.
    @array[9..13] is an array slice which evaluates to a list which in turn evaluates to its last component in scalar context!
    So defined @array[9..13] is just an equivalent of defined($array[13]), is it not???
      you are indeed correct. my code's been a little off lately. i'm a little out of practice, stuck in ksh all day. correct (but a little hard to read) would be:

      defined $_ && $_ ne '' && my_sub($_) for @array[9..13];

      ~Particle ;Þ