[26242] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 8427 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Sep 16 18:05:19 2005

Date: Fri, 16 Sep 2005 15:05:05 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Fri, 16 Sep 2005     Volume: 10 Number: 8427

Today's topics:
        Customizing the Output of a Sorted Array <hlarons@yahoo.com>
    Re: Customizing the Output of a Sorted Array <emschwar@pobox.com>
    Re: Customizing the Output of a Sorted Array xhoster@gmail.com
        googletalk communication with perl <""alexjaquet\"@[no spam]msn.com">
    Re: googletalk communication with perl <mark.clementsREMOVETHIS@wanadoo.fr>
    Re: sorting data - hash vs. list <Fred@fred.net>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Fri, 16 Sep 2005 18:22:09 -0000
From: HaroldWho <hlarons@yahoo.com>
Subject: Customizing the Output of a Sorted Array
Message-Id: <slrndim39o.1bm.hlarons@Beagle.mylocal.net>

'@sorted' contains lines of text, space-delimited and sorted on the first
field and then on others. Some lines have duplicate first fields.

How can I emphasize the lines with duplicate first fields during output;
e.g., by indenting them or with leading asterisks?

I can think of some 'lookback' approaches, but they don't include the first
line of the array.

TIA,
Harold Who
-- 
Powered by SuSE Linux 9.0 -- Kernel 2.6.11
News Reader slrn 0.9.8.1




------------------------------

Date: Fri, 16 Sep 2005 12:37:09 -0600
From: Eric Schwartz <emschwar@pobox.com>
Subject: Re: Customizing the Output of a Sorted Array
Message-Id: <etoacicvoyy.fsf@wilson.emschwar>

HaroldWho <hlarons@yahoo.com> writes:
> '@sorted' contains lines of text, space-delimited and sorted on the first
> field and then on others. Some lines have duplicate first fields.
>
> How can I emphasize the lines with duplicate first fields during output;
> e.g., by indenting them or with leading asterisks?
>
> I can think of some 'lookback' approaches, but they don't include the first
> line of the array.

The only way I can think of to do it is to use 'map' (perldoc -f map)
to create a hash indexed on the first field of each line, with the
value being the number of times that field has been seen.  Then, when
you print, just

print "\t$field\n" if $seen{$field1};

or something like that.  Yes, it's O(n), but if n is sufficiently
small (less than a few hundred thousand lines should be fine), that
won't be a big problem.  I don't see any other way; I thought at first
you could populate the hash during the sort, but $a and $b will likely
take on the same lines multiple times during a sort, which will throw
off your count.

-=Eric


------------------------------

Date: 16 Sep 2005 20:04:38 GMT
From: xhoster@gmail.com
Subject: Re: Customizing the Output of a Sorted Array
Message-Id: <20050916160438.157$xf@newsreader.com>

HaroldWho <hlarons@yahoo.com> wrote:
> '@sorted' contains lines of text, space-delimited and sorted on the first
> field and then on others. Some lines have duplicate first fields.
>
> How can I emphasize the lines with duplicate first fields during output;
> e.g., by indenting them or with leading asterisks?

my %seen;
$seen{(split / /,$_,2)[0]}++ foreach @sorted;
foreach (@sorted) {
  print "****" if ($seen{(split / /,$_,2)[0]}>1);
  print "$_\n";
};



Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service                        $9.95/Month 30GB


------------------------------

Date: Fri, 16 Sep 2005 20:34:43 +0200
From: Alexandre Jaquet <""alexjaquet\"@[no spam]msn.com">
Subject: googletalk communication with perl
Message-Id: <kfEWe.34553$hV3.15142@nntpserver.swip.net>

Hi,

Anyone 've tryed to communicate with googletalk with a perl script and 
have some ressource to share ?

thanks in advance

Alexandre Jaquet


------------------------------

Date: Fri, 16 Sep 2005 21:14:59 +0200
From: Mark Clements <mark.clementsREMOVETHIS@wanadoo.fr>
Subject: Re: googletalk communication with perl
Message-Id: <432b1940$0$5366$8fcfb975@news.wanadoo.fr>

