[16712] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4124 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Aug 24 21:05:41 2000

Date: Thu, 24 Aug 2000 18:05:18 -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: <967165518-v9-i4124@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Thu, 24 Aug 2000     Volume: 9 Number: 4124

Today's topics:
    Re: A Proposal for BaseLib module <mischief@motion.thispartfake.net>
        array of array references <antsyp@my-deja.com>
    Re: array of array references (Jakob Schmidt)
    Re: Check array for an element <Juha.Laiho@iki.fi>
    Re: Check array for an element (David Wall)
        cookies. <j_bandi@yahoo.com>
    Re: cookies. <lauren_smith13@hotmail.com>
    Re: cookies. (Malcolm Dew-Jones)
    Re: cookies. (Tony L. Svanstrom)
        Docs on Mac (Was: Re: how to round ?) (Jakob Schmidt)
    Re: errno 22 1024 char limit writing to DB's perlnewbie@my-deja.com
    Re: File handling and manipulation from function, help  <care227@attglobal.net>
    Re: Free Perl compiler ? <lauren_smith13@hotmail.com>
    Re: From metacharacter and back again <lr@hpl.hp.com>
    Re: help me decipher PERL <wyzelli@yahoo.com>
    Re: help with simple regexp - does my head in (Martien Verbruggen)
    Re: help with simple regexp - does my head in <ren.maddox@tivoli.com>
    Re: help with simple regexp - does my head in <ren.maddox@tivoli.com>
    Re: how to generate unreadable from readable perl code <elijah@workspot.net>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Thu, 24 Aug 2000 19:47:30 -0500
From: "Chris Stith" <mischief@motion.thispartfake.net>
Subject: Re: A Proposal for BaseLib module
Message-Id: <sqbgglbdt9110@corp.supernews.com>

I apologize to all the readers for including all of the original
post in my reply. The OP, in a seperate thread on the
same topic, assumed that any part of his original post
not included in the reply was not addressed in the reply.

"Hasanuddin Tamir" <hasant@trabas.com> wrote in message
news:8o37ph$g3j$1@nnrp1.deja.com...
> NAME
>
> BaseLib - manipulate @INC dynamically for independent installation
>           path
>
> [WARNING: The module name is still subjected to change]
>
>
> DESCRIPTION
>
> BaseLib provides a simple and straightforward mechanism to
> include private library path of an application set to @INC
> independent of installation path.  It optionally takes two
> arguments, which also happen to be the keywords of this
> module: BASEDIR and LIBDIR.
>
> This module is intended for a set of application with certain
> file and directory structure, not for ordinary single script
> at general. The typical structure could be:
>
>     mail2sms/  -> base directory of the application
>      scripts/  -> where the scripts located, this directory
>                   might have so many nested directories
>      libdir/   -> path of the private modules
>      others/   -> other directory
>
> The usage is similiar to lib.pm,
>
>     use BaseLib qw(BASEDIR LIBDIR);
>
> In the absence of the arguments, BaseLib will use the default
> values: `appl_root' (subjected to change) and `lib' respectively.
>
> For example, the structure is put under `/installation/path'.
> Using lib.pm, all scripts need to say,
>
>     use lib '/installation/path/mail2sms/libdir';
>
> What happens when the application is moved to, for example,
> `/new/installation/path'?  Of course, in order for it to work,
> all scripts must be modified to refer to the new pat,
>
>     use lib '/new/installation/path/mail2sms/libdir';
>
>
> OK, one may use environment variables, either the built in
> ones (PERL5LIB and PERLLIB), or customized one, say, PRIVLIBDIR.
> The scripts only need to say once,
>
>     use lib "$ENV{PRIVLIBDIR}";
>

It'd be just as easy to say this once per script:

push(@INC, PRIVLIBDIR);

or am I missing something? Of course, the preferred way to add to
@INC according to the documentation is

use lib "directory";

but didn't you know that you can feed it a list? Try this :

use lib ("/var", "/etc");

and see what it does.

> or nothing at all if PERL5LIB/PERLLIB is used.  But then
> someone must be responsible to maintain the content of the
> environment variables, either via global profile (assumming
> unices), or, via web server conf (and don't forget to reload
> or restart the server :-), each time the installation path
> changes (Thanks to Steven Haryanto for providing this
> examples.)
>
> And what if during the development process, there are more
> than one version at the same machine? Or there are multiple
> developers with their own environment? So many changes need
> to be done.  Beside PERL5LIB and PERLLIB don't work with -T
> switch.
>
> This when BaseLib comes to rescue. All the scripts have to
> say is,
>
>     use BaseLib qw(mail2sms libdir);

