[16699] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4111 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Aug 23 21:06:33 2000

Date: Wed, 23 Aug 2000 18:05:16 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <967079116-v9-i4111@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Wed, 23 Aug 2000     Volume: 9 Number: 4111

Today's topics:
    Re: @_ as array <abe@ztreet.demon.nl>
    Re: @_ as array <amir_e_a@netvision.net.il>
    Re: @_ as array <lr@hpl.hp.com>
    Re: Associative arrays <mjcarman@home.com>
    Re: Best General HTTP Proxy? (Abigail)
    Re: database for large number of keys? <timewarp@shentel.net>
    Re: database for large number of keys? <bwalton@rochester.rr.com>
    Re: Deleteing a file <timewarp@shentel.net>
    Re: Deleting all elements between ZZZ and YYY (Abigail)
    Re: Flipflop matching philhibbs@my-deja.com
    Re: Flipflop matching <lr@hpl.hp.com>
    Re: Flipflop matching philhibbs@my-deja.com
    Re: free online CGI/Perl courses <flavell@mail.cern.ch>
    Re: help with simple regexp - does my head in <ren.maddox@tivoli.com>
    Re: help with simple regexp - does my head in (Abigail)
    Re: how to generate unreadable from readable perl code <elijah@workspot.net>
        Just another silly post. <reljr_2@yahoo.com>
    Re: Just another silly post. <lr@hpl.hp.com>
    Re: lwp post method matt@NOSPAMcipherdesign.com
    Re: mnemonics for //m, //s (was: Re: negative lookahead <uri@sysarch.com>
    Re: Modifying @INC: my problem and solution (any commen <mischief@motion.thispartfake.net>
    Re: Modifying @INC: my problem and solution (any commen <hasant@trabas.com>
        Newbie - Escaping special chars in forms scottfreez@my-deja.com
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Thu, 24 Aug 2000 00:12:25 +0200
From: Abe Timmerman <abe@ztreet.demon.nl>
Subject: Re: @_ as array
Message-Id: <kpi8qs0h0blshsv9m4asr4t5foj1315irp@4ax.com>

[alt.perl removed]
On Wed, 23 Aug 2000 09:47:01 GMT, helgi@NOSPAMdecode.is (Helgi Briem)
wrote:

> On Tue, 22 Aug 2000 13:11:46 +0200, "LecturaX Porodum"
> <haak12@remove.ie.hva.nl> wrote:
> 
> >Hi,
> >
> >How can I best achieve to retrieve the second element (element 1) from @_?
 ...
> 
> my ($notwanted,$wanted) = @_;

You could also use 'undef' as placeholder for the notwanted:

	my(undef, $wanted) = @_;

-- 
Good luck,
Abe


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

Date: Thu, 24 Aug 2000 00:19:34 +0200
From: "Amir E. Aharoni" <amir_e_a@netvision.net.il>
Subject: Re: @_ as array
Message-Id: <8o1f07$rtt$1@news.netvision.net.il>

> On Tue, 22 Aug 2000 13:11:46 +0200, "LecturaX Porodum"
> <haak12@remove.ie.hva.nl> wrote:
>
> >Hi,
> >
> >How can I best achieve to retrieve the second element (element 1) from
@_?
> >
> >I get a warning when I do @_[1], but I imagine $_[1] wouldn't work
either,
> >as $_ is a reserved variable as well.
> >
>
> my ($notwanted,$wanted) = @_;
>

Actually $_[1] will do just what you want.

$_ and @_ are _completely different_ variables; just as $keanu and @keanu
are completely different variables; the $ and @ characters are inseparable
parts of variables' names.

# Creates a scalar variable called $keanu and assigns "Reeves" to it
my $keanu = "Reeves";

# prints "Reeves"
print $keanu;

# Creates an array called @keanu and assigns 3 values to it
my @keanu = ("Speed", "Matrix", "Devil's Advocate");

# Prints "Matrix"
print @keanu[1];

# Prints 3 - the size of the array
print @keanu;

See the document perldata for the complete explanation about Perl's
variables and perlsub about writing your own subroutines (aka functions).
___________________________________________
Amir Elisha Aharoni, the original Israelite
"Bartender! Put all my meals in one plate.
Don't ask me what kind of music I play.
I play the good kind." - Oliver Lake





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

Date: Wed, 23 Aug 2000 17:03:26 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: @_ as array
Message-Id: <MPG.140e06246f3d23c798acd0@nntp.hpl.hp.com>

[alt.perl removed.  They'll just have to live with the errors!]

In article <8o1f07$rtt$1@news.netvision.net.il> on Thu, 24 Aug 2000 
00:19:34 +0200, Amir E. Aharoni <amir_e_a@netvision.net.il> says...

 ...

> $_ and @_ are _completely different_ variables; just as $keanu and @keanu
> are completely different variables; the $ and @ characters are inseparable
> parts of variables' names.

Not exactly.  That is a significant oversimplification. See below.

> # Creates a scalar variable called $keanu and assigns "Reeves" to it
> my $keanu = "Reeves";
> 
> # prints "Reeves"
> print $keanu;
> 
> # Creates an array called @keanu and assigns 3 values to it
> my @keanu = ("Speed", "Matrix", "Devil's Advocate");
> 
> # Prints "Matrix"
> print @keanu[1];

That prints a slice of the array @keanu, which is a list consisting of 
the single scalar element $keanu[1].  Note how the @ character isn't an 
inseparable part of the name of the array @keanu.

Similarly, for the hash %keanu, an element is $keanu{whatever}.

> # Prints 3 - the size of the array
> print @keanu;

That is completely wrong.  As it is list context, it prints all the 
members of the array, separated by the contents of $, which by default 
is the null string.

  print scalar @array;

> See the document perldata for the complete explanation about Perl's
> variables and perlsub about writing your own subroutines (aka functions).

A damn good idea!

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Wed, 23 Aug 2000 23:45:56 GMT
From: Michael Carman <mjcarman@home.com>
Subject: Re: Associative arrays
Message-Id: <39A46345.A352F640@home.com>

Mark wrote:
> 
> Martien Verbruggen wrote:
>
> > [please, in the future, put your reply after the suitably 
> > trimmed text you reply to]
> >
> Well pardon the hell out of me, Mr Moderator

It was a polite and perfectly reasonable request. No need to get snippy
about it.
 
> > [reorder post to respect the natural arrow of time]
> >
> Sorry, I think my time is more valuable than using it to please you. I
> have already spent too much time...
> 

And what exactly is it that makes your time more valuable than anyone
else's here and exempts you from following Usenet etiquette?

Based on the OP's message, (and assuming that he wasn't asking an X/Y
question) 'reverse %fields' is the best solution iff [1] his hash is
1:1. A larger view of his program might reveal a more fundamental issue
and lead to a better one, but this sounds a lot like a newbie 'wish
list' anyway.

Alex, this is something that occasionally you will want/need to do, but
most of the time it is neither necessary nor desirable. When you really
need it, there are ways.

[1] Misspelling intentional: iff = 'if and only if' in mathematical
notation.

-mjc


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

Date: 24 Aug 2000 01:03:39 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Best General HTTP Proxy?
Message-Id: <slrn8q8t1u.tj3.abigail@alexandra.foad.org>

Matt Kruse (mkruse@netexpress.net) wrote on MMDXLIX September MCMXCIII in
<URL:news:39a3ff60$0$18142@wodc7nh0.news.uu.net>:
!! Randal L. Schwartz <merlyn@stonehenge.com> wrote
!! > >>>>> "Ilmari" == Ilmari Karonen <iltzu@sci.invalid> writes:
!! > Ilmari>          <!-- A --   --> still in a comment <!--   -- D -->
!! > Oooh, sorry.  I put the letters in to annotate, but forgot that would
!! > break it.
!! 
!! I'm not sure the specs dictate whether this is allowed or not.

I am pretty sure.

!! I understand the concept of what you're doing (multiple comments, each
!! starting with and ending with '--') but are you sure that '>' is a valid
!! character in an HTML comment?

Yes. Anything but a '-' followed by a '-' is legal inside a comment.
(How else would you comment out markup? <![ IGNORE [ ... ]]> isn't going
to work on any popular browser.)

!! My interpretation of the spec would be that '>' ends the comment tag,

Wrong. That's how Netscape 1.0 did it, but I still doubt anyone at 
Netscape Inc has any clue what exactly a specification is.

There is no comment tag. Period.

There are comment declarations. A comment declaration consists of

    - An MDO token ("<!")
    - Zero or more comments, each optionally followed by whitespace.
    - A MDC token (">").

A comment consists of:

    - A COM token ("--")
    - Zero or more SGML characters.
    - A COM token ("--") 

where the second part is non-greedy. That is, a "--" terminates the
comment.

!! regardless of whether it's current inside of '-- --' or not. So, your
!! example comment is actually invalid because it starts a comment but doesn't
!! end it before the closing '>' tag.

Could you please cite that specification?

!! So, while this example may be interesting and challenge your brain a bit,
!! I'm not positive that the spec is specific enough to either allow or not
!! allow what you've written. Agree or disagree?

Disagree. The specification is *very* specific. People have worked years
on it, and would not let such a thing as comments vaguely specified.

Here are the relevant parts of the SGML grammar:

     [5] s (6.2.1, 297:23) =
             ( SPACE
             | RE   
             | RS
             | SEPCHAR )

     [50] SGML character (9.2.1, 345:1) =
             ( markup character [51]
             | DATACHAR )
          
     [51] markup character (9.2.1, 345:4) =
             ( name character [52]
             | function character [54]   
             | DELMCHAR )

     [52] name character (9.2.1, 345:8) =
             ( name start character [53]
             | Digit
             | LCNMCHAR
             | UCNMCHAR )

     [53] name start character (9.2.1, 346:3) =
             ( LCLetter
             | UCLetter
             | LCNMSTRT
             | UCNMSTRT )

     [54] function character (9.2.2, 346:8) =
             ( RE
             | RS
             | SPACE
             | SEPCHAR
             | MSOCHAR
             | MSICHAR
             | MSSCHAR
             | FUNCHAR )

     [91] comment declaration (10.3, 391:1) =
             ( mdo ("<!"),
               ?( comment [92],
                  *( s [5]
                   | comment [92] ) ),
               mdc (">") )
        
     [92] comment (10.3, 391:7) =
             ( com ("--"),
               *SGML character [50],
               com ("--") ) 


References:
    Charles F. Goldfarb: "The SGML Handbook". Oxford, Clarendon Press.
    1990. ISBN 0-19-853737-9.


Abigail
-- 
print v74.117.115.116.32.97.110.111.116.104.101.114.
      v32.80.101.114.108.32.72.97.99.107.101.114.10;


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

Date: Wed, 23 Aug 2000 20:13:29 -0400
From: Albert Dewey <timewarp@shentel.net>
Subject: Re: database for large number of keys?
Message-Id: <39A468A9.48F0C5A6@shentel.net>

I will have to admit that I am not a large datafile expert only having
dealt with flat files but I do have an idea that you might try - or I
could risk getting seriously flamed from some of the more advanced users
out there - but here goes anyway . . . .

How about running a sorting routine a single time on your code words
and, not only sorting them alpha-numerically, but breaking them up into
a bunch of separate files, each file containing code words that start
with a unique letter or number, i.e. a file for code words that begin
with the letter 'a' and another for those that begin with 'b' and so
forth. Then with this task complete, you do your submit and search
routine for each time you wish to add a code word but instead of
searching through a single massive file, you are only going to be
searching through the file that will contain the match, if at all, by
looking in the file that will contain code words that start with same
character as the new code word you are trying to add to the system. This
should speed up things considerably regardless of the final search
method you choose to use since you will be dealing with a file that is a
fraction the size of the single large file. If you still need the large
master file, for whatever reason, then you simply keep these files
maintained in parallel with one another, searching through the smaller
files for the code word match, and if the new one is found to be a valid
new entry, then update the relevant smaller file as well as the master
file with the new entry. Might solve any, all, or none of your needs but
there it is anyway.

Just another uneducated suggestion from the peanut gallery.

Albert Dewey

nejeian@my-deja.com wrote:

> For a task involving keeping track of several million
> unsorted codewords (alphanumeric strings <= 16 characters
> in length), we need to know only whether a codeword is
> already in use.
>
> Using ActivePerl v5.6.0, build 616, on Win98.
>
> Any suggestions for efficient database implementation?
>
> To initialize database with all current codewords, currently
> trying this:
>
>  use DB_File;
>
>  $txtfile = shift;
>  open (TXTFILE, "<$txtfile") or die "can't open $txtfile";
>
>  tie %DB, "DB_File", "db" or die "Cannot open file 'db': $!\n";
>
>  while (<TXTFILE>)
>  {
>   chomp ($key = $_);
>   $DB{$key} = 1;
>  }
>
>  untie %DB;
>
> Takes a long time to process all the entries this way, which
> is a drag since we will often be given a new set of data from
> which to generate a new database. Also, faster lookups would
> help.
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.



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

Date: Thu, 24 Aug 2000 00:38:27 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: database for large number of keys?
Message-Id: <39A46EB2.EBFD037@rochester.rr.com>

nejeian@my-deja.com wrote:
> 
> For a task involving keeping track of several million
> unsorted codewords (alphanumeric strings <= 16 characters
> in length), we need to know only whether a codeword is
> already in use.
> 
> Using ActivePerl v5.6.0, build 616, on Win98.
> 
> Any suggestions for efficient database implementation?
> 
> To initialize database with all current codewords, currently
> trying this:
> 
>  use DB_File;
> 
>  $txtfile = shift;
>  open (TXTFILE, "<$txtfile") or die "can't open $txtfile";
> 
>  tie %DB, "DB_File", "db" or die "Cannot open file 'db': $!\n";
> 
>  while (<TXTFILE>)
>  {
>   chomp ($key = $_);
>   $DB{$key} = 1;
>  }
> 
>  untie %DB;
> 
> Takes a long time to process all the entries this way, which
> is a drag since we will often be given a new set of data from
> which to generate a new database. Also, faster lookups would
> help.
 ...
If you want faster, why not invest in another memory chip and use a
regular hash, rather than a tied hash?  Both the setup time and the
lookup time would be reduced.  Otherwise, I think a tied hash will be
about as fast as you can expect from just about anything available,
including the various databases.
-- 
Bob Walton


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

Date: Wed, 23 Aug 2000 20:16:46 -0400
From: Albert Dewey <timewarp@shentel.net>
Subject: Re: Deleteing a file
Message-Id: <39A4696E.9576170B@shentel.net>


I don't know how you are generating your html page but if you first take this
data and put it into a variable and use this variable to load the content into
your html page, then once the variable is created, there should be no problems
with deleting the data file anytime after that.

Albert Dewey


> blindemann@my-deja.com writes:
>
> > I am a PERL rookie, so this may be basic for some of you, so I
> > apologize in advance if it is!
> > I have a scprit I wrote that returns some info to the browser.  After
> > this is complete, I want to delete a file that contains data that was
> > used in running the script and returned to the browser.  At the very
> > end of my scprit after the html is returned to the browser, I added
> > unlink myfile.dat;
> >
> > Evidently it deletes the file quicker then the HTML fills the page
> > because with the unlink at the end of my script, my data doesnt come up
> > in the browser.  Is there a way to prevent this?  I tried adding a
> > second script to delete the file and calling it in the HTML that is
> > returned to the browser, but that doesnt seem to work.  Any suggestions?



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

Date: 24 Aug 2000 00:23:27 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Deleting all elements between ZZZ and YYY
Message-Id: <slrn8q8qmk.tj3.abigail@alexandra.foad.org>

Ed Braden (ed@aw.sgi.com) wrote on MMDXLIX September MCMXCIII in
<URL:news:39A40E61.C5B09F43@aw.sgi.com>:
__ Hi,
__ 
__ In a text file I would like to remove all lines that exist between all
__ the occurances of 'ZZZ' 'YYY'. For example:
__ 
__ -----file example-----
__ laksdf
__ lasdf
__ ladf
__ TGT
__ ZZZ
__ want to remove
__ these
__ lines
__ YYY
__ lkasdf
__ la
__ ZZZ
__ want
__ to remove
__ these lines
__ YYY
__ -----end of file example----
__ 
__ This is easily done in sed since you can specify two addresses and
__ perform a delete on all lines between the two addresses but I don't see
__ how to do this in Perl.


That's a half liner in Perl:

    perl -wi -ne 'print unless /^ZZZ$/ .. /^YYY$/' file



Abigail
-- 
$" = "/"; split // => eval join "+" => 1 .. 7;
*{"@_"} = sub {foreach (sort keys %_) {print "$_ $_{$_} "}};
%_ = (Just => another => Perl => Hacker); &{%_};


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

Date: Wed, 23 Aug 2000 22:05:52 GMT
From: philhibbs@my-deja.com
Subject: Re: Flipflop matching
Message-Id: <8o1hrj$k9e$1@nnrp1.deja.com>

In article <8o1922$81m$2@slb6.atl.mindspring.net>,
  ebohlman@netcom.com (Eric Bohlman) wrote:
> philip.hibbs@tnt.co.uk wrote:
> It's called the range operator.  See perlop for details.
>
That's the fellah! Thanks, I had tried looking it up, but I was lost for
keywords to look up on, and perldoc isn't much use on Win95.

Uri Guttman wrote:
>as always the answer is in your question.
> this is even more fun than the newbies who ask 'how do i find the
>length of a string?'.
>perldoc perlop and look for the stuff i marked above.

Sorry, I don't understand - did I ask a stupid question? I didn't think
so.

Phil.


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Wed, 23 Aug 2000 15:47:43 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Flipflop matching
Message-Id: <MPG.140df466e5bbd3c098accf@nntp.hpl.hp.com>

In article <8o1hrj$k9e$1@nnrp1.deja.com> on Wed, 23 Aug 2000 22:05:52 
GMT, philhibbs@my-deja.com <philhibbs@my-deja.com> says...

 ...

> Uri Guttman wrote:
> >as always the answer is in your question.
> > this is even more fun than the newbies who ask 'how do i find the
> >length of a string?'.
> >perldoc perlop and look for the stuff i marked above.
> 
> Sorry, I don't understand - did I ask a stupid question? I didn't think
> so.

Not at all.  Uri was just crowing that he found the answer to your 
question within the text of the question itself, though not so blatantly 
as the 'length' example.  It is in the ellipsis that he pointed to in 
his response.

 ...  :-)

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Wed, 23 Aug 2000 23:26:39 GMT
From: philhibbs@my-deja.com
Subject: Re: Flipflop matching
Message-Id: <8o1mir$pqs$1@nnrp1.deja.com>

