[27834] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 9198 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Apr 24 21:05:39 2006

Date: Mon, 24 Apr 2006 18:05:06 -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           Mon, 24 Apr 2006     Volume: 10 Number: 9198

Today's topics:
    Re: How to find uploaded data size from content-length <usenet@morrow.me.uk>
    Re: How to remove all duplications of characters <tadmc@augustmail.com>
    Re: How to remove all duplications of characters <tadmc@augustmail.com>
    Re: Term::ReadKey on Win?  5.005 vs 5.8.8? <rvtol+news@isolution.nl>
    Re: Term::ReadKey on Win?  5.005 vs 5.8.8? <rvtol+news@isolution.nl>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Mon, 24 Apr 2006 17:12:24 +0100
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: How to find uploaded data size from content-length
Message-Id: <80avh3-86a.ln1@osiris.mauzo.dyndns.org>


Quoth Asterbing <no@thanks.com>:
> In article <200420061650292428%jgibson@mail.arc.nasa.gov>, 
> jgibson@mail.arc.nasa.gov says...
> > If you read the documentation that the author of the CGI module
> > included with its distribution, you will find:
> > 
> > AUTHOR INFORMATION
> > 
> >     Copyright 1995-1998, Lincoln D. Stein.  All rights reserved.
> > 
> >     This library is free software; you can redistribute it and/or
> >     modify it under the same terms as Perl itself.
> 
> "Modification" is not "copy". 

Note the 'under the same terms as Perl'. Go read Perl's license. You
will find that extracting sections of code and including them in your
own programs is very much allowed, with certain restrictions on whether
you are then allowed to pass that program to someone else.

Ben

-- 
   Razors pain you / Rivers are damp
   Acids stain you / And drugs cause cramp.                    [Dorothy Parker]
Guns aren't lawful / Nooses give
  Gas smells awful / You might as well live.            benmorrow@tiscali.co.uk


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

Date: Mon, 24 Apr 2006 16:20:28 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: How to remove all duplications of characters
Message-Id: <slrne4qg8s.54p.tadmc@magna.augustmail.com>

Ignoramus21673 <ignoramus21673@NOSPAM.21673.invalid> wrote:
> On Mon, 24 Apr 2006 10:30:39 -0500, Tad McClellan <tadmc@augustmail.com> wrote:
>> Ignoramus21673 <ignoramus21673@NOSPAM.21673.invalid> wrote:

>>>   Hardcoore incesst Content
>>> 
>>> I want to replace that with "Hardcore incest Content" (note removal of
>>> duplicate characters.

>> You can do it fine without any regular expressions:
>>
>>       tr/a-zA-Z//s;


> If tr is somehow better 


It is.


> (not sure why), 


1) it is more self-documenting. s/// is for *patterns*, tr/// is
for characters, and you want to operate on characters not on patterns.

2) it is a lot faster than s///g


> I can
> switch to using tr.


Good.


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Mon, 24 Apr 2006 16:33:10 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: How to remove all duplications of characters
Message-Id: <slrne4qh0m.54p.tadmc@magna.augustmail.com>

David Squire <David.Squire@no.spam.from.here.au> wrote:
> Tad McClellan wrote:
>> Ignoramus21673 <ignoramus21673@NOSPAM.21673.invalid> wrote:


>>> (note removal of
>>> duplicate characters.


>> You can do it fine without any regular expressions:
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>>       tr/a-zA-Z//s;
>> 
>> 
> 
> Out of interest, can tr handle more general cases, such as:
> 
> 	s/(.)\1+/$1/g;
> 
> or is a regex necessary for this?


You do not need any regular expressions for that either:

   tr/\000-\011\013-\377//s;  # No regex here!


> PS. Yes, I have tested 'tr/.//s;', and it doesn't remove any dupes.


That must be because you tested on a string without any of 
the tr-listed characters in it. It works for me:

   perl -le '$_="etc..."; tr/.//s; print'


Note the underlined part above. tr/// is NOT a regular expression
(so a dot is a dot, not a "wildcard").


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Tue, 25 Apr 2006 01:14:19 +0200
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: Term::ReadKey on Win?  5.005 vs 5.8.8?
Message-Id: <e2jtfn.1ag.1@news.isolution.nl>

Ilya Zakharevich schreef:
> Dr.Ruud:

> Your mention of USE_GETC is confusing.  AFAICS, all it does is
> switching between getc and read(...,1).  And IIRC, in all versions of
> Perl getc() is just a shortcut for read(...,1).  Could you recheck the
> case where you see that getc vs read makes a difference?  If true,
> which case it is exactly?

I mentioned: "the behaviour is the same (on both platforms) for USE_GETC
set to 0 or to 1."
So I didn't notice any difference.


>> Wow, that
>>
http://search.cpan.org/src/ILYAZ/Term-ReadLine-Perl-1.03/ReadLine/readline.pm
>> is pretty loaded with externalizable stuff, like Vi-mode and keymaps
>> etc.
>
> Now if only I knew whether "externalizable" (in your usage) is for
> good things, or for bad things...  ;-)

It really looks like it would be good to split it up.

-- 
Affijn, Ruud

"Gewoon is een tijger."



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

Date: Tue, 25 Apr 2006 01:41:50 +0200
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: Term::ReadKey on Win?  5.005 vs 5.8.8?
Message-Id: <e2jv81.1cs.1@news.isolution.nl>

Ilya Zakharevich schreef:
> Dr.Ruud:

>> It is not just the bug, but also the lack of support for
>> Function-keys and special combinations with Alt/Ctrl/Shift, etc.
>
> I did not get this before.  Do you say that the getc() version does
> NOT produce useful output if you press, e.g., Left key, or Shift-F8?
>
> I would expect to get 0/75 for Left, and 0/91 for Shift-F8.

On the ActiveState 5.8.8 perl here, getc() returns nothing for function
keys and arrow keys, same as ReadKey(0, STDIN).
But if I replace getc by ReadKey(q{0E0}, STDIN), that returns a chr(0)
for function keys and arrow keys, and a chr(10) for Ctrl-J. I have
mentioned all that before.

Is the code below good enough for that test?

   perl -MTerm::ReadKey
         -le "binmode STDIN or die $!;
              ReadMode 5, STDIN;
              while(1) {
                $_ = getc STDIN;
                print length($_).q{:}.ord;
                last if 3==ord
              }; ReadMode 0, STDIN"

The lengths always come out as 1, as expected.


>> In the code in my previous post, the first-13-gets-eaten-bug is not
>> there, as long as you leave USE_GETC at 0.
>> With SET_BINMODE 1, there are no eaten or delayed 13s, even if
>> USE_GETC is 1 and/or USE_CONIN is 0.
>
> I assume this is with some pre-5.6.0 Perl, right?

No, in the Win32-corner I only have a perl, v5.8.8 built for
MSWin32-x86-multi-thread (AciveState) here.

-- 
Affijn, Ruud

"Gewoon is een tijger."



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

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 9198
***************************************


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