[18634] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 802 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Apr 30 14:06:36 2001

Date: Mon, 30 Apr 2001 11:05:08 -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: <988653908-v10-i802@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Mon, 30 Apr 2001     Volume: 10 Number: 802

Today's topics:
    Re: Am I in the perl Debugger? (M.J.T. Guy)
    Re: Appending to files and flock. nobull@mail.com
        AUTOLOAD Clarification <jasonh@colubs.com>
    Re: Can I include local perl snipits? <dodger@necrosoft.net>
    Re: Can I include local perl snipits? (Randal L. Schwartz)
    Re: Can I include local perl snipits? <mischief@velma.motion.net>
    Re: Chicago Perl Consultants Needed <henryhartley@westat.com>
    Re: Chicago Perl Consultants Needed (David H. Adler)
    Re: How can I stop at the frist matching <ren@tivoli.com>
    Re: How secure is this.... <dodger@necrosoft.net>
    Re: How to convert integer to string? (Perl newbie) <mischief@velma.motion.net>
    Re: How to write a multi process program with perl ? <gtoomey@usa.net>
    Re: Html link in mysql data (Tad McClellan)
    Re: https module <dodger@necrosoft.net>
        new to perl hanton32@hotmail.com
        one-line stderr, stdout redirection <nospam@newsranger.com>
    Re: one-line stderr, stdout redirection (Randal L. Schwartz)
    Re: Perl compete: Java is dead on server side!! PHP is  <havoc@harrisdev.com>
        perlcc on RedHat Linux 6.2 <nospam@hotmail.com>
    Re: pointer/reference question nobull@mail.com
    Re: RegEx optimization assistance <andrew@mvt.ie>
        RegExp Teaser <bigusAT@btinternetDOT.com>
    Re: Simple newbie performance question <ren@tivoli.com>
    Re: Strange string -> num conversion <mischief@velma.motion.net>
    Re: Strange string -> num conversion <bart.lateur@skynet.be>
    Re: tinyweb server <fatcatfan_quitspammingme_@hotmail.com>
        What does qw do? (J. Cooper)
    Re: What does qw do? (E.Chang)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 30 Apr 2001 15:13:16 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Am I in the perl Debugger?
Message-Id: <9cjvec$a0i$1@pegasus.csx.cam.ac.uk>

Broc Seib  <bseib@jade.cc.purdue.edu> wrote:
>
>Does anyone know for certain that $^P will always be zero when running
>normal, and non-zero if in the debugger?

Short answer: yes, in practice.    I use it all the time.

Longer answer with caveats:
Bits in $^P are also set by other development/debugging tools, such
as Devel::Dprof.    And of course the user program can set or reset
$^P as it likes.    For example, I often surround a fork() with a

		local $^P = 0;

since the debugger tends to get discombobulated when faced with
forking processes.

But provided you avoid such things, and/or understand their implications,
the simple rule is OK.


Mike Guy


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

Date: 30 Apr 2001 18:19:09 +0100
From: nobull@mail.com
Subject: Re: Appending to files and flock.
Message-Id: <u9wv82z4oi.fsf@wcl-l.bham.ac.uk>

"John Lin" <johnlin@chttl.com.tw> writes:

> <nobull> wrote
> > If you know you are only going to use a system that does correctly
> > implement appending (i.e. not Win32) then you can omit the seek() from
> > the above code.
> 
> Do you mean Win32's open ">>" is problematic?

Yes - for discussion see the previous thread discussing this issue,
about 5 weeks ago.

> Can you give a sample code for me to experiment?

Please see the previous thread[1].

The code I refer to above is the example from "perldoc -f flock".

Like I say on Win32 you need the seek() to work-round a bug.

To get code to illustrate a bug you can take the code illustrating a
work-round for the bug and remove the work-round.  (Now please slap
your forehead and say "D'oh!").

[1] The person who presented the code actually presented it as example
code to illustrate that seek() was necessary because he didn't
understand (despite it already having been explained to him) that the
behaviour he was observing was an OS bug.  Others then pointed out
that the code (without the seek) works just fine on Unix.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Mon, 30 Apr 2001 10:15:55 -0700
From: "Jason Hurst" <jasonh@colubs.com>
Subject: AUTOLOAD Clarification
Message-Id: <3aed9dc1$0$26606@wodc7nh0.news.uu.net>