In article <MPG.140df466e5bbd3c098accf@nntp.hpl.hp.com>,
  Larry Rosler <lr@hpl.hp.com> wrote:
> Not at all.  Uri was just crowing that he found the answer to your
> question within the text of the question itself, though not so
> blatantly as the 'length' example.  It is in the ellipsis that he
> pointed to in his response.
>
> ...  :-)
>

Oh, I see, the ellpisis. Viewing the message on deja.com, it looks like
his carets are pointing to the es of "matches".

Phil.


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Thu, 24 Aug 2000 00:16:56 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: free online CGI/Perl courses
Message-Id: <Pine.GHP.4.21.0008240008450.7023-100000@hpplus03.cern.ch>

On Wed, 23 Aug 2000, yumin liang wrote:

>      http://www.*excised*.com/perlcgi

After a longish wait, a redirection, and another longish wait, it
says:

   Detecting Macromedia Flash 4.0, please wait a moment...

and then a lot of nothing happens.  Whoopeedoo.

This page hasn't even been "optimised for arguing with customers".

>     (Yes. It's free. The website based its revenue income
>      from advertisement sponsorship.)

Is there very much Perl in it?

"And now a word from one of our sponsors":

        http://language.perl.com/misc/div-www.html



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

Date: 23 Aug 2000 15:43:17 -0500
From: Ren Maddox <ren.maddox@tivoli.com>
Subject: Re: help with simple regexp - does my head in
Message-Id: <m3k8d77lp6.fsf@dhcp11-177.support.tivoli.com>

