in reply to Grep question

Not sure why you need to "pop the rest". If all you're trying to do is find the index of the status value itself, what's wrong with:
my %statusoption = ( "Waiting Approval" => 0, "Denied" => 1, "Approved" => 2, "Ordered" => 3, "Building" => 4, "Built" => 5, "Shipped" => 6, ); my $statusoption = $statusoption{$status};
This assumes an item can't have more than one status, but since you're using a scalar to hold it that's not a bad assumption.

Replies are listed 'Best First'.
Re^2: Grep question
by hok_si_la (Curate) on Feb 03, 2005 at 18:16 UTC
    I will post the more code to give you guys a better idea of what I am trying to accomplish. I have no problem getting this to work, but I have been cleaning it up a bit. Originally it was about 40 lines, and now I have it down to this. In the process I am learning about perl Data structures.

    ###--- Define options for select Status ---### @statusoption = ('Waiting Approval' , 'Denied' , 'Approved' , 'Ordered +' , 'Building' , 'Built' , 'Shipped'); if ($purchase eq "Already Have") { delete @statusoption[3]; } if ($purchase eq "Virtual Machine") { delete @statusoption[3]; delete $statusoption[6]; } @statusoption = grep {$found++ if $_ eq $status; $found } @statusoptio +n; ###----------------------------------------###
      Actually the code is as follows
      ###--- Define options for select Status ---### @statusoption = ('Waiting Approval' , 'Denied' , 'Approved' , 'Ordered +' , 'Building' , 'Built' , 'Shipped'); if ($purchase eq "Already Have") { delete $statusoption[3]; } if ($purchase eq "Virtual Machine") { delete $statusoption[3]; delete $statusoption[6]; } @statusoption = grep {$found++ if $_ eq $status; $found } @statusoptio +n; ###----------------------------------------###