in reply to Grep question
Update: No need for splice when you just want a slice:@statusoption = splice(@statusoption, (grep $statusoption[$_] eq $status, 0..$#statusoption)[0]);
Update: But splice is better than reassignment:@statusoption = @statusoption[ (grep {$status eq $statusoption[$_]} 0..$#statusoption)[0] ..$#statusoption];
Here's one that will short-circuit :-D:splice(@statusoption, 0, (grep $status eq $statusoption[$_], 0..$#stat +usoption)[0]);
splice(@statusoption, 0, &{sub { grep {$status eq $statusoption[$_] and return $_} 0..$#statusop +tion }} );
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Grep question
by hok_si_la (Curate) on Feb 03, 2005 at 18:12 UTC | |
by Roy Johnson (Monsignor) on Feb 03, 2005 at 18:19 UTC | |
by hok_si_la (Curate) on Feb 03, 2005 at 19:11 UTC |