abigail@foad.org (Abigail) writes:

> Well, yeah, but the difference is insignificant. 
> 
> 
>     #!/opt/perl/bin/perl -w
> 
>     use strict;
> 
>     use Benchmark;
> 
>     use vars qw /@a/;
> 
>     @a = (1 => 2);
> 
>     timethese -10 => {
>          1  =>  'my $a = $a [ 1]',
>         -1  =>  'my $a = $a [-1]',
>     };
> 
>     __END__
> 
>     Benchmark: running -1, 1, each for at least 10 CPU seconds...
>             -1:  9 wallclock secs (10.62 usr + -0.03 sys = 10.59 CPU)
>                  @ 445933.52/s (n=4722436)
>              1: 14 wallclock secs (10.52 usr +  0.00 sys = 10.52 CPU)
>                  @ 529952.57/s (n=5575101)
> 
> 

Um... It doesn't seem like negative values for the number of
iterations is doing what you think.  It looks like it causes each case
(individually) to run for at least (in this case) 10 seconds.  But if
you look at the values of n, they are substantially different.  So the
cases are not being run the same number of times.

Changing your -10 to 10_000_000 in your first benchmark shows 1 to be
significantly faster than -1 (30% to 40%).

The second benchmark shows much less variance (about 3%), but 1 is
still faster than -1.  Of course, the real reason for this is that the
split dominates by about a factor of 10.

