in reply to Sorting Issue
here you have a variable to which you apply a series of substitutions, (incidentally it is customary to write
when you have a long series of of substitutions - much cleaner IMHO).for ($status) { s/P|F|C|D|I/Posted/g; s/A/Accepted/g; s/N/New/g; s/R/Rejected/g; s/S/Save/g; s/X/Canceled/g; }
Update: contrary to what I wrote above, in this particular case I'd probably do something along the lines of (untested):
my %subst={ A => 'Accepted', N => 'New', R => 'Rejected', S => 'Save', X => 'Canceled' }; $subst{$_}='Posted' for qw/P F C D I/; $status =~ s/[A-Z]/$subst{$&}||$&/ge;
Note to the update: I am aware of the gotchas about $& & C. My gut feeling is that people overestimate them. Personally I'm not a fanatic of its use, but happen to resort to it every now and again...
Then you create an array containing only (the value of) that variable and sort it, which is an immaterial operation, since it has only one entry in any case.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Sorting Issue
by Anonymous Monk on Jul 26, 2005 at 13:57 UTC | |
by polettix (Vicar) on Jul 26, 2005 at 14:20 UTC | |
by Anonymous Monk on Jul 26, 2005 at 16:49 UTC | |
by polettix (Vicar) on Jul 26, 2005 at 16:59 UTC | |
by Anonymous Monk on Jul 26, 2005 at 17:35 UTC | |
by blazar (Canon) on Jul 26, 2005 at 14:01 UTC | |
by Iron (Scribe) on Jul 26, 2005 at 14:02 UTC | |
by blazar (Canon) on Jul 26, 2005 at 14:18 UTC | |
by Anonymous Monk on Jul 26, 2005 at 14:00 UTC |