I'm having problems understanding the autoload method.  I understand the
principle as to how it works: when a method isn't defined, it goes to the
autoload method instead.  My confusion is when you're extending a module
that has an autoload function and your new module ALSO has an autoload
function.  Can I access the SUPER::AUTOLOAD if the function doesn't exist in
my new module.  So, for example, lets say you have something like this:



package Foo;



sub AUTOLOAD {...}



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



package Bar;

use base qw(Foo);



 ...

my %feilds = {

  foo => undef,

  bar => undef,

}



sub AUTOLOAD {

  my ($self, @param) = @_;



  my $ref = ref($key) or die "don't think so";



  my $key = $AUTOLOAD

  $key =~ s/.*://;



  if (!$feilds{$key}) {

    #here is where i want to look at the SUPER AUTOLOAD, because

    # we just tried to do AUTOLOAD, but we couldn't find the functon here

    # so is there any way to do something like this:

    $self->SUPER::AUTOLOAD(@param);

  }else{

    ...  #do whatever here

  }

}



From my understanding when you use autoload, perl first goes through all of
@ISA THEN hits the autoload in your current module.  Does this mean that it
stops there or will it continue to go through @ISA looking for autoloads?
Thanks for any clarification you can offer on this, it's starting to hurt my
head. :)





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

Date: Mon, 30 Apr 2001 17:09:54 GMT
From: "Dodger" <dodger@necrosoft.net>
Subject: Re: Can I include local perl snipits?
Message-Id: <C%gH6.39649$B22.9693496@news1.rdc2.pa.home.com>

<nobull@mail.com> wrote in message news:u93daymep7.fsf@wcl-l.bham.ac.uk...
> God_Of_Pain <silicontao_roy@technologist.com> writes:
>
> > Newsgroups:
alt.perl,comp.lang.perl,comp.lang.perl.misc,comp.lang.perl.modules
>
> You do realise comp.lang.perl does not exist don't you?

What the hell are you talking about, mate? That's where I read this.

> > Followup-To: alt.perl
>
> Ignored!  Most people who know Perl answers won't read alt.perl so by
> directing answers away from the real groups you will make you question
> appear not to have been answered.

Again...  I read both. I don't feel that weird.

--
Dodger
www.dodger.org
www.necrosoft.net
www.gothic-classifieds.com





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

Date: 30 Apr 2001 10:16:13 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Can I include local perl snipits?
Message-Id: <m14rv6b95u.fsf@halfdome.holdit.com>

>>>>> "Dodger" == Dodger  <dodger@necrosoft.net> writes:

>> You do realise comp.lang.perl does not exist don't you?

Dodger> What the hell are you talking about, mate? That's where I read this.

It doesn't exist in the absolute sense.  If your newsserver is
carrying it, they are broken.

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


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

Date: Mon, 30 Apr 2001 17:27:53 -0000
From: Chris Stith <mischief@velma.motion.net>
Subject: Re: Can I include local perl snipits?
Message-Id: <ter84p118r9m5c@corp.supernews.com>

In comp.lang.perl.misc Dodger <dodger@necrosoft.net> wrote:
> <nobull@mail.com> wrote in message news:u93daymep7.fsf@wcl-l.bham.ac.uk...
>> God_Of_Pain <silicontao_roy@technologist.com> writes:
>>
>> > Newsgroups:
> alt.perl,comp.lang.perl,comp.lang.perl.misc,comp.lang.perl.modules
>>
>> You do realise comp.lang.perl does not exist don't you?

> What the hell are you talking about, mate? That's where I read this.

It's been officially dead for years. Your newsservice is misconfigured
if it lets your newsreader post there.

>> > Followup-To: alt.perl
>>
>> Ignored!  Most people who know Perl answers won't read alt.perl so by
>> directing answers away from the real groups you will make you question
>> appear not to have been answered.

> Again...  I read both. I don't feel that weird.

I disagree with the statement that alt.perl is worthless. I rather like
some of the discussion I've seen there. It's not quite like c.l.p.misc,
but it's not intended to be. I just wish StuporNews would carry it so
I don't have to hit Google to look through it.

Chris

-- 
It's not the U in UBE that pisses people off. It's the B.
  -- Martien Verbruggen in clp.misc



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