In the end though, you are exactly right.  This shouldn't be a
performance issue -- use the form that makes sense.  If you want the
1st (2nd) field, use 1.  If you want the last field, use -1.  If you
know that the 1st (2nd) field is always the last field, then use
whichever one you like.

-- 
Ren Maddox
ren@tivoli.com


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

Date: 24 Aug 2000 00:15:14 GMT
From: abigail@foad.org (Abigail)
Subject: Re: help with simple regexp - does my head in
Message-Id: <slrn8q8q78.tj3.abigail@alexandra.foad.org>

Ren Maddox (ren.maddox@tivoli.com) wrote on MMDXLIX September MCMXCIII in
<URL:news:m3k8d77lp6.fsf@dhcp11-177.support.tivoli.com>:
:} abigail@foad.org (Abigail) writes:
:} 
:} > Well, yeah, but the difference is insignificant. 
:} > 
:} > 
:} >     #!/opt/perl/bin/perl -w
:} > 
:} >     use strict;
:} > 
:} >     use Benchmark;
:} > 
:} >     use vars qw /@a/;
:} > 
:} >     @a = (1 => 2);
:} > 
:} >     timethese -10 => {
:} >          1  =>  'my $a = $a [ 1]',
:} >         -1  =>  'my $a = $a [-1]',
:} >     };
:} > 
:} >     __END__
:} > 
:} >     Benchmark: running -1, 1, each for at least 10 CPU seconds...
:} >             -1:  9 wallclock secs (10.62 usr + -0.03 sys = 10.59 CPU)
:} >                  @ 445933.52/s (n=4722436)
:} >              1: 14 wallclock secs (10.52 usr +  0.00 sys = 10.52 CPU)
:} >                  @ 529952.57/s (n=5575101)
:} 
:} Um... It doesn't seem like negative values for the number of
:} iterations is doing what you think.  It looks like it causes each case
:} (individually) to run for at least (in this case) 10 seconds.

