[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl] going backwards



say we have an array like...
@weekdays = (mon, tues, wed, thurs, fri, sat, sun);
....and we do $weekdays[0] we get "mon", no problems. But is there a simple way to go backwards from "mon" to get "0" without testing every value in the array? The best I've come up with so far is to have a hash...
%weekdays = (mon => 0, tues => 1, wed => 2, thurs => 3, fri => 4, sat => 5, sun => 6);
.... and do $weekdays{mon} to get "0". But for what I'm doing I'd like not to have an inverse hash for all the arrays.

le meas,
--Nick
# ===== Want to unsubscribe from this list? # ===== Send mail with body "unsubscribe" to macperl-request@macperl.org