Date: Mon, 30 Apr 2001 12:08:01 -0400
From: Henry Hartley <henryhartley@westat.com>
Subject: Re: Chicago Perl Consultants Needed
Message-Id: <3AED8DE1.8A9A5E98@westat.com>

"Scott R. Godin" wrote:
> 
> In article <9cjqj9$rs9@spamz.news.aol.com>,
>  "Jason C. Hill" <jhill@technoslave.net> wrote:
> 
> 
>  | > >  | > He seems as perceptive as a potato.
>  | > >  |
>  | > >  | Hey!  Don't insult the potatoes that way!
>  | > >  |
>  | > >
>  | > > yeah, we wouldn't want them going around with a chip on their
>  | > > shoulders...
>  | >
>  | > Or making eyes at us.
>  |
>  | Don't make me skin you alive for making these lame posts about potatoes!!!
>  |
> 
> Lame? I thought they had a certain appeal, myself.

Yes, I think we're getting to the root of the matter now.

-- 
Henry Hartley


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

Date: 30 Apr 2001 16:42:13 GMT
From: dha@panix2.panix.com (David H. Adler)
Subject: Re: Chicago Perl Consultants Needed
Message-Id: <slrn9er5f6.b5.dha@panix2.panix.com>

In article <9cju99$nsl$0@216.155.32.52>, Scott R. Godin wrote:
> In article <9cjqj9$rs9@spamz.news.aol.com>,
>  "Jason C. Hill" <jhill@technoslave.net> wrote:
> 
>  
>  | > >  | > He seems as perceptive as a potato.
>  | > >  |
>  | > >  | Hey!  Don't insult the potatoes that way!
>  | > >  |
>  | > >
>  | > > yeah, we wouldn't want them going around with a chip on their
>  | > > shoulders...
>  | >
>  | > Or making eyes at us.
>  | 
>  | Don't make me skin you alive for making these lame posts about potatoes!!!
>  | 
> 
> Lame? I thought they had a certain appeal, myself. 

It's responses like this that are the root of the problem...

dha

-- 
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
Perl gives you enough rope to hang yourself and your neighbor.
     - Randal L. Schwartz


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

Date: 30 Apr 2001 10:35:14 -0500
From: Ren Maddox <ren@tivoli.com>
Subject: Re: How can I stop at the frist matching
Message-Id: <m3hez6pfil.fsf@dhcp9-172.support.tivoli.com>

On Mon, 30 Apr 2001, bart.lateur@skynet.be wrote:

> Ann Tica wrote:
> 
>>I have a variable $var
>>and I want to extract "8.1.0" from the line if the line starts with 
>>name[789]
>>My codes return "7.2.3" ?!
> 
>>name8 line2 sls sl sl sls 8.1.0.2 slsl 7.2.3.1 ddd
> 
>>$var =~ /^(.*)(name[789].* )([789]\.\d\.\d)/m;
>>print "$3\n";
> 
> Make the .* right after "name[789]" non-greedy, by adding a question
> mark:
> 
> $var =~ /^(.*)(name[789].*? )([789]\.\d\.\d)/m;

And keep in mind that since you have a ".*" at the beginning, multiple
occurrences of "name[789]" on the line will also cause a similar
problem.  Plus, you're forcing the regex engine to do a lot of
(probably unnecessary) backtracking.

Above, you say "if the line starts with name[789]".  If that is really
the condition, then you probably don't need the "(.*)" on the front at
all.

-- 
Ren Maddox
ren@tivoli.com


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

Date: Mon, 30 Apr 2001 17:10:30 GMT
From: "Dodger" <dodger@necrosoft.net>
Subject: Re: How secure is this....
Message-Id: <a0hH6.39650$B22.9693774@news1.rdc2.pa.home.com>

No, he means it's an encryption routine.

--
Dodger
www.dodger.org
www.necrosoft.net
www.gothic-classifieds.com
"Super-Simon" <simon@super-simon.com> wrote in message
news:9c4oiv$lmo$1@news1.xs4all.nl...
> You mean it's a hashing-routine....
>
>
> "Brett Foster" <onasc@remove.me@home.com> wrote in message
> news:eLkF6.96228$61.20567500@news4.rdc1.on.home.com...
> > It is my information that once you crypt you can't go back. In other
> words,
> > you cannot determin what the value of $passwd was before calling crypt.
> >
> > "Super-Simon" <simon@super-simon.com> wrote in message
> > news:9c2b12$sbn$1@news1.xs4all.nl...
> > > Hi,
> > >
> > > In most security-scripts the following code is used for encryption:
> > >
> > > print crypt($passwd,$salt);
> > >
> > > Is this safe, or at least difficult to crack, is there something
> better???
> > > Please help me.
> > >
> > >
> > > Grtz,
> > >
> > > Simon
> > >
> > >
> >
> >
>
>




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

