caciqueman has asked for the wisdom of the Perl Monks concerning the following question:
However, no matter what I try, I cant seem to get the print line to work the way I would like. When I use this:open(INF,"$Dir/log.txt") or dienice("Can't open logs: $! \n"); @stats = <INF>; close(INF); foreach $i (sort byrate @stats) { chomp($i); ($rate,$team,$comment,$gotdate) = split(/\|/,$i); print "$rate $team $comment\n"; print "<br>"; print "$ip $gotdate\n"; print "<br><br>"; } sub byrate { @a = split(/\|/,$a); @b = split(/\|/,$b); $b[0] <=> $a[0]; }
Can anyone help this newkid out ? Thanks.print "[$rate] [$team] $comment\n"; print "<br>"; print "$ip $gotdate\n"; print "<br><br>"; or this: print "($rate) ($team) $comment\n"; print "<br>"; print "$ip $gotdate\n"; print "<br><br>"; it prints out the list in the correct order, that is numerically with the highest rate on top, BUT after it prints the rows out, it then prints an equal amount of these: [][] [][] [][] or these ()() () () etc. I tried stripping spaces or newlines, tried using a if $i > 0 or if exists ($rate) with no success.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Sort ofa Print Problem
by gav^ (Curate) on Apr 26, 2002 at 02:08 UTC | |
by caciqueman (Novice) on Apr 26, 2002 at 03:08 UTC | |
|
Re: Sort ofa Print Problem
by graff (Chancellor) on Apr 26, 2002 at 04:46 UTC | |
|
Re: Sort ofa Print Problem
by Fletch (Bishop) on Apr 26, 2002 at 02:11 UTC |