> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] Behalf Of
> steve silvers
> Sent: Tuesday, August 12, 2003 9:53 AM
> To: [EMAIL PROTECTED]
> Subject: What is wrong with this?
> 
> 
> I don't understand why the output of the below snippet kind 
> of blows up..
> 
> --TEXT FILE test.txt--
> 
> 03|04|09|14|15|18|24|27
> 09|23|24|26|27|28|33|35
> 10|11|13|15|17|18|19|22
> 07|08|13|17|22|23|24|25
> 03|06|07|08|11|12|16|17
> 02|05|06|09|12|18|19|22
> 
> --SCRIPT
> 
> #!Perl -w
> 
> use strict;
> use vars qw(%counts $numbers @numbers);
> 
> open(FILE,"test.txt") || die "Can't open file $^E";
> while(<FILE>) {
>       push(@numbers, split(/\|/,$_));
> }
> close(FILE);
> 
> # ---------------------
> # Get Count..
> 
> $counts{$_}++ foreach @numbers;
> 
> foreach (sort { $counts{$b} <=> $counts{$a} } keys %counts) {
>       print qq( $_ - $counts{$_} \n);
> }
> 
> 
> -- RESULTS --
> 
> 18 - 3
> 24 - 3
> 09 - 3
> 07 - 2
> 23 - 2
> 15 - 2
> 08 - 2
> 17 - 2
> 19 - 2
> 03 - 2
> 11 - 2
> 12 - 2
> 13 - 2
> 06 - 2
> 22 - 2
> 22
> - 1
> 25
> - 1
> 17
> - 1
> 35
> - 1
> 27
> - 1
> 02 - 1
> 05 - 1
> 16 - 1
> 33 - 1
> 04 - 1
> 26 - 1
> 10 - 1
> 14 - 1
> 27 - 1
> 28 - 1
> 
> 
> Why do the last numbers as it seems is blowing out and not 
> keep a nice form 
> like the rest of the results?
> It seems likes it's just the last numbers?
> 

@numbers is getting the carriage returns...
while(<FILE>) {
        chomp;  #<<<<<<<<<<<< 
        push(@numbers, split(/\|/,$_));
}

hth...Lynn.
_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to