Well, duh! That's why I used a negative number. It's doing exactly
what it is supposed to be doing.

:}                                                                But if
:} you look at the values of n, they are substantially different.  So the
:} cases are not being run the same number of times.

So? It also reports the number of times per second it ran, and both
seconds are of equal lenght.

:} Changing your -10 to 10_000_000 in your first benchmark shows 1 to be
:} significantly faster than -1 (30% to 40%).

Really? Can we see the output of the benchmark? Considering you didn't
read my results properly, I'm not taking your word for granted.

(And note that in my benchmark, the speed difference is about 15%).


Abigail
-- 
map{${+chr}=chr}map{$_=>$_^ord$"}$=+$]..3*$=/2;        
print "$J$u$s$t $a$n$o$t$h$e$r $P$e$r$l $H$a$c$k$e$r\n";


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

Date: 24 Aug 2000 00:11:23 GMT
From: Eli the Bearded <elijah@workspot.net>
Subject: Re: how to generate unreadable from readable perl code
Message-Id: <eli$0008232011@qz.little-neck.ny.us>

In comp.lang.perl.misc, Martien Verbruggen <mgjv@tradingpost.com.au> wrote:
> Besides, anyone who uses %, @ or $ as a separator for s///, tr///, m//
> or qq and related operators, should be taken outside behind the shed,
> and summarily shot :)

