Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Text Manipulation Quickie

by frankus (Priest)
on Aug 15, 2002 at 10:41 UTC ( #190357=note: print w/ replies, xml ) Need Help??


in reply to Text Manipulation Quickie

And for the file:

2
2
2
3
3
3
4
4
5
How would that be handled?
this    or  that?
2             2
3             3
4             2
5             3
2             4
3             2
4             3
2             4
3             5
Fundamentaly whay you need is this:
# Create an array of numbers with values... my %numbers = (); for (<FILE>){ chomp; $numbers{$_}++; # tally the occurences of numbers.. # Could add a preemptive 'last' if numbers not contiguous } while( %numbers ){ # satisfies "this" criteria, insert a reverse for "that" for ( sort keys %numbers ){ print "$_\n"; delete $numbers{$_} unless --$numbers{$_}; # Add a routine here to remove all higher values # and warn if numbers are non-contiguous. } }
If this is homework, please note we're not here to do your thinking for you, just to help you think in Perl.

--

Brother Frankus.

¤


Comment on Re: Text Manipulation Quickie
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (6)
As of 2015-07-04 09:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (59 votes), past polls