The Wayback Machine - https://web.archive.org/web/20110707134412/http://groups.google.com:80/group/comp.lang.perl.misc/msg/7b97c434492c8d20

Account Options

  1. Sign in
Google Groups Home
� Groups Home
Message from discussion Incrementing a value in a slice
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
Greg Bacon  
View profile  
 More options May 28 1999, 3:00 am
Newsgroups: comp.lang.perl.misc
From: gba...@itsc.uah.edu (Greg Bacon)
Date: 1999/05/28
Subject: Re: Incrementing a value in a slice
In article <x7emk1i36u....@home.sysarch.com>,
        Uri Guttman <u...@sysarch.com> writes:
: >>>>> "GB" == Greg Bacon <gba...@itsc.uah.edu> writes:
:   GB>     my @uniq;
:   GB>     my %seen;
:
:   GB>     while (<>) {
:   GB>         chomp;
:
:   GB>         push @uniq, $_ unless $seen{$_}++;
:   GB>     }
:
:   GB>     my $mode = shift @uniq;
:   GB>     for (@uniq) {
:   GB>         $mode = $_ if $seen{$_} > $seen{$mode};
:   GB>     }
:
: greg, you can do better than that! why two loops? why the push into
: @uniq?

It's a pedagogical issue.  I wanted to show how to collect the
information she wanted and then show one possible way to use it.
Playing Perl golf (fewest (key)strokes wins!) with people who have lots
of experience is fine, but it's not going to help much for people who
are still trying to get the hang of it.

Greg
--
VMS is a text-only adventure game. If you win you can use Unix.
    -- Bill Davidsen


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.