Date: Mon, 30 Apr 2001 17:05:18 -0000
From: Chris Stith <mischief@velma.motion.net>
Subject: Re: How to convert integer to string? (Perl newbie)
Message-Id: <ter6qe44t5ab89@corp.supernews.com>

Rudolf Polzer <eins@durchnull.de> wrote:
> Godzilla! <godzilla@stomp.stomp.tokyo> wrote:
>> David Blair wrote:
>> 
>> (snipped) 
>> 
>> > I need to get the random number to between 1 and 10...
>> 
>> > $randnum = int(rand * 10);
>> 
>> > but that is not satisfactory because it truncates the
>> > the decimal rather than rounding it.
>> 
>> 
>> This is untrue.
>> 
>> Your code is attempting to find the product of
>> a word, "rand" and the number 10. This is not
>> possible; your code is not numeric in nature.
>> Your return is 0 (zero) not a truncated decimal.

'rand' is a builtin function. It is treated as such
in the OP's program.

> No. The code does not work because 

> int (rand * 10)
> is parsed as
> int (rand (*main::10))
> (*main::10 is a typeglob).

> You will get this information when you enable warnings. 'rand' is not 
> parsed as a word.

This is true. Try this:

    $ perl -w
    print( rand * 10 );
    print "\n";

Now try this:

    $ perl -w
    print( (rand) * (10) );
    print "\n";

Of course, what the OP wants is 'rand(10)' or 'rand 10', but
'( (rand) * (10) )' will do the same thing. It's just clunky to
disambiguate this from other meanings using all those parens.

Why Kira feels the need to argue with Rudolf when Rudolf is correct
I do not know. A little empirical testing proves Rudolf is correct.

perldoc -f rand

Chris

-- 
People understand instinctively that the best way for computer programs to
communicate with each other is for each of the them to be strict in what they
emit, and liberal in what they accept. The odd thing is that people themselves
are not willing to be strict in how they speak, and liberal in how they listen.
 -- Larry Wall, 2nd State of the Onion Address, August 1998



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

Date: Tue, 1 May 2001 02:00:15 +1000
From: "Gregory Toomey" <gtoomey@usa.net>
Subject: Re: How to write a multi process program with perl ?
Message-Id: <WMfH6.14830$482.76319@newsfeeds.bigpond.com>


"Uri Guttman" <uri@sysarch.com> wrote in message
news:x7oftff3zn.fsf@home.sysarch.com...
> >>>>> "GT" == Gregory Toomey <gtoomey@usa.net> writes:
>
>   GT> If you've only got 1 CPU, five processes many not run faster than 1
>   GT> process - there is only 1 running process at any instant.
>
> please learn about multiprocessing before you make foolish claims like
> that. any of the processes could be blocked on a system call or disk i/o
> and the others can then run. ever heard of timesharing? :)
 ...

My comment started "If you've only got 1 CPU", and is correct.

gtoomey




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

Date: Mon, 30 Apr 2001 09:29:11 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Html link in mysql data
Message-Id: <slrn9eqq57.gr1.tadmc@tadmc26.august.net>

carlfox <carlfox@netdoor.com> wrote:
>Could anyone help me figure out how to make an html tag appear as a link
>in mysql data? Mine just appear as the text, as follows:
>
><A HREF=photo.htm>Go to Photo</a>
>
>I want to be able to click on the link to take me elsewhere from witin
>the mysql data presentation.


What is your Perl question?


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


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

Date: Mon, 30 Apr 2001 15:24:59 GMT
From: "Dodger" <dodger@necrosoft.net>
Subject: Re: https module
Message-Id: <ftfH6.39564$B22.9664132@news1.rdc2.pa.home.com>


