[25889] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 8117 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu May 26 06:05:32 2005

Date: Thu, 26 May 2005 03: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           Thu, 26 May 2005     Volume: 10 Number: 8117

Today's topics:
    Re: Fibonacci string <abigail@abigail.nl>
    Re: Fibonacci string <someone@example.com>
    Re: Fibonacci string (Anno Siegel)
    Re: FormMail Problem <emschwar@pobox.com>
    Re: FormMail Problem <noreply@gunnar.cc>
    Re: FormMail Problem (Anno Siegel)
        Komodo and subversion <ambre00@free.fr>
        lexical analyzer generators (Jay G. Scott)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 26 May 2005 01:18:04 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: Fibonacci string
Message-Id: <slrnd9a8uc.ch.abigail@alexandra.abigail.nl>

John W. Krahn (someone@example.com) wrote on MMMMCCLXXXIV September
MCMXCIII in <URL:news:GsOke.9458$9A2.8141@edtnps89>:
##  
##  A bit faster.   :-)
##  
##  my $v = '1';
##  for ( 1 .. 20 ) {
##       printf "%10d %10d\n", $v =~ y/0//, $v =~ y/1//;
##       $v =~ s/./ $& ? '10' : '1' /eg;
##  }


Much faster:

    my $v = '1';
    for ( 1 .. 20 ) {
         printf "%10d %10d\n", $v =~ y/0//, $v =~ y/1//;
         $v =~ s/1/12/g; $v =~ y/02/10/;
    }


Benchmark:


    #!/usr/bin/perl

    use strict;
    use warnings;
    no warnings qw /syntax/;

    use Benchmark qw 'cmpthese';

    our @a = (1, 10);
    our ($j, $a);
    our $max = 20;

    cmpthese -5 => {
        john    => '$j = 1; for (1 .. $max) {$j =~ s/./$& ? "10" : "1"/eg;}',
        abigail => '$a = 1; for (1 .. $max) {$a =~ s/1/12/g; $a =~ y/02/10/}',
    };

    die unless $a eq $j;

    __END__
              Rate    john abigail
    john    21.3/s      --    -62%
    abigail 55.4/s    160%      --


Abigail
-- 
perl -we 'eval {die ["Just another Perl Hacker\n"]}; print ${${@}}[$#{@{${@}}}]'


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

Date: Thu, 26 May 2005 06:27:06 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: Fibonacci string
Message-Id: <__dle.10597$9A2.1093@edtnps89>

Abigail wrote:
> John W. Krahn (someone@example.com) wrote on MMMMCCLXXXIV September
> MCMXCIII in <URL:news:GsOke.9458$9A2.8141@edtnps89>:
> ##  
> ##  A bit faster.   :-)
> ##  
> ##  my $v = '1';
> ##  for ( 1 .. 20 ) {
> ##       printf "%10d %10d\n", $v =~ y/0//, $v =~ y/1//;
> ##       $v =~ s/./ $& ? '10' : '1' /eg;
> ##  }
> 
> Much faster:
> 
>     my $v = '1';
>     for ( 1 .. 20 ) {
>          printf "%10d %10d\n", $v =~ y/0//, $v =~ y/1//;
>          $v =~ s/1/12/g; $v =~ y/02/10/;
>     }
> 
> Benchmark:
> 
>     #!/usr/bin/perl
> 
>     use strict;
>     use warnings;
>     no warnings qw /syntax/;
> 
>     use Benchmark qw 'cmpthese';
> 
>     our @a = (1, 10);
>     our ($j, $a);
>     our $max = 20;
> 
>     cmpthese -5 => {
>         john    => '$j = 1; for (1 .. $max) {$j =~ s/./$& ? "10" : "1"/eg;}',
>         abigail => '$a = 1; for (1 .. $max) {$a =~ s/1/12/g; $a =~ y/02/10/}',
>     };
> 
>     die unless $a eq $j;
> 
>     __END__
>               Rate    john abigail
>     john    21.3/s      --    -62%
>     abigail 55.4/s    160%      --

Thanks Abigail,

I wonder if Ton can come up with a Perl program that does the same thing
in ~50 characters?  :-)


John
-- 
use Perl;
program
fulfillment


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