Heh. I like % since it looks a bit like /. And I use @ with some
frequency. $ I'd probably only use for obfuscation.

But there are some other cases that will screw over parsers.
I've used regexps like:

	s X (some regexp that includes lots of ! \# \$ \@ \% / , )
	  X &replacestring($1) Xxes;

in real code. And control characters (unless considered whitespace)
do work as delimiters. I once used ^A for a security through
obscurity concern.

Elijah
------
exec{$^X}('Just Another Perl HackerX',$0)unless($^X=~y=X=\cJ=);print$^X


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

Date: Wed, 23 Aug 2000 18:42:17 -0500
From: Policy Man <reljr_2@yahoo.com>
Subject: Just another silly post.
Message-Id: <39A46159.ECE3174@yahoo.com>

Please feel very free to ignore this silly post. If you find yourself
irritated or angered by this post please review the previous sentence.

This is for those of us with disposable time to spare, who love to be
clever with perl, and who don't mind being challenged by some idiot
like me with a crazy notion in his head.

I have a challenge for you. Create perl code according to these
requirements:

In a Unix/Linux OS return a list of the names of all the files,
directories, sub directories, sub sub directories, sub sub ... sub
directories, etc. of an arbitrarily given list of directories or files
(called @given) with the directory name of each directory listing
given last. Do not include . or .. in the returned list.

Example:

 @given = glob "/tmp";
 print join "\n",

 challenge code somehow utilizing @given;

produces:

/tmp/Arrgh
/tmp/fnoodle/google/who
/tmp/fnoodle/google
/tmp/fnoodle/spank
/tmp/fnoodle
/tmp/zzz
/tmp

The challenge code must not in any way clutter up the name space of a
program it might be included in.

-- The code may employ at most a single ';' and then only as the final
item/character.
-- Runs on a Unix/Linux OS.
-- Runs under Perl 5.004 or later.
-- It must work cleanly if later deployed with 'use strict' and the perl
'-w' option.
-- @given may only appear once and must not be modified.
-- Generous use of whitespace to add clarity is appreciated.
-- It must not return duplicate entries due to symbolic links to
directories.
-- It must not return directory listings outside the base directories
specified
   by @given due to symbolic links to those external directories.

Do not employ:
-- objects, packages, modules, methods.
-- '::'
-- keywords: 'use', 'do', 'require', 'bless', `` (backticks), 'exec',
'system', 'fork'.
-- external programs of any kind.
-- named variables other than specials like: '$_ @_ $1 $2 $#' etc. and
the array @given.
-- named subroutines other than functions included in the basic perl
5.xxx install.

Note: (Single quotes used for emphasis only, the spirit and not the
       letter, gentle persons!)

Do not whine that the object model is secretly in effect in perl even
if the package keyword is not employed. All perl programs that don't
employ the package keyword are in fact in the 'main' name space. I
know that, and I don't expect anyone to dismantle perl's object system
to make the challenge code work. I simply don't want some pragmatic
perl hooligan to somehow spoil a perfectly good, non-object-oriented
challenge with some evil object thingy. I expect cleverness, not
pragmatic smarts. If I wanted it done easily I would 'use File::Find'
and be done with it.

Juvenile attempts to meet the challenge by creating a fixed list in
perl that returns the names of all the directories and files on their
local Unix/Linux box will be met with derision. Don't try to be cute.

Why do it? The same reason one might climb a mountain -- because we can.

Prize: The sweet feeling of success in the face of a difficult task.



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

Date: Wed, 23 Aug 2000 17:50:28 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Just another silly post.
Message-Id: <MPG.140e112c7fb2144798acd2@nntp.hpl.hp.com>

In article <39A46159.ECE3174@yahoo.com> on Wed, 23 Aug 2000 18:42:17 -
0500, Policy Man <reljr_2@yahoo.com> says...
> Please feel very free to ignore this silly post. If you find yourself
> irritated or angered by this post please review the previous sentence.
> 
> This is for those of us with disposable time to spare, who love to be
> clever with perl, and who don't mind being challenged by some idiot
> like me with a crazy notion in his head.
> 
> I have a challenge for you. Create perl code according to these
> requirements:

Your challenge might be more suitable for the Fun With Perl list, 
fwp@technofile.org

 ...

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Wed, 23 Aug 2000 22:26:53 GMT
From: matt@NOSPAMcipherdesign.com
Subject: Re: lwp post method
Message-Id: <39a44f1c.52538195@news.ntlworld.com>

hey all,

it would really clarify things if someone could tell me whats wrong
with the following code. it just fetches the search page, it doesnt
actually search...

TIA matt.

#!/usr/bin/perl -w
use strict;

use LWP::UserAgent;
use HTTP::Cookies;
use HTTP::Request::Common qw( POST );

my $loginUrl='http://www.altavista.com/cgi-bin/query';

my $query = 'query text';

my $ua = new LWP::UserAgent;
my $loginReq = POST $loginUrl, [ q => $query ];

my $result = $ua->request($loginReq)->as_string();

print $result;


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

Date: Wed, 23 Aug 2000 23:03:39 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: mnemonics for //m, //s (was: Re: negative lookahead assertions in Perl Regex)
Message-Id: <x7aee3twaf.fsf@home.sysarch.com>

>>>>> "NK" == Neil Kandalgaonkar <neil@brevity.org> writes:

  NK> I still can't think of a better mnemonic, though.

/s changes the behavior of a SINGLE metachar .
/m changes the behavior of MULTIPLE metachars ^ and $

not that i use that nmemonic as i just made it up.

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com


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

Date: Wed, 23 Aug 2000 18:22:11 -0500
From: "Chris Stith" <mischief@motion.thispartfake.net>
Subject: Re: Modifying @INC: my problem and solution (any comment?)
Message-Id: <sq8n506bt91153@corp.supernews.com>


"Malcolm Dew-Jones" <yf110@vtn1.victoria.tc.ca> wrote in message
news:39a41d62@news.victoria.tc.ca...
> hasant@trabas.com wrote:
> : The Problem
>
> : Determine a non-standard module path dynamically
> : in the scripts.
>
> Can you not define the PERL5LIB environment variable before hand?

I might even suggest putting a small config file in the
application's base directory, which lists where the
modules to be included reside. Read it in once, reuse it
thoughout any part of the code that needs it. This could
be done for the base directory, too, for that matter, in case you need to
find data files or whatever based on that.

> Or use relative paths?
>

That could work pretty well too.

Chris Stith
Motion Internet
mischief@motion.net   mr_mischief1@hotmail.com





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

Date: Wed, 23 Aug 2000 23:16:04 GMT
From: Hasanuddin Tamir <hasant@trabas.com>
To: bandung-pm-list@happyfunball.pm.org
Subject: Re: Modifying @INC: my problem and solution (any comment?)
Message-Id: <8o1lv3$p19$1@nnrp1.deja.com>

In article <39a41d62@news.victoria.tc.ca>,
  yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones) wrote:
> hasant@trabas.com wrote:
> : The Problem
>
> : Determine a non-standard module path dynamically
> : in the scripts.
>
> Can you not define the PERL5LIB environment variable before hand?
> (that name could be wrong, look it up)

And PERLLIB as well. But if I move the application set, I need to adjust
the environment variable value. And they don't work with -T. We just
discussed this alternative at our local PM group.


> Or use relative paths?

I've used this also, so if the script is exactly under a directory
with the same level as lib dir, I could say,

  use lib '../lib';

If the script is one level down, I would say,

  use lib '../../lib';

and son on. But if for one reason a script moves to a different level,
then the use() statement needs to be adjusted.

So,
     use BaseLib qw(BASEDIR LIBDIR);

will never require change neither on the script nor environment
variables, unless of course BASEDIR and/or LIBDIR change.

> Also useful, a module can be in more than one location - you can place
any
> number of test versions in directories earlier in the path to
temporarily
> replace a module.

What you mean by "temporarily replace a module"?


Regards,
hasant


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Thu, 24 Aug 2000 00:32:51 GMT
From: scottfreez@my-deja.com
Subject: Newbie - Escaping special chars in forms
Message-Id: <8o1qfi$tv7$1@nnrp1.deja.com>

Hi,

In ASP I use server.urlEncode to encode special characters.

Does anyone know a similar function in Perl? I'm creating a form on the
fly and submitting it to another page. Problems are arising when there
are "&" characters in the form.

So, if there is a function then that would be great. If there is no
function, then can someone please tell me which characters besides "&"
need to be replaced to get the form to submit properly?

Thanks,
scottfreez


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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 V9 Issue 4111
**************************************


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