Wouldn't the folowing work?

push(@INC, mail2sms, libdir);

or

use lib ("mail2sms", "libdir");

or am I still missing something?

> And no further tweaking is necessary, no matter how many
> environments the application will run in. The scripts will
> always be able to lookup to the right path to mail2sms/libdir
> without having to care where mail2sms is put under. Well, as
> long as no change on mail2sms and/or libdir.
>
> As addition, BaseLib has a global package variable $BaseDir,
> contains full path to the, unsuprisingly, base directory of
> the application. This is not exported, so it must be qualified
> with the package name to use it, e.g. $BaseLib::BaseDir.

You could (and probably should) use @EXPORT_OK
so others can use it without the package name if they so
choose without polluting their namespace without asking.

If you REALLY want to make changes minimal when you
move the directories around, and even moreso since you
mention making this apply to whole groups of applications, follow my advice
from the original thread, and create a config file. You could make each
script do
this permanently:

open(config, "./myscripts.conf");
$basedir = <config>;
$libdir = <config>;
close(config);
push(@INC, $basedir, $libdir);

This would allow you to only change two lines no matter
with how many scripts you are dealing. If the config file
isn't in the same directory as the scripts, or if the scripts
aren't all in the same directory, you could try making the
config file "~/myscripts.conf" or "/etc/myscripts.conf" or
something similar. You could maintain a seperate config
file for each script if you wanted to, but that might defeat
your purpose.

> AVAILABILITY
>
> The module is currently available via URL,
>
>    http://www.zp.f2s.com/perl/modules/BaseLib-0.01.tar.gz
>
>
> CAVEATS
>
> At this very early stage, BaseLib lacks of many things:
>
>     * portability support
>     * checking the existence of the path in @INC
>     * include standard hierarchy style under LIBDIR
>     * more accommodative regex when untainting
>     * potentially broken if same name as base dir exists
>     * might be broken in mod_perl environment
>     * proper documentation
>     * good testing (only tested it few times myself)
>
>
>
> Thanks for everyone's attention and/or comments.
>
> Best regards,
>
> --
> san
>
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.




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

Date: Thu, 24 Aug 2000 23:59:34 GMT
From: nancy <antsyp@my-deja.com>
Subject: array of array references
Message-Id: <8o4css$suu$1@nnrp1.deja.com>

I'm creating an array which contains references to other arrays (it's a
list of records selected from the database).
I'm not using fetchall_arrayref b/c i need to add a field on to each
record before adding the reference to the master array.
However, when trying to loop through the master array and dereference
the references to the arrays, the same record is printed twice (See
below).
Is there something obvious I'm missing here?
Thanks.

Code snippet:

@users = ('user1','user2');

foreach $user (@users) {
    $query = "SELECT distinct m.userid, m.code2, m.code1 " .
                  "from MailUsers m " .
                  "LEFT JOIN aliases a ON m.userid = a.userid " .
                  "where (m.username = '$user' or a.alias = '$user')";

    $sth = $dbh->prepare($query)
        or die "Couldn't prepare statement: " . $dbh->errstr;
    $sth->execute()
        or die "Couldn't execute statement: " . $sth->errstr;

    # get the result
    @row = $sth->fetchrow_array;
    # add the username sent in to the array
    push @row, $user;
    # add a reference to that array to the masterarray
    push @masterarray, \@row;
    $sth->finish;
}

$dbh->disconnect;

foreach $item (@masterarray) {
    @newrow = @{$item};
    print "$newrow[0] $newrow[1] $newrow[2]\n";
}

Result:
    100    Joe    user2
    100    Joe    user2


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


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

Date: Fri, 25 Aug 2000 02:26:53 +0200
From: sumus@aut.dk (Jakob Schmidt)
Subject: Re: array of array references
Message-Id: <1efweke.1i9lz0ehmwbkwN@[192.168.88.117]>

nancy <antsyp@my-deja.com> wrote:

>     # get the result
>     @row = $sth->fetchrow_array;

my @row = $sth->fetchrow_array;

Should solve your problem. Ask if you can't see why.

