Hi rizzler,
I think this may help you,
my %quantity=(YEAR => 5, MONTH => 4, WEEK => 3, DAY => 2, HOUR =>1);
my $a1="A,Star_1GB,MONTH,1000,0";
my $b1="B,Unlim60,MONTH,1000,6000";
my $b2="B,Unlim60,YEAR,1000,6000";
my $c1="C,Unlim,DAY,50,6000";
my $c2="C,Unlim,HOUR,50,6000";
my $d1="D,,MONTH,500,8000";
my @vals = ($a1, $b1, $b2, $c1, $c2, $d1);
@vals = map{$_->[0]} sort{$quantity{$b->[1]} <=> $quantity{$a->[1]}} s
+ort{$b->[2] <=> $a->[2]} sort{$b->[3] <=> $a->[3]} map{[$_, /(YEAR|MO
+NTH|WEEK|DAY|HOUR),([^,]*),([^,]*)$/i]} @vals;
print join("\n",@vals);
Output will be:
B,Unlim60,YEAR,1000,6000
B,Unlim60,MONTH,1000,6000
A,Star_1GB,MONTH,1000,0
D,,MONTH,500,8000
C,Unlim,DAY,50,6000
C,Unlim,HOUR,50,6000
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.