Date: 26 May 2005 08:09:38 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Fibonacci string
Message-Id: <d74082$h9t$1@mamenchi.zrz.TU-Berlin.DE>

Abigail  <abigail@abigail.nl> wrote in comp.lang.perl.misc:
> John W. Krahn (someone@example.com) wrote on MMMMCCLXXXIV September
> MCMXCIII in <URL:news:GsOke.9458$9A2.8141@edtnps89>:
> ##  
> ##  A bit faster.   :-)
> ##  
> ##  my $v = '1';
> ##  for ( 1 .. 20 ) {
> ##       printf "%10d %10d\n", $v =~ y/0//, $v =~ y/1//;
> ##       $v =~ s/./ $& ? '10' : '1' /eg;
> ##  }
> 
> 
> Much faster:
> 
>     my $v = '1';
>     for ( 1 .. 20 ) {
>          printf "%10d %10d\n", $v =~ y/0//, $v =~ y/1//;
>          $v =~ s/1/12/g; $v =~ y/02/10/;
>     }

Avoiding s/// altogether gains another factor of 50 or so:

    my $v = 1;
    for ( 1 .. 20 ) {
        printf "%10d %10d\n", $v =~ y/0//, $v =~ y/1//;
        $_ .= length > 1 ? substr( $_, 0, tr/1/1/) : 0 for $v;
    }


Benchmark:

    #!/usr/bin/perl
    use strict; use warnings; $| = 1; # @^~`
    use Vi::QuickFix;

    use Benchmark qw 'cmpthese';

    our ($j, $a, $b);
    our $max = 20;

    cmpthese -5 => {
        john    => '$j = 1; for (1 .. $max) {$j =~ s/./$& ? "10" : "1"/eg;}',
        abigail => '$a = 1; for (1 .. $max) {$a =~ s/1/12/g; $a =~ y/02/10/}',
        anno    => '$b = 1; for (1 .. $max) ' .
                   '{ $_ .= length() > 1 ? substr( $_, 0, y/1/1/) : 0 for $b}',
    };

    die unless $a eq $j and $b eq $j;
    __END__

Anno


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

Date: Wed, 25 May 2005 17:32:24 -0600
From: Eric Schwartz <emschwar@pobox.com>
Subject: Re: FormMail Problem
Message-Id: <etowtpmkhkn.fsf@wilson.emschwar>

Gunnar Hjalmarsson <noreply@gunnar.cc> writes:

> Eric Schwartz wrote:
>> Gunnar Hjalmarsson writes:
>>> The discussion has been about whether it's accurate to describe
>>> version 1.92 of Matt's FormMail script as "horribly, horrendously
>>> insecure and thoroughly broken" without providing any evidence.
>> the CGI-parsing code in there
>> query string delimited by ; not & for GET,
>
> It's a *form*-to-mail script, so ';' as delimiter is not applicable.

UAs can split up the args however they like.  Still broken.

>> and read not reading all data in the buffer at once for POST
>
> Well, it normally does its work as intended...

Normally most things do, so why should we bother testing anything for
failure?  That's poor reasoning if ever I saw it.

>> As for security holes, there's the obvious one that HTTP_REFERER is
>> easily spoofable.
>
> <quote from the FormMail docs>
> This is not a security check. Referer headers can EASILY be faked.
> </quote from the FormMail docs>
>
> => Not a security hole.

Just because the docs alert you to it doesn't mean it's not a hole.
All it means is that the author is aware of the hole.  Also, someone
else pointed out the /e on the regexes, which I didn't notice.

-=Eric
-- 
Come to think of it, there are already a million monkeys on a million
typewriters, and Usenet is NOTHING like Shakespeare.
		-- Blair Houghton.


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

Date: Thu, 26 May 2005 02:33:07 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: FormMail Problem
Message-Id: <3fkk1lF7ss4lU1@individual.net>

Eric Schwartz wrote:
> Gunnar Hjalmarsson writes:
>> Eric Schwartz wrote:
>>> the CGI-parsing code in there
>>> query string delimited by ; not & for GET,
>>
>> It's a *form*-to-mail script, so ';' as delimiter is not applicable.
> 
> UAs can split up the args however they like.  Still broken.

No browser will use anything but '&' in the foreseeable future.

