in reply to Re: sub routine to sort per time
in thread sub routine to sort per time

Thanks a lot moritz, I updated the messages several times, sorry for the trouble

However, I can't understand why $n is 0

my %in; while (<$INFILE>){ m[(\d\d:\d\d) (.+)$] and push @{ $in{ $1 } }, $2 ; print STDOUT "1 is $1\n"; print STDOUT "2 is $2\n"; } my @keys = keys %in; my @times = sort @keys; foreach my $hr (@times) { print STDOUT "hr is $hr\n"; my $n = $#{ $in{ $hr } }; } __DATA__ 11:10 A1 11:30 E4 11:30 Z4 11:50 H5 12:02 H6 12:25 B2 12:25 A8 12:30 F3 12:30 E7 12:50 E15 12:55 E16

Replies are listed 'Best First'.
Re^3: sub routine to sort per time
by moritz (Cardinal) on Nov 26, 2008 at 10:53 UTC

    Update: OP changed, so this might not be of relevance any more.

    I'm sorry, but I can't read your mind. I don't see a problem in the code you show, and stating that there is one doesn't help me to identify it.

    Is a cloaked ninja attacking you every time you run this program? If not, of what nature is that problem?

    If your output is not what you expect, you have to tell us what your input and your expectations are.

    Please read I know what I mean. Why don't you?.

Re^3: sub routine to sort per time
by BrowserUk (Patriarch) on Nov 26, 2008 at 11:05 UTC
Re^3: sub routine to sort per time
by moritz (Cardinal) on Nov 26, 2008 at 11:02 UTC
    However, I can't understand why $n is 0
    Well, it's not always, at least not if I run your code and actually read from <DATA>. If there's one item in the array, it contains 0, which is the last index in the array. What do you want it to contain?