Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
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 meditating upon the Monastery: (8)
As of 2014-12-28 04:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (178 votes), past polls