> foreach $item (@masterarray) {
>     @newrow = @{$item};
>     print "$newrow[0] $newrow[1] $newrow[2]\n";

Just a tip: You might as well

foreach $item (@masterarray) { print "@$item[ 0..2 ]\n" }

or if indeed it's the whole array you're printing:

foreach $item (@masterarray) { print "@$item\n" }

-- 
Jakob


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

Date: 24 Aug 2000 21:57:54 +0300
From: Juha Laiho <Juha.Laiho@iki.fi>
Subject: Re: Check array for an element
Message-Id: <8o3r7i$2uc$1@ichaos.ichaos-int>

Hermann FASS <hf@ses-astra.com> said:
>Not that there is no workaround, but I would like to
>know an elegant way to check wether an element is
>already contained in an array or not.
>E.g. when parsing an access-log for making a list of authenticated
>users:
>($ip, $user) = /([\d\.]+\s+.*(\w+|-)..../;
>if (! &alreadyPresent($user,@allUsers) ) {
>  push(@allUsers,$user);
>}

If all the data you're going to store to @allUsers is just an array
of user names, I'd suggest you to use a hash instead. Just do
$allUsers{$user}=1;
within the loop, and later on use 'keys %allUsers;' to get a list
of all users seen in the log.
-- 
Wolf  a.k.a.  Juha Laiho     Espoo, Finland
(GC 3.0) GIT d- s+: a- C++ UH++++$ UL++++ P+@ L+++ E(-) W+$@ N++ !K w !O
         !M V PS(+) PE Y+ PGP(+) t- 5? !X R tv--- b+ DI? D G e+ h--- r+++ y+
"...cancel my subscription to the resurrection!" (Jim Morrison)


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

Date: 24 Aug 2000 20:23:34 -0400
From: darkon@one.net (David Wall)
Subject: Re: Check array for an element
Message-Id: <8F9AC7DDDdarkononenet@206.112.192.118>

hf@ses-astra.com (Hermann FASS) wrote in <39A52436.CEC1E3FE@ses-astra.com>:

>Not that there is no workaround, but I would like to
>know an elegant way to check wether an element is
>already contained in an array or not.
>E.g. when parsing an access-log for making a list of authenticated
>users:
>($ip, $user) = /([\d\.]+\s+.*(\w+|-)..../;
>if (! &alreadyPresent($user,@allUsers) ) {
>  push(@allUsers,$user);
>}
>The question is:
>Did anybody write a good &alreadyPresent-subroutine,
>which does not go through the complete @allUsers to
>compare each singel element agains the current $user,
>which seems time-consuming.
>I thought about searching @allUsers in scalar context,
>but there might be s.th. better, he?

Why not use a hash instead of an array? Then you won't even need to write a 
subroutine, just check to see if a key exists.  

-- 
David K. Wall
darkon@one.net


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

Date: Thu, 24 Aug 2000 23:29:21 GMT
From: shalu892 <j_bandi@yahoo.com>
Subject: cookies.
Message-Id: <sqbbuh44t9157@corp.supernews.com>

Hi,
I want to know where the cookies are stored on a client's
browser. I know that in netscape it is stored in 
 .netscape/cookies file but what about other browsers? I would
appreciate if you answer my question.

Thanks.


--
Posted via CNET Help.com
http://www.help.com/


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

Date: Thu, 24 Aug 2000 16:40:45 -0700
From: "Lauren Smith" <lauren_smith13@hotmail.com>
Subject: Re: cookies.
Message-Id: <8o4bm5$a3u$1@brokaw.wa.com>


shalu892 <j_bandi@yahoo.com> wrote in message
news:sqbbuh44t9157@corp.supernews.com...
> Hi,
> I want to know where the cookies are stored on a client's
> browser. I know that in netscape it is stored in
> .netscape/cookies file but what about other browsers? I would
> appreciate if you answer my question.
>

Hi Shalu.  Unfortunately this isn't the type of question that belongs here.
*points to the sign*  This is a Perl newsgroup.  :-)  You were probably
looking for a group with 'browsers' or some such thing in its title.  They
are a couple doors down to your left.

> Posted via CNET Help.com

Did they send you here?  They've been sending people in the wrong direction
for a long time.  It'd be nice if they updated their information.

Lauren
--
print grep ord $_,map{y/a-zA-Z//d;$x.="+ $_";chr(eval $x)}
'J74u43-s2tA1-84n33o45th1er5-12-P3e13-82r48l21H13-a6-76
c40k25er2wx8-y6z13-81'=~m#([^!\n]{3})#g#tr/-0-9//d;print





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

Date: 24 Aug 2000 17:21:00 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: cookies.
Message-Id: <39a5bbec@news.victoria.tc.ca>

shalu892 (j_bandi@yahoo.com) wrote:
: Hi,
: I want to know where the cookies are stored on a client's
: browser. I know that in netscape it is stored in 
: .netscape/cookies file but what about other browsers? I would
: appreciate if you answer my question.

I usually keep mine near the keyboard on a paper napkin.


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

Date: Fri, 25 Aug 2000 02:58:08 +0200
From: tony@svanstrom.com (Tony L. Svanstrom)
Subject: Re: cookies.
Message-Id: <1efwg5x.13vgnxz15z0e7iN%tony@svanstrom.com>

Malcolm Dew-Jones <yf110@vtn1.victoria.tc.ca> wrote:

> shalu892 (j_bandi@yahoo.com) wrote:
> : Hi,
> : I want to know where the cookies are stored on a client's
> : browser. I know that in netscape it is stored in 
> : .netscape/cookies file but what about other browsers? I would
> : appreciate if you answer my question.
> 
> I usually keep mine near the keyboard on a paper napkin.

Personally I've found that it doesn't matter that much, but that you
always should keep track of the matching glas of milk... ;-)


     /Tony
-- 
     /\___/\ Who would you like to read your messages today? /\___/\
     \_@ @_/  Protect your privacy:  <http://www.pgpi.com/>  \_@ @_/
 --oOO-(_)-OOo---------------------------------------------oOO-(_)-OOo--
   on the verge of frenzy - i think my mask of sanity is about to slip
 ---ôôô---ôôô-----------------------------------------------ôôô---ôôô---
    \O/   \O/  ©99-00 <http://www.svanstrom.com/?ref=news>  \O/   \O/


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

Date: Fri, 25 Aug 2000 01:51:18 +0200
From: sumus@aut.dk (Jakob Schmidt)
Subject: Docs on Mac (Was: Re: how to round ?)
Message-Id: <1efwcn7.wrmoqc1layhjaN@[192.168.88.117]>

Martien Verbruggen <mgjv@tradingpost.com.au> wrote:

> If you ever find yourself wondering if a problem or question you have is
> possibly a common one, and one encountered or asked by many other
> people, then you should consult the Perl FAQ[0].
[ heavy snip ]

Gee, Martien - I hope you had that one written in advance and ready to
past into your followup. Or at least that you're a very fast typer ;-)

> [2] I believe that Mac users don't have this command line thing that
> everyone keeps talking about?

We Mac users ain't got no command line, it's true. We do have the .pods
and a GUI application (Shuck) to read them and search through them. But
we lack

perldoc -q
perldoc -f

Unless of course we're in LinuxPPC in stead of MacOS. I'm not right now
'cause sadly I broke my USB keyboard by pouring coffee into it and my
Linux reacts very temperamentally to this old ADB keyboard :-(

Oops - guess that was a bit off topic, eh? Hard to stay on topic at ten
to two in the morning with a more than ten years old keyboard in front
of you. Anyway - I hope you and all the rest of c.l.p.m had a lovely day
and will be blessed with a good night as well.

-- 
Jakob


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

Date: Thu, 24 Aug 2000 22:57:25 GMT
From: perlnewbie@my-deja.com
Subject: Re: errno 22 1024 char limit writing to DB's
Message-Id: <8o498a$om9$1@nnrp1.deja.com>

Thanks for the info.  I have found that the size limitation can set in
SDBM_File source code and then recompiled.  I am going to try that and
see if it works.

In article <8nvpqb$4re$1@orpheus.gellyfish.com>,
  Jonathan Stowe <gellyfish@gellyfish.com> wrote:
> On Tue, 22 Aug 2000 18:27:14 GMT perlnewbie@my-deja.com wrote:
> > I am encountering an error when I try and write to a DB file in
WinNT
> > using Active Perl. Here is the error message I receive:
> >
> > "Tue Aug 22 09:54:07 2000: sdbm store returned -1, errno 22,
> > key "92"..."
> >
> > It seems that I am only allowed to write a maximum of 1024
characters.
> > I was wondering if there is any way to work around this limitation?
>
> Use another DBM implementation I'm afraid - below is the table from
the
> AnyDBM_File manpage :
>
>                                 odbm    ndbm    sdbm    gdbm    bsd-db
>                                 ----    ----    ----    ----    ------
>         Linkage comes w/ perl   yes     yes     yes     yes     yes
>         Src comes w/ perl       no      no      yes     no      no
>         Comes w/ many unix os   yes     yes[0]  no      no      no
>         Builds ok on !unix      ?       ?       yes     yes     ?
>         Code Size               ?       ?       small   big     big
>         Database Size           ?       ?       small   big?    ok[1]
>         Speed                   ?       ?       slow    ok      fast
>         FTPable                 no      no      yes     yes     yes
>         Easy to build          N/A     N/A      yes     yes     ok[2]
>         Size limits             1k      4k      1k[3]   none    none
>         Byte-order independent  no      no      no      no      yes
>         Licensing restrictions  ?       ?       no      yes     no
>
> It might be possible to obtain gdbm or bsd-db for windows - I would
check
> out the Activestate repository in the first place.
>
> /J\
> --
> yapc::Europe in assocation with the Institute Of Contemporary Arts
>    <http://www.yapc.org/Europe/>   <http://www.ica.org.uk>
>


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


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

Date: Thu, 24 Aug 2000 20:43:31 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: File handling and manipulation from function, help please?
Message-Id: <39A5C133.8BDEAC0E@attglobal.net>

Larry Rosler wrote:
> 
> In article <39A534F6.CCD266A5@attglobal.net> on Thu, 24 Aug 2000
> 10:45:10 -0400, Drew Simonis <care227@attglobal.net> says...
> > arvind_kuk@hotmail.com wrote:
> 
> ...
> 
> > > sub subCall {
> > > my($filename) = @_;
> >
> > Better written (IMO) as my $filename = shift;
> > As it is right now, $filename is set to 1.  Certainly not what you
> > want.
> 
> Err, no.  It is set to $_[0], the same as with the shift(), but non-
> destructive to the argument list.  You overlooked the parentheses, which
> create list context for the declared variable.

Doh!  I just looked at my test script I tried this out on, and you
are (as usual) correct.  Forgive my blunder.


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

Date: Thu, 24 Aug 2000 16:20:04 -0700
From: "Lauren Smith" <lauren_smith13@hotmail.com>
Subject: Re: Free Perl compiler ?
Message-Id: <8o4afe$9gr$1@brokaw.wa.com>


<stanley.shapiro@wcom.com> wrote in message
news:8o43nv$irn$1@nnrp1.deja.com...
> Where can I find a perl compiler for Win-NT ?

www.activestate.com

Lauren
--
print grep ord $_,map{y/a-zA-Z//d;$x.="+ $_";chr(eval $x)}
'J74u43-s2tA1-84n33o45th1er5-12-P3e13-82r48l21H13-a6-76
c40k25er2wx8-y6z13-81'=~m#([^!\n]{3})#g#tr/-0-9//d;print





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

Date: Thu, 24 Aug 2000 15:47:23 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: From metacharacter and back again
Message-Id: <MPG.140f45d66f06858c98acde@nntp.hpl.hp.com>

In article <39A590D0.6E1940C3@itron.com> on Thu, 24 Aug 2000 14:17:04 -
0700, TEC <travis.cox@itron.com> says...
> I have a database table that contains information on how to create a
> file. My problem is I want to be able to put metacharacters in the table
> such as \n or \t and then have my Perl script interpolate it as a "new
> line" instead of a string containing "\n". I have done this temporarily
> by doing this: $rs =~ s/\\n/\n/ but I was hoping I wouldn't have to do
> this for all possible values. Any ideas would be appreciated.


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

my $escapes = 'befnrt';
my %escapes = map { $_, eval "qq(\\$_)" } split // => $escapes;

$_ = 'abc\ndef\tghi\zjkl\n';

s/\\([$escapes])/$escapes{$1}/go;

print;

__END__

Output:

abc
def	ghi\zjkl

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


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

Date: Fri, 25 Aug 2000 09:05:43 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: help me decipher PERL
Message-Id: <2kip5.1$Pe3.1861@vic.nntp.telstra.net>

"CyberEyes" <avisingh@my-deja.com> wrote in message
news:8o3j05$u74$1@nnrp1.deja.com...
> Hi

>     my($link, $title, $size, $score, $number) = @_;
>     my($preview, $rvalue, $number);

> "my" variable $number masks earlier declaration in same scope
> at /opt/IBMHTTPServer/cgi-bin/search.cgi line 623.

That would mean that you have declared the variable $number twice within
the same scope (block) and the second declaration is masking the first.
Indeed that is the case, and the second declaration above is redundant.

> <code>
> $mgout .= &process_calendar($category_file[$i], $words, $start, $end);
>     $category_total[$i] = $total;

> Name "main::mgout" used only once: possible typo

The variable $mgout has been used only once in your script.  Since it is
not declared with 'my' in the line above, I would expect to to have
declared it earlier, in which case this is a warning that might indicate
a typo in the variable name.

Otherwise, the use of a variable only once within a script as you have
(assigning a bunch of stuff to it) is rather pointless if you never use
it again.

Wyzelli




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

Date: Thu, 24 Aug 2000 23:47:41 GMT
From: mgjv@verbruggen.comdyn.com.au (Martien Verbruggen)
Subject: Re: help with simple regexp - does my head in
Message-Id: <slrn8qbd06.ma.mgjv@verbruggen.comdyn.com.au>

On 24 Aug 2000 10:35:03 -0500,
	Ren Maddox <ren.maddox@tivoli.com> wrote:
> mgjv@verbruggen.comdyn.com.au (Martien Verbruggen) writes:
> > 
> > I think Abigail was probably comparing the two underlined numbers, and
> > they are significantly different.
> 
> Ah.. but she said that the difference was insignificant, while I (and

15% is significant in relative terms. The insignificant that Abigail
was talking about was that the absolute difference between the two
methods is insignificant in any real life application. It's the word
(in)significant applied to two different things.

It's partly my fault for using the word at all :)

> you, it appears) felt that the difference was significant.  In light
> of this difference, I did not spend an appropriate amount of effort
> understanding the source of her 355 nanosecond figure, and instead

I didn't reread the thread, but wasn't it someone else who calculated
the 355 ns figure from the raw benchmark results?

> jumped to the incorrect conclusion that she was misusing the module.
> I regret my error but feel that my subsequent analysis is still
> correct.

I think there is a bit of confusion, and apparently I'm partly to
blame for that. Yes, the difference between the raw benchmarks is
significant, relatively. Absolutely speaking, in a real application,
however, any gains to be gotten out of this difference will be very
small compared to other work you will be doing in the application. I
believe that those are the conclusions.

I think it's related to the old adagio[1] 'premature optimisation is
the root of all evil'. Unless you know for certain that a particular
bit of code significantly contributes in the running time of your
application, you shouldn't even be looking at it. If you have code
that takes about 1% of the total runtime of your application, you
shouldn't consider optimising it[2].

Martien

[1] Knuth, if I'm not mistaken

[2] Of course, if that particular piece of code is the only one that
is interactive, and people have to wait for it, that's another story.
-- 
Martien Verbruggen              | 
Interactive Media Division      | In a world without fences, who needs
Commercial Dynamics Pty. Ltd.   | Gates?
NSW, Australia                  | 


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

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

abigail@foad.org (Abigail) writes:

> Please provide us with a useful, non-trivial program were use of 1 vs -1
> does make a significant difference.

Well, I've already stated at least twice that I am in complete
agreement with you that it does not make a significant difference in
any real-world way.  I just don't agree that looking at the absolute
time difference of a single iteration is the best way to come to that
conclusion.

-- 
Ren Maddox
ren@tivoli.com


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

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


I still want to try to understand what leads to the -1 index actually
being faster when the split is included (or in any case).  I suppose I
could go digging through the source code to see if there I can find a
reason there, and maybe I will eventually, but I'm hoping that someone
has some thoughts on this matter.

It seems that the naive assumption would be that the -1 index would
have a best-case performance equal to the explicit index.

-- 
Ren Maddox
ren@tivoli.com


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

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

In comp.lang.perl.misc, David H. Adler <dha@panix.com> wrote:
> Eli the Bearded <elijah@workspot.net> wrote:
> >I've used regexps like:
> >	s X (some regexp that includes lots of ! \# \$ \@ \% / , )
> >	  X &replacestring($1) Xxes;
> Indeed.  I was just thinking of you, in fact, while reading through
> the new edition of the camel, which indicates that you can no longer
> do this... unless I misread.  :-(

(output wrapped)

$ perl -MO=Deparse -w
 s X (some regexp that includes lots of ! \# \$ \@ \% / , )
   X &replacestring($1) Xxes;
__END__
s[ (some regexp that includes lots of ! \# \$ \@ % / , )\n][
&replacestring($1);]sex;
- syntax OK
$ perl -v

This is perl, v5.6.0 built for i686-linux-thread-multi

 ...

Elijah
------
noticed that deparse reversed the order of the regexp options


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

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


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