in reply to Creating comma-delimited lists
Update: Oh, and if you just wanted to have it print certain elements, just pass it an array slice. For example,sub iknow { if ( @_ > 1 ) { print "I know about ", join( ', ', @_[0 .. @_ - 2] ), ", and $_[-1].\n"; } elsif ( @_ == 1 ) { print "I know about @_.\n"; } else { print "I don't know bout nuthin.\n"; } }
should print out "I know about one, three, and five."my @array = ( one, two, three, four, five ); iknow( @array[1, 3, 5] );
|
---|