"Brian Richardson" <lamecow78@hotmail.com> wrote in message
news:cKXG6.66654$Zn4.718551@news1.rdc1.ab.home.com...
>
> "Paul Cotter" <prcotter@bellsouth.net> wrote in message
> news:fQ%F6.1649$5B4.665630@news2.mia...
> > "smilepak" <smilepak@hotmail.com> wrote in message
> > news:BJID6.971$cM1.57429@newsread1.prod.itd.earthlink.net...
> >
> > > I need to access a secure http site to pull data on a daily basis. The
> > site
> > > request a username/password. Anyone know of a way I can get perl to do
a
> > > https call and passing a username/password when it request for it?
> > >
> > > I know perl has a "GET" function, however that doesn't work with
secure
> > http
> > > server.
> > >
>
> [ snip ]
>
> Ouch! That's a lot of code for a simple thing that could be done using
> LWP::UserAgent;
> Check the documentation on CPAN to double-check that it does what you
need.
> You may also need to look into LWP::SecureSockets and Net::SSLeay should
you
> in fact be dealing with a secure server.

You do need ssleay installed. In addition, as far as I know, you should
compile LWP _after_ ssleay is installed. I have written an LWP utility that
worked over ssl, though it did not go through server-based user
authentication.

--
Dodger




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

Date: 30 Apr 2001 15:00:10 GMT
From: hanton32@hotmail.com
Subject: new to perl
Message-Id: <9cjulq$e7p$1@news.netmar.com>


I would like to start learning Perl. Specifically for loading (flat files) and
unloading from databases (ie. Oracle). can someone recommend a book or site
where I can start. Is perl DBI the way to go or ????

thanks and any help appreciated

 -----  Posted via NewsOne.Net: Free (anonymous) Usenet News via the Web  -----
  http://newsone.net/ -- Free reading and anonymous posting to 60,000+ groups
   NewsOne.Net prohibits users from posting spam.  If this or other posts
made through NewsOne.Net violate posting guidelines, email abuse@newsone.net


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

Date: Mon, 30 Apr 2001 16:31:29 GMT
From: Gerald Shuman <nospam@newsranger.com>
Subject: one-line stderr, stdout redirection
Message-Id: <BrgH6.4149$SZ5.335582@www.newsranger.com>

What's the perl equivalent of "exec 2> stderr.txt" in a shell script?




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

Date: 30 Apr 2001 10:02:18 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: one-line stderr, stdout redirection
Message-Id: <m1g0eqb9t1.fsf@halfdome.holdit.com>

>>>>> "Gerald" == Gerald Shuman <nospam@newsranger.com> writes:

Gerald> What's the perl equivalent of "exec 2> stderr.txt" in a shell script?

open STDERR, ">stderr.txt" or die "Cannot reopen STDERR: $!";


-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


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

Date: Mon, 30 Apr 2001 10:20:30 -0600
From: havoc <havoc@harrisdev.com>
Subject: Re: Perl compete: Java is dead on server side!! PHP is 4 times faster  than JSP,CF,ASP!!
Message-Id: <3AED90CE.A10E8FAF@harrisdev.com>

> PHP is the fastest web-scripting language and is 4 times faster than

I just love it when people use this type of statistic.... Cocain and
Heroin use are up, too. does that make them good for you?

havoc
-- 
*****=======| http://bigpig.org/
*****=======|
*****=======| It's about Freedom!
============|


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

Date: Mon, 30 Apr 2001 11:56:12 -0500
From: Mr. SunRay <nospam@hotmail.com>
Subject: perlcc on RedHat Linux 6.2
Message-Id: <NOgH6.586$XU2.186520@news.uswest.net>

Hi all,

Using Perl 5.6 on RedHat 6.2.

When I tried to run 'perlcc' I got the following:

>/usr/local/bin/perlcc -b -c edi2excel edi2excel.pl

