while (<DATA>){
chomp;
($itemone) = split/,/; #split at comma
$seen{$itemone}++;
}
foreach my $element (sort { $a <=> $b} keys %seen){
print "$element\n";
}
exit;
__DATA__
1,ABC,X,1.203000e+02
1,ABC,Y,7.830000e+00
2,DEF,X,1.212400e+02
2,DEF,Y,8.810000e+00
3,GHI,X,1.180700e+02
3,GHI,Y,8.550000e+00
5,JKL,X,1.193500e+02
5,JKL,Y,7.270000e+00
you forgot to look at the
keys for the seen hash, also look how I used $_ those chomp lines etc were real ugly.
-Waswas
-
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.