Alexandre Jaquet > wrote:
> Hi,
> 
> Anyone 've tryed to communicate with googletalk with a perl script and 
> have some ressource to share ?
> 

I haven't, but take a look at http://www.google.com/talk/developer.html. 
It should contain enough information to get you started.

regards,

Mark


------------------------------

Date: Fri, 16 Sep 2005 17:05:05 -0500
From: "Fred@fred.net" <Fred@fred.net>
Subject: Re: sorting data - hash vs. list
Message-Id: <v3fmi15g54mc0l2eluchvpss13ajabfj6k@4ax.com>

On Fri, 16 Sep 2005 04:08:21 GMT, "A. Sinan Unur" <1usa@llenroc.ude.invalid> wrote:

>"Fred@fred.net" <Fred@fred.net> wrote in
>news:sc3ki1lka0o2ub8v6sodndmu1n2ltijjbb@4ax.com: 
>
>> I have never really understood you guys and the way you all are about
>> this group, but I won't be posting anymore , 
>
>OK.
I sense your relief, but I have already deviated from my intention.
>
>> as to follow the guidlines would yeild from me little. 
>
>Huh?
You guys, c'mon. It's been argued here before. The ideal post here
would be very esoteric. The brilliance of the group for me is lies
in the messages I can mine. I'll find myself reading a post and then
notice the date will be something like 1999!
And I'm sure some of you were here prior, etc
But a ton of good stuff results from 'flawed posts'.
And you can't argue that. You might not like it,
it may shame you or I dunno, but it's a fact.

>
>> Other usenet groups are more "relaxed". 
>
>So?
So why not? I posted 1 time to alt.engineering.electrical to ask how to tell, or
if there was a way to tell, how much electricity a AC window unit was using.
I got tons of expert replies and they were all gentlemen about it. 
I was definitely off-topic.
But I never ask about anything other than perl here.
>
>> See, in my ill-mannered post I managed to learn about a
>> promising programming language called Ruby. Diamonds in the rough, I
>> guess. 
>
>I find Ruby interesting, too. I just haven't invested too much time in 
>it yet.
 ......
>
>>>>>>>Have you read the posting guidelines for this group? They contain 
>>>>>>>invaluable information on how to help yourself and help others
>>>>>>>help you. 
>>>>>> Thanks, but no. 
>
>It is perfectly within your rights to reject help.
Actually I find that funny. And very ironic.
>
>> Honestly all I needed to hear was "prepend the epoch seconds to the
>> front of the list and sort the zero subscript". 
>
>WTF is that going to solve? Your stated problem was that the file was 
>too large, and you did not want to read all of it to sort it. You 
>rejected using an OS utility, you rejected using Sort::External. Were 
>you lying when you said you did not want to read in the file?
No, but as it became apparent that in the context of having to
sort it, I would need it all in memory, I just went ahead and slurped it.
>
>> I just wanted friendly advice.
>
>Which you were given. Then you spat on it.
I take issue with that but then again
your talking about posting guidlines, and
NOT the answer that was posted. I was worried about
that big of a file, and I looked at alternatives. In the end
it got slurped. I just wanted to talk about perl. I don't dig
the military style thing, at all. I mean you all act as if, were
it not for such tight guidlines, the group would be awash with
erroneous posts, and yet you never consider... WHO-TF 
would be interested in this group, save someone interested in perl.
You would think you all would be better perl advocates. 
>
>> Whatever. There is always a skeptic, a heckler, and the rest of us in
>> any crowd. I guess we can leave it it up to the reader to flesh those
>> definitions out. 
>
>OK. *PLONK*
Ouch! OTH - DHCP sorts of fucks up the plonk thing doesn't it?

I'm taking my toys and going home.

Fred aka 2**256


------------------------------

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc.  For subscription or unsubscription requests, send
#the single line:
#
#	subscribe perl-users
#or:
#	unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V10 Issue 8427
***************************************


home help back first fref pref prev next nref lref last post