--------------------------------------------------------------------------------
Compiling edi2excel.pl:
--------------------------------------------------------------------------------
Making Bytecode(edi2excel.plc) for edi2excel.pl!
perl -I/usr/local/lib/perl5/5.6.0/i686-linux -I/usr/local/lib/perl5/5.6.0 
-I/usr/local/lib/perl5 -I/usr/local/lib/perl5/5.6.0/i686-linux 
-I/usr/local/lib/perl5/5.6.0 -I/usr/local/lib/perl5/site_perl/5.6.0/i686-linux 
-I/usr/local/lib/perl5/site_perl/5.6.0 -I/usr/local/lib/perl5/site_perl -I. 
-MB::Stash -c  edi2excel.pl
perl -I/usr/local/lib/perl5/5.6.0/i686-linux -I/usr/local/lib/perl5/5.6.0 
-I/usr/local/lib/perl5 -I/usr/local/lib/perl5/5.6.0/i686-linux 
-I/usr/local/lib/perl5/5.6.0 -I/usr/local/lib/perl5/site_perl/5.6.0/i686-linux 
-I/usr/local/lib/perl5/site_perl/5.6.0 -I/usr/local/lib/perl5/site_perl -I. 
-MO=Bytecode, edi2excel.pl
Can't load '/usr/local/lib/perl5/5.6.0/i686-linux/auto/B/B.so' for module B: 
/usr/local/lib/perl5/5.6.0/i686-linux/auto/B/B.so: undefined symbol: 
PL_op_desc at /usr/local/lib/perl5/5.6.0/i686-linux/XSLoader.pm line 73.
 at /usr/local/lib/perl5/5.6.0/i686-linux/B.pm line 262
BEGIN failed--compilation aborted at 
/usr/local/lib/perl5/5.6.0/i686-linux/O.pm line 2.
BEGIN failed--compilation aborted.
ERROR: In generating code for edi2excel.pl!

Just for kicks I even tried adding the Dynaloader module in at line 393.  No 
difference (not that I expected one).

Any ideas?  Thanks in advance for any and all help.

Regards,

Dan




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

Date: 30 Apr 2001 18:26:37 +0100
From: nobull@mail.com
Subject: Re: pointer/reference question
Message-Id: <u9vgnmz4c2.fsf@wcl-l.bham.ac.uk>

garry@ifr.zvolve.net (Garry Williams) writes:

> On Sat, 21 Apr 2001 23:11:46 -0500, xris <xris@dont.send.spam> wrote:
> 
> > In article <9btbef$e2r$1@mamenchi.zrz.TU-Berlin.DE>,

> > My main concern is that I'll forget the extra $ to dereference something 
> > and it'll cost me hours of bug testing to find the typo.  :)
> 
>   use warnings;
>   use strict;
> 
> Program without fear.  

Bogus!  I always wear a seat-belt but this this does not mean that I
expect it to protect me in a side-impact or that I drive without fear
(or at least due caution).

xris is talking about doing something like: $foo{$bar} when he meant
to write $foo{$$bar}.  In this case warnings and strict are usually no
help because the implicit stringification of a reference does not
yeild a warning.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Mon, 30 Apr 2001 17:08:57 +0100
From: "Andrew" <andrew@mvt.ie>
Subject: Re: RegEx optimization assistance
Message-Id: <9ck2sn$g39$1@kermit.esat.net>


"Drew" <nospam@newsranger.com> wrote in message
news:5aDF6.5046$QV4.428882@www.newsranger.com...
> In article <tebccapccsrm3f@corp.supernews.com>, Craig Berry says...

> >: >>memory                     page                          faults
> >: >>avm    free   si   so    pi   po    fr   de    sr     in     sy    cs
> >: >>21996  203131    0    0     0    0     9    0     0   3054  27087
806
> >: >>CPU

