Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: summarization of list

by ayrnieu (Beadle)
on Mar 15, 2006 at 03:16 UTC ( #536767=note: print w/replies, xml ) Need Help??


in reply to summarization of list

#! /usr/bin/env perl use strict; use warnings; my %numbers = qw/210 rg1000 212 rg1000 214 rg1000 215 rg1000 218 rg1003 221 rg1000 222 rg1003 223 rg1003 224 rg1003/; my %rgs; push @{$rgs{substr($_,0,2) . ':' . $numbers{$_}}}, $_ for keys %numbers; # The first <=> will warn. for (sort { $a <=> $b or @{$rgs{$b}} <=> @{$rgs{$a}} } keys %rgs) { /^(\d{2}):(.+)/; printf "%d => $2\n", @{$rgs{$_}} == 1 ? $rgs{$_}->[0] : $1; } __END__ $ ./mad 21 => rg1000 218 => rg1003 22 => rg1003 221 => rg1000

Replies are listed 'Best First'.
Re^2: summarization of list
by ikegami (Patriarch) on Mar 15, 2006 at 05:47 UTC
    @{$rgs{$_}} == 1? What if I added 225 => rg1000? I get some strange results.

      Updated: .. actually, looking at it again, my original program complies with the spec. But you have probably found a problem with the spec.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://536767]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (3)
As of 2022-01-24 08:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:












    Results (64 votes). Check out past polls.

    Notices?