>>> and read not reading all data in the buffer at once for POST
>>
>> Well, it normally does its work as intended...
> 
> Normally most things do, so why should we bother testing anything for
> failure?  That's poor reasoning if ever I saw it.

Okay, I admit that. :)

>>> As for security holes, there's the obvious one that HTTP_REFERER is
>>> easily spoofable.
>>
>> <quote from the FormMail docs>
>> This is not a security check. Referer headers can EASILY be faked.
>> </quote from the FormMail docs>
>>
>> => Not a security hole.
> 
> Just because the docs alert you to it doesn't mean it's not a hole.

How can a feature that is not intended to provide for security be a 
security hole??

> Also, someone else pointed out the /e on the regexes, which I
> didn't notice.

What about it? Did you read my reply? 
http://groups-beta.google.com/group/comp.lang.perl.misc/msg/c81511a4fc69d112

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl


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

Date: 26 May 2005 05:57:07 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: FormMail Problem
Message-Id: <d73ofj$c7r$1@mamenchi.zrz.TU-Berlin.DE>

Eric Schwartz  <emschwar@pobox.com> wrote in comp.lang.perl.misc:
> Gunnar Hjalmarsson <noreply@gunnar.cc> writes:
> > Eric Schwartz wrote:
> >> Gunnar Hjalmarsson writes:

[...]

> Also, someone
> else pointed out the /e on the regexes, which I didn't notice.

Those are harmless (much as I'd like to find fault with FormMail :)

A substitution "s/xxx/$user_string/e" is not like "eval $user_string"
but similar to "eval qq( $user_string)".  That doesn't interpret
$user_string.

s///ee is another matter.

Anno


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

Date: Thu, 26 May 2005 09:37:08 +0200
From: Ambre <ambre00@free.fr>
Subject: Komodo and subversion
Message-Id: <42957ca4$0$3103$8fcfb975@news.wanadoo.fr>

This is an OpenPGP/MIME signed message (RFC 2440 and 3156)
--------------enig5BF8BEC515A567FF0D0D7E0A
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

Hello,
I'm trying to use subversion with Komodo 3.1 under Windows XP.

I've installed Subversion and created a repository, but Komodo don't let
me access to the source control menu.

Did anyone have an idea ?

Thanks,
Nicolas
--=20
Tout mes messages sont sign=E9s num=E9riquement.
Si vous recevez un message non sign=E9, il n'est pas de moi, veuillez le
supprimer.

Merci !


--------------enig5BF8BEC515A567FF0D0D7E0A
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="signature.asc"

-----BEGIN xxx SIGNATURE-----
Version: GnuPG v1.2.4 (MingW32)

iD8DBQFClXyklTM7DNkaLiYRAgXSAJ4qykipppOxYfxEHd/QM3IRQdmFngCglAjV
T+EJJaTSAAVykEdQmJ64PLs=
=HpUM
-----END PGP SIGNATURE-----

--------------enig5BF8BEC515A567FF0D0D7E0A--


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

Date: Thu, 26 May 2005 00:43:28 +0000 (UTC)
From: gl@torn.arlut.utexas.edu (Jay G. Scott)
Subject: lexical analyzer generators
Message-Id: <d7363g$q0d$1@ns3.arlut.utexas.edu>


i've asked this before, and i went off an read up on the answers,
ie, ParseLex.

well, this doesn't help.  i don't see anything out there that's remotely
like lex/flex.  the perl tools seem incapable of the sort of flexibility
i want.  in flex, i can do things like this:

aab[cd]+	{ C code }

acr[a-z][0-9][a-r]*	{ some other code }
[a-z0-9]+	{yet another chunk}

whereas i don't see anything akin to this in ParseLex.


question:

am i right in thinking that the perl lexical analyzer generators don't
actually generate lexical analyzers to order, they just use their idea of
a lexical analyzer and give you their routine results?  i looked at
one of ParseLex's examples and it MAY be that i can get it to return a string
to me, but once i have the string i'd have to sort things to decide which
of the three rules above the string matches.  that's exactly the thing i
want to avoid.  so if that's what they do, then i don't want to use them.

j.

-- 
Jay Scott		512-835-3553		gl@arlut.utexas.edu
Head of Sun Support, Sr. Operating Systems Specialist
Applied Research Labs, Computer Science Div.                   S224
University of Texas at Austin


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

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


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