> >: >>while ( <DATA> ) {
> >: >>    if ( /\bfree\b/ ) {
> >: >>        my @keys = split " ";
> >: >>        @stats{ @keys } = split " ", <DATA>;
> >: >                                      ^^^^^^
>
> When I run this, I get all the column headings, but no data.  Should I be
> splitting on something other than spaces?
>

It looks from the data originally provided that it may have been tab
delimited, rather than space delimited.

Trying this might work;

my @keys = split /\t|\s+/;
@stats{ @keys } = split /\t|\s+/, <DATA>;

Andrew





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

Date: Mon, 30 Apr 2001 19:02:36 +0100
From: "S Warhurst" <bigusAT@btinternetDOT.com>
Subject: RegExp Teaser
Message-Id: <9ck8ul$ic2$1@plutonium.btinternet.com>

Hi

You regulars must be getting fed up of regular expression questions. I've
read a number of articles on it & am slowly getting the grasp of it.
However, I haven't been able to suss this one out..

I have a text file containing the following kind of text (a listserv catalog
file in case anyone recognises it):

* preamble
*
* more preamble
*
-#-file1.txt
* File 1 description
-#-file2.htm
* File 2 description
* some file descriptions have more than one line
-#-file3.xls
* File 3 description-#-

Now, I converted the array holding the file contents into a scalar & added
the "-#-" in order to make the regexp easier. Here is the one I came up
with:

$tmp = $filecontents = ~ /-#-.+-#-/sg

Now that works to a point, but what it returns (I'm going by memory here,
but I think you will get the point) is:

-#-file1.txt * File 1 description -#-
-#-file3.xls * File 3 description -#-

What it's doing is it's including the ending "-#-" delimiter thingy. How can
I get it not to include the end "-#-".. (the character before that could be
any character).

Many thanks if you can help :)

Spencer




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

Date: 30 Apr 2001 11:28:57 -0500
From: Ren Maddox <ren@tivoli.com>
Subject: Re: Simple newbie performance question
Message-Id: <m3d79upd12.fsf@dhcp9-172.support.tivoli.com>

On Sun, 29 Apr 2001, ixlu@PCGuide.com wrote:

> I'm new to perl but not to programming in general. I just want to do
> a "sanity check" on an application I am considering to make sure
> that I am not asking too much of this particular interpreted
> language.

Not that it really matters, but Perl isn't actually an interpreted
language.  There just isn't a separate compile step for the
programmer.  Rather, the program is compiled and then run, all in one
step (from the user's perspective).

> The application in question will need to handle loading and
> searching through some fairly large arrays--possibly 50,000
> items. For example, I might need to load a 50,000 line file into a
> 2D array of say 50,000x10, with each set of 10 elements
> corresponding to 10 pieces of data in one line in the file.  Then I
> would need to do some pattern matching where I try to find a
> particular line and look at the data in those other 9 entries that
> go with it. In fact, I would probably have to do this fairly often.

This should be fine.  Assuming you actually use hashes (as you
mentioned in a follow-up), then speed should be quite good.  The only
real concern is the amount of memory used, as Perl isn't all that
memory-efficient.  Still, I wouldn't think 50,000 x 10 elements is
going to be too bad.

> Is this something that Perl can handle pretty well? Is it preferable
> to use the built-in expression-matching functions, or should I write
> a quick binary search for this sort of thing? I don't need lightning
> speed, but I don't want it to be lumberingly slow either. Just
> looking for some ballpark ideas...

It depends on exactly how you will be searching.  If you are just
going to be doing hash-lookups, then it will be quite fast.  For
something more complicated, you may find that a binary search is
worthwhile.  However, a binary search would need sorted data, and the
data cannot be sorted on multiple keys(*), so you should be able to
use the sort key as the hash key and avoid the search (and sort)
entirely.

(*) If you do need to search on multiple keys, you might find a good
solution is to store a reference to the data in additional hashes
keyed by each of the different keys.

#!/usr/bin/perl -w
use strict;
my %hash1;
my %hash2;
while(<DATA>) {
  my ($key1, $key2, @data) = split;
  $hash1{$key1} = \@data;
  $hash2{$key2} = \@data;
}
print qq/Data for key 1 of "blue" is: @{$hash1{blue}}\n/;
print qq/Data for key 2 of "square" is: @{$hash2{square}}\n/;
__DATA__
red square this is the first set of data
blue circle this is the second set of data
yellow triangle this is the third set of data
__END__

Note that this example makes no effort to handle duplicate key
values.  Also, unless you are going to be changing the data, it isn't
strictly necessary to store references to it -- but assuming
non-trivial data size, it can save some memory.

-- 
Ren Maddox
ren@tivoli.com


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

Date: Mon, 30 Apr 2001 15:51:03 -0000
From: Chris Stith <mischief@velma.motion.net>
Subject: Re: Strange string -> num conversion
Message-Id: <ter2f7rl7m4h72@corp.supernews.com>

Bart Lateur <bart.lateur@skynet.be> wrote:
> Chris Stith wrote:

>>This really is a Perl issue. Look at this:
>>
>>[mischief@mischief mischief]$ perl
>>print "0x12" + 1;
>>print "\n";
>>2.125
>>
>>There's no shell there. 

> The shell has nothing to do with it. People here have been claiming that
> this behaviour depends on the linkled in C library.

There's at least one post I saw in this thread which suggested
using 'perl -le' instead of 'perl -e' because of the shell. I
thought I'd point out that this is not the case. You seem to think
I'm saying it does have something to do with the shell. It seems
you did not read my post.

> If perl were to include a standard functionality instead of depending on
> external 3rd party libraries, just as with (s)printf, at least the
> behaviour would be platform independent. Er... except for the internal
> representation of the numbers, that is...

But that's the point. It's _documented_ to work this way! _Documented_!
This has nothing to do with C libraries any more than it has to do
with the shell. The C libraries do not decide how or when to DWIM a
string of digits into a number. Only perl does that. This is a casting
issue within perl. And it's _documented_. Did you read my post at all?

Why would you care if use contrary to the documentation varies from
platform to platform? It's undefined anyway! It's _documented_ that
numbers in bases other than decimal will not be seen as such in
string literals. If it's _documented_ that you must do step B to attain
goal C, then who cares if one platform differs from another when
you didn't perform step B? It's _documented_. It's _Perl_. It's done
in _perl_, not in a a library. This is Perl acting according to
perlvar. Read the post. Read the docs. Come to the conclusion that
if it's documented, then it's not a bug. It may be suboptimal, but
it is working as expected.

Chris

-- 
If they can get you asking the wrong questions, they don't
have to worry about the answers.
  -- Thomas Pynchon, Gravity's Rainbow



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

Date: Mon, 30 Apr 2001 16:27:46 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Strange string -> num conversion
Message-Id: <lk4ret4dtn7djgcnliq4ctqcm0l36m8a9d@4ax.com>

Chris Stith wrote:

> It's _documented_ that
>numbers in bases other than decimal will not be seen as such in
>string literals. If it's _documented_ that you must do step B to attain
>goal C, then who cares if one platform differs from another when
>you didn't perform step B? It's _documented_. It's _Perl_.

Don't get all worked up.

And no, it's not documented as such. It is documented that "0x12" as a
string would not be treated differently than "123var". It *should*
return zero.

-- 
	Bart.


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

Date: Mon, 30 Apr 2001 11:14:51 -0500
From: "Eric K" <fatcatfan_quitspammingme_@hotmail.com>
Subject: Re: tinyweb server
Message-Id: <ter3t2kfnndl96@corp.supernews.com>

Yes, though I decided to switch to a different server, eventually. =
TinyWeb discards multiple cookies in your headers, keeping only the last =
one sent. No way to set to nph mode either. And all cookies in redirect =
headers are dropped. I recompiled TinyWeb to fix the multi-cookie =
problem, but not the redirect one.

"Bart Lateur" <bart.lateur@skynet.be> wrote in message =
news:hfeqet4tm76djrad0qtl1k3h5pm0suegp0@4ax.com...
> jtjohnston wrote:
>=20
> >Has anyone succeeded in getting Perl to run in
> >http://www.ritlabs.com/tinyweb/ ?
>=20
> Yes.
>=20
> What's your problem?
>=20
> --=20
> Bart.



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

Date: Mon, 30 Apr 2001 16:11:43 GMT
From: jean.coopernyetspam@sympatico.ca (J. Cooper)
Subject: What does qw do?
Message-Id: <3aed9001.12780096@news1.on.sympatico.ca>

Hi,

I'm trying to understand some Perl code, and have come across
qw(http:// ....).  I can't seem to find any reference to qw, can
anyone tell me what it does?

Thanks,

Jean


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

Date: Mon, 30 Apr 2001 16:26:11 GMT
From: echang@netstorm.net (E.Chang)
Subject: Re: What does qw do?
Message-Id: <Xns90937DBB5FC67echangnetstormnet@207.106.93.86>

jean.coopernyetspam@sympatico.ca (J. Cooper) wrote in 
<3aed9001.12780096@news1.on.sympatico.ca>:

> Hi,
> 
> I'm trying to understand some Perl code, and have come across
> qw(http:// ....).  I can't seem to find any reference to qw, can
> anyone tell me what it does?
> 
> Thanks,
> 
> Jean


perldoc -f qw  reveals
       qw/STRING/
               Generalized quotes.  See the Regexp Quote-Like
               Operators entry in the perlop manpage.

You can find the referenced documentation online at http://www.perldoc.com/ 
if you are not sure how to access it locally.

-- 
EBC


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

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.  

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


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