in reply to Re: Algorithm needed
in thread Algorithm needed

Or, just do it all at once:
my %hash = (); while (<DATA>) { # split based on spaces my ($hex, $foo, $int) = split /\s+/; $hash{$hex}{$int}++; } for (keys %hash) { print "$_ = ", join(", ", sort keys %{$hash{$_}}), "\n"; }

-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply.

Replies are listed 'Best First'.
Re: &bull;Re: Re: Algorithm needed
by sauoq (Abbot) on Dec 05, 2002 at 23:36 UTC
    split /\s+/;

    Do you recommend this as normal practice? I think the special case, split ' ', is usually what people really want. (Yes, this is a very minor point but I'm curious.)

    -sauoq
    "My two cents aren't worth a dime.";
    
        Yeah, I'd probably just change that to "split", no args, which is like split ' ', $_.

        Even better. Thanks for clarifying.

        -sauoq
        "My two cents aren't worth a dime.";