my @list = ( [0, 'Zero'], [1, 'One'], [2, 'Two'], [3, 'Three'], [4, 'Four'], [5, 'Five'], [6, 'Six'] ); SWITCH: for ($some_obj->get_status) { /0/ && do { @list = @list[0, 6]; last; }; /1/ && do { @list = @list[0..2]; last; }; /2/ && do { @list = @list[2..5]; last; }; /3/ && do { @list = @list[3]; last; }; /4/ && do { @list = @list[4]; last; }; /5/ && do { @list = @list[2, 5]; last; }; /6/ && do { @list = @list[6]; last; }; @list = (); } $"=', '; print "Result: status = ".$some_obj->get_status."; list=@list";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Use an array slices
by Hofmator (Curate) on Feb 28, 2003 at 09:30 UTC | |
|
Re: Use an array slices
by blakem (Monsignor) on Feb 28, 2003 at 09:31 UTC | |
by nite_man (Deacon) on Feb 28, 2003 at 14:38 UTC | |
by blakem (Monsignor) on Mar 01, 2003 at 00:37 UTC | |
by hypochrismutreefuzz (Scribe) on Mar 17, 2003 at 15:04 UTC | |
by TVSET (Chaplain) on Apr 28, 2003 at 07:14 UTC |