[12072] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5672 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat May 15 10:07:14 1999

Date: Sat, 15 May 99 07:00:18 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Sat, 15 May 1999     Volume: 8 Number: 5672

Today's topics:
        ANNOUNCE: Looking for Perl Jobs and Resumes? (ResumesYES)
    Re: best way to database stuff using Perl? <gellyfish@gellyfish.com>
    Re: Hash arrays <jdf@pobox.com>
    Re: Help: I find tutorial & doc armchair@my-dejanews.com
    Re: Help: I find tutorial & doc <jdf@pobox.com>
    Re: htaccess <davidk@nospam.cnct.com>
    Re: open, read,then print a file armchair@my-dejanews.com
    Re: Parameter pass to PERL armchair@my-dejanews.com
    Re: Perl "constructors" armchair@my-dejanews.com
    Re: Perl "constructors" armchair@my-dejanews.com
    Re: Perl "constructors" armchair@my-dejanews.com
    Re: Perl "constructors" armchair@my-dejanews.com
    Re: Perl "constructors" armchair@my-dejanews.com
    Re: Perl "constructors" armchair@my-dejanews.com
        Perl scripting software mdichirico@my-dejanews.com
    Re: Q: regexpr - WHY???? - HELP!!! (Andrew Johnson)
    Re: uninitialized value <xyf@inetnebr.com>
    Re: uninitialized value <xyf@inetnebr.com>
    Re: uninitialized value <xyf@inetnebr.com>
    Re: uninitialized value <xyf@inetnebr.com>
    Re: uninitialized value <xyf@inetnebr.com>
    Re: uninitialized value (Bart Lateur)
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: 15 May 1999 13:44:47 GMT
From: resumesyes@aol.com (ResumesYES)
Subject: ANNOUNCE: Looking for Perl Jobs and Resumes?
Message-Id: <19990515094447.08843.00001362@ng-ch1.aol.com>

These sites are Free and allow Employers, Agents and Jobs Seekers for both full
time and consulting positions to post and view both Jobs and Resumes for FREE.

Want More you say! 

Both of These sites also offer FREE Automatic EMAIL notification when ANY
message is posted on the Boards, this means that you will ALWAYS be the first
to see when a New Job or Resume is posted.

Still want more you say!

JobRap allows Employers, Agents, Job Seekers and there families to TALK on the
Internet for FREE.  Up to 30 people can be talking at the same time without ANY
loss of conversation, even when multiple people are talking at the same moment.

OH, Now you want the links, well make sure you bookmark them as well

FREE Job and Resumes Posting sites are:

http://www.trav-tech.com

http://www.programming-services.com

JobRap can be DOWNLOADED from:

http://www.trav-tech.com/chat.html


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

Date: 15 May 1999 09:35:40 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: best way to database stuff using Perl?
Message-Id: <7hjf5c$1de$1@gellyfish.btinternet.com>

[comp.lang.perl is dead - and I am certain that btinternet dont carry it
 any more]

In comp.lang.perl.misc owner@btinternet.com wrote:

[Ben - I have sorted out the order of your quoting but please can you
fix your newsreader to do it properly ]

> Charles R. Thompson wrote:
> 
>> [ Congratulations, owner@btinternet.com you could be a winner! Return to
>> comp.lang.perl.misc to claim your prize. ]
>>
>> In article <373B6C9D.7F18C9B@btinternet.com>, owner@btinternet.com
>> says...
>> > I know that the preffered way these days is Cold Fusion, but
>>
>> Like #%(*%# it is. Bad newbie! Bad! :)
>>
>> > say I want to do this via Perl, how would I go about this?
>>
>> Depends on alot. There is a big difference between your choices if you
>> are running your own server in a LAN or WAN deal and renting a little
>> virtual server. Also, depends on what platform you are going to run on.
>>
>> What is the target enviroment for the script(s)? Owned LAN, Virtual
>> Server, Self Maintained Web Server, Windows, UNIX, MAC. The list goes on.
>>
> 
> OK.....to be short and sweet, access to a cgi-bin on a virtual server. I've
> heard a lot about these modules, and am wondering if someone can
> explain/advise on the best way of modifying/querying a database file (created
> from scratch or an existing, preferably MS Access, one)
> 

Generally you will want to be using the appropriate DBI/DBD module for 
the database that you wish/have to use - you will make the decision based
on criteria such as volume of data, transaction integrity and so on ...

Of course this decision will also be constrained by the OS platform you
find yourself on - most probably NT vs Unix.

You will probably *not* want to use MS Access as it is not supported on
non-MS platforms and can only said to be marginally useful for anything
other than single user, low volume use.  If you have a substantial body
of data committed to an Access Database you will probably want to find
someway of exporting it to, say, a CSV file - if you only have a 
relatively small amount of data (sub 10,000 rows say) then you could
probably use DBD::CSV to work directly with this export file - you may
of course be eschewing such things such as transactional integrity that
might be offered by a proper RDBMS, but hey !.  The advantage with using
DBD is that at such a time you should decide to go to a more powerful
RDBMS then the coding changes will be minimal (possibly only the
connect string).

Of course a lot of this depends on the facilities that your hosting
provider has made available to you.  You might want to talk to them
about this.

/J\
-- 
Jonathan Stowe <jns@gellyfish.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>


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

Date: 15 May 1999 09:35:40 -0400
From: Jonathan Feinberg <jdf@pobox.com>
To: armchair@my-dejanews.com
Subject: Re: Hash arrays
Message-Id: <m37lqa1mmr.fsf@joshua.panix.com>

armchair@my-dejanews.com writes:

> I would definitely have to study real hard and long to find out that
> a hash name inside an if test returns 0 if the has is empty.

No, you'd have either to read any decent tutorial (the book _Learning
Perl_ comes to mind) or to read the perl document "perldata", which
states

       If you evaluate a hash in a scalar context, it returns a
       value that is true if and only if the hash contains any
       key/value pairs.

and which comes with perl.  

Good luck in your trolling. 

*plonk*

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY
http://pobox.com/~jdf


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

Date: Sat, 15 May 1999 12:34:43 GMT
From: armchair@my-dejanews.com
Subject: Re: Help: I find tutorial & doc
Message-Id: <7hjpl3$vh3$1@nnrp1.deja.com>

In article <7hb5q1$n8s$1@fe1.cs.interbusiness.it>,
  "Sauro Sgatti" <sauro@fol.it> wrote:
> Where I find tutorial and document of Perl?
> I know perl.org and CPAN site.
>
> Please reply also in email.
> Thanks.
>
>

http://www.ncsa.uiuc.edu/General/Training/PerlIntro/
http://agora.leeds.ac.uk/nik/


--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---


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

Date: 15 May 1999 09:44:34 -0400
From: Jonathan Feinberg <jdf@pobox.com>
To: armchair@my-dejanews.com
Subject: Re: Help: I find tutorial & doc
Message-Id: <m34sle1m7x.fsf@joshua.panix.com>

armchair@my-dejanews.com writes:

> In article <7hb5q1$n8s$1@fe1.cs.interbusiness.it>,
>   "Sauro Sgatti" <sauro@fol.it> wrote:
> > Where I find tutorial and document of Perl?
> > I know perl.org and CPAN site.
> 
> http://www.ncsa.uiuc.edu/General/Training/PerlIntro/
> http://agora.leeds.ac.uk/nik/

Ah, this begins to explain your well-publicized ignorance of Perl.
Neither of those tutorials documents Perl 5, and both are rife with
weird misuses of Perl terms and outright mistakes.

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY
http://pobox.com/~jdf


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

Date: Sat, 15 May 1999 08:22:31 -0400
From: "Dave Kaufman" <davidk@nospam.cnct.com>
Subject: Re: htaccess
Message-Id: <7hjp28$hga@world2.bellatlantic.net>

Eric Umehara wrote...
>.... I want to create a restricted area through which
>you get to through the pop-up password dialoge box used through htaccess.


if you're using Apache, try:
www.apache.org/docs/mod/mod_auth.html

if not, try using Apache :-)

-dave




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

Date: Sat, 15 May 1999 12:21:52 GMT
From: armchair@my-dejanews.com
Subject: Re: open, read,then print a file
Message-Id: <7hjot0$v4j$1@nnrp1.deja.com>

In article <7hj78o$atj$2@justice.csc.cuhk.edu.hk>,
  austin95002887@yahoo.com (Austin Ming) wrote:
>
> How to open, read,then print a text.txt file to the browser in current
> dierectory ?
>
>
----------------------------------------------------------
#!/usr/local/bin/perl -w
use strict;
use diagnostics;


my $input_file = "text.txt";
open(INPUT_FILE,"<$input_file") or die "Can't open file $input_file:
$!\n";


my $file_line = "";
while ( $file_line = <INPUT_FILE> )
{
  print "--> $file_line";
}
close (INPUT_FILE);


--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---


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

Date: Sat, 15 May 1999 11:57:09 GMT
From: armchair@my-dejanews.com
Subject: Re: Parameter pass to PERL
Message-Id: <7hjnel$ucm$1@nnrp1.deja.com>

In article <7hitpk$o2u$1@unix2.glink.net.hk>,
  rwmip@glink.net.hk (Raymond Ip) wrote:
> If I written a perl script to run it under UNIX environment, and want
to
> pass some parameter to the perl script.
>
> How do I check how many parameter pass to the script ?
>
> Best Regards
>
> Raymond Ip
>

The command line parameters become elements in an array called @ARGV.

You find out the number by assigning the array to a scalar which causes
the number of entries to be assigned.

my $num_arguments = @ARGV;

or for a little more logical clarity to non-Perl programmers

my $num_arguments = scalar(@ARGV);

and you access the elements like a normal array:

if ( $num_arguments > 0 )
{
  print ("the first argument passed to this script was",$ARGV[0]);
}


--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---


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

Date: Sat, 15 May 1999 12:44:34 GMT
From: armchair@my-dejanews.com
Subject: Re: Perl "constructors"
Message-Id: <7hjq7i$vt7$1@nnrp1.deja.com>

In article <373d5ea4@cs.colorado.edu>,
  tchrist@mox.perl.com (Tom Christiansen) wrote:
> In comp.lang.perl.misc, armchair@my-dejanews.com writes:
> :> You're confused.  The %hash is Perl's record construct.
> :
> :You are saying that a hash can be used to approximate a record in
Perl.
>
> I did not.  The word "approximate" never left my lips.  Call
> a spade a spade.  The has *is* perl's implementation of a record.
> It is not an approximation.  Please remove the C++ pole from your
> posterior.  It's starting to poke up into your brain.

Ah, so then it was me that said a hash is a Perl's approximation of a
record, but is not equal to it. I knew one of us said it.

>
> --tom
> --
>     "You can't have filenames longer than 14 chars.
>      You can't even think about them!"
>         --Larry Wall in Configure from the perl distribution
>


--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---


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

Date: Sat, 15 May 1999 12:42:58 GMT
From: armchair@my-dejanews.com
Subject: Re: Perl "constructors"
Message-Id: <7hjq4j$vsq$1@nnrp1.deja.com>

In article <7uc%2.10345$L4.363390@news2.rdc1.on.home.com>,
  andrew-johnson@home.com wrote:
> In article <7hjfeg$pl9$1@nnrp1.deja.com>,
>  armchair@my-dejanews.com <armchair@my-dejanews.com> wrote:
> ! In article <ylzp366dm2.fsf@windlord.stanford.edu>,
> !   Russ Allbery <rra@stanford.edu> wrote:
>
> [snip]
>
> ! > > I don't think it is too much to ask for a function, a complement
to
> ! > > "exists" if you will, that tells how many items are in a hash.
> ! >
> ! > What, like $count = keys %hash?
> !
> ! Very expensive, not intuitive. What is the hash has 2000 items.
Create
> ! a matching array just to get a count of them?
>
> What makes you think that is what perl is doing?

Because the book I have - "Perl From the Ground Up" in it's built-in
function reference says that keys "returns all the keys for the Hash
named". It does not mention "scalar context" as some right honorable
fellow was nice enough to point out that the perlfunc does inside of
parenthese after stating the above regarding returning all the keys.

> Just because keys()
> returns a list in a list context doesn't mean that in scalar context
> is has to build the list and then count the items. How do you know
> perl doesn't maintain the number of keys in a special slot called
> xhv_keys somewhere in its HV hash stucture and simply returns that
> when keys() is used in scalar context? Did you run timing
> tests to see if scalar keys() showed degraded performance
> with larger hashes? did you run similar memory tests? did you look
> at the source code?

I don't. No. No. No. No.
Correct me if I am wrong, but I will assume you are aggresively implying
that $scalar = keys %hash  operates just like the entries() function I
was requesting. Thanks for the info.

>
> regards
> andrew
>
>


--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---


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

Date: Sat, 15 May 1999 12:45:51 GMT
From: armchair@my-dejanews.com
Subject: Re: Perl "constructors"
Message-Id: <7hjq9v$66$1@nnrp1.deja.com>

In article <373d5e07@cs.colorado.edu>,
  tchrist@mox.perl.com (Tom Christiansen) wrote:
>
> In comp.lang.perl.misc, armchair@my-dejanews.com writes:
> :What is your opinion of the dual use of {} in variable context -
either
> :to specify a member of a hash, or to dereference a reference? This
leads
> :to confusion in my opinion. There are already two other ways to
> :dereference a reference.
>
> It is the destiny of small minds to shrink.

I won't repeat my response to their other "you got a small brain"
fellow, as I am sure you will find it.
>
> --tom
> --
>     "Don't wear rollerskates to a tug-of-war." --Larry Wall
>


--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---


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

Date: Sat, 15 May 1999 13:16:43 GMT
From: armchair@my-dejanews.com
Subject: Re: Perl "constructors"
Message-Id: <7hjs3q$18m$1@nnrp1.deja.com>

In article <373d5fd9@cs.colorado.edu>,
  tchrist@mox.perl.com (Tom Christiansen) wrote:
> In comp.lang.perl.misc, armchair@my-dejanews.com writes:
> :You cannot connect() with a
> :constructor and get a status code back from the connect() - you get a
> :reference to the object just created whether your connection has been
> :successful or not. This problem exists in C++ as well.
>
> You're wrong.  That's not the way it works in Perl.

Oh, and how does it work in Perl.
I have only seen examples where a Perl constructor returns a reference
to a blessed variable which is a reference. Hence the syntax

my $new_object = MyClass->Connect();

if Connect() (your constructor) fails, we end up with a reference to a
object that has not connected. With no idea that it failed at this
point.


>
> :So in effect, Perl has a capability to "overload" a classes
constructors
> :then, I take it.
>
> No, that's not it.  Again you fail to understand.

However you want to term it, if there is more than one constructor for a
class, they are "overloaded" to use a C++ term.

>
> :What is the most classes that a module could implement? What is the
most
> :packages that a module could define?
>
> There is such limit.

I see:
package Abc;  in Abc.pm
and in test.pl I see
use Abc;
where it is stated that Abc is assumed to be in Abc.pm.

if in Abc.pm I had
package Xyx;
how do I use that in test.pl?


>
> :> :In any event, you can't get around the fact that
> :> :constructors return a blessed reference.
> :> Oh, good.  You're wrong again.  I most certainly can.
> :Well, let's see some code my good man.
>
>     sub fred { "barney" }

That looks like a subroutine. I am talking about constructors.
If that's a constructor, provide the code of a perl script that
instantiates one.
>
> :Well, to be correct functions that fail should actually throw
> :exceptions, but that is not available in Perl, so returning an error
> :code, and checking it, is the way to go if you want "robust" code.
>
> You're wrong again.   Perl has exceptions.  You have no clue.

Perl certainly does not have exceptions that I have seen or are you
calling die exceptions?

>
> I've had enough.
>
>     He who knows not and knows not he knows not,
> 	he is a fool - shut him.
>     He who knows not and knows he knows not,
> 	he is a child - teach him.
>     He who knows and knows not he knows,
> 	he is aleep - wake him.
>     He who knows and knows he knows,
> 	he is a teacher - heed him.
>
> You sir, being of the formermost variety, are doomed to
> being <plonked>.   Get your head out of C++ and learn
> Perl for Perl.  Actually, I take that back.  Get out of
> Perl.  Your congenital (or conC++) brain damage will
> always preclude understanding.  Please go torture some
> other programming langauge.  You will never understand Perl.

It appears that understanding Perl is a binary event. But the question
is, what is <plonked>?

>
> --tom
> --
>     char program[1];        /* Unwarranted chumminess with compiler.
*/
>             --Larry Wall in the Perl source code
>     (quoting Henry Spencer (quoting Dennis Ritchie (quoting Brian
Kerninghan)))
>


--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---


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

Date: Sat, 15 May 1999 13:17:23 GMT
From: armchair@my-dejanews.com
Subject: Re: Perl "constructors"
Message-Id: <7hjs52$190$1@nnrp1.deja.com>

In article <373d5fd9@cs.colorado.edu>,
  tchrist@mox.perl.com (Tom Christiansen) wrote:
> In comp.lang.perl.misc, armchair@my-dejanews.com writes:
> :You cannot connect() with a
> :constructor and get a status code back from the connect() - you get a
> :reference to the object just created whether your connection has been
> :successful or not. This problem exists in C++ as well.
>
> You're wrong.  That's not the way it works in Perl.

Oh, and how does it work in Perl.
I have only seen examples where a Perl constructor returns a reference
to a blessed variable which is a reference. Hence the syntax

my $new_object = MyClass->Connect();

if Connect() (your constructor) fails, we end up with a reference to a
object that has not connected. With no idea that it failed at this
point.


>
> :So in effect, Perl has a capability to "overload" a classes
constructors
> :then, I take it.
>
> No, that's not it.  Again you fail to understand.

However you want to term it, if there is more than one constructor for a
class, they are "overloaded" to use a C++ term.

>
> :What is the most classes that a module could implement? What is the
most
> :packages that a module could define?
>
> There is such limit.

I see:
package Abc;  in Abc.pm
and in test.pl I see
use Abc;
where it is stated that Abc is assumed to be in Abc.pm.

if in Abc.pm I had
package Xyx;
how do I use that in test.pl?


>
> :> :In any event, you can't get around the fact that
> :> :constructors return a blessed reference.
> :> Oh, good.  You're wrong again.  I most certainly can.
> :Well, let's see some code my good man.
>
>     sub fred { "barney" }

That looks like a subroutine. I am talking about constructors.
If that's a constructor, provide the code of a perl script that
instantiates one.
>
> :Well, to be correct functions that fail should actually throw
> :exceptions, but that is not available in Perl, so returning an error
> :code, and checking it, is the way to go if you want "robust" code.
>
> You're wrong again.   Perl has exceptions.  You have no clue.

Perl certainly does not have exceptions that I have seen or are you
calling die exceptions?

>
> I've had enough.
>
>     He who knows not and knows not he knows not,
> 	he is a fool - shut him.
>     He who knows not and knows he knows not,
> 	he is a child - teach him.
>     He who knows and knows not he knows,
> 	he is aleep - wake him.
>     He who knows and knows he knows,
> 	he is a teacher - heed him.
>
> You sir, being of the formermost variety, are doomed to
> being <plonked>.   Get your head out of C++ and learn
> Perl for Perl.  Actually, I take that back.  Get out of
> Perl.  Your congenital (or conC++) brain damage will
> always preclude understanding.  Please go torture some
> other programming langauge.  You will never understand Perl.

It appears that understanding Perl is a binary event. I am reminded of
religous conversions.... But the question is, what is <plonked>?

>
> --tom
> --
>     char program[1];        /* Unwarranted chumminess with compiler.
*/
>             --Larry Wall in the Perl source code
>     (quoting Henry Spencer (quoting Dennis Ritchie (quoting Brian
Kerninghan)))
>


--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---


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

Date: Sat, 15 May 1999 13:24:42 GMT
From: armchair@my-dejanews.com
Subject: Re: Perl "constructors"
Message-Id: <7hjsip$1bk$1@nnrp1.deja.com>

In article <373d5ffc@cs.colorado.edu>,
  tchrist@mox.perl.com (Tom Christiansen) wrote:
> In comp.lang.perl.misc, armchair@my-dejanews.com writes:
> :In article <ylzp366dm2.fsf@windlord.stanford.edu>,
> :  Russ Allbery <rra@stanford.edu> wrote:
> :> armchair <armchair@my-dejanews.com> writes:
> :>
> :> > I can speak to this: connect() and prepare() should be member
> YOUR BROKEN EXCUSE FOR A NEWSREADER MISWRAPPED THIS:
> :functions
> :> > and not constructors as a member function can return a status
code
> YOUR BROKEN EXCUSE FOR A NEWSREADER MISWRAPPED THIS:
> :of
> :> > success or various error codes. A constructor cannot.
> :>
> :> Constructors certainly can return various error codes, as well as
> YOUR BROKEN EXCUSE FOR A NEWSREADER MISWRAPPED THIS:
> :success
> :> or failure.
> :
> :And what does your code look like?
>
> You already posted this.  Was there some reason you thought
> we needed to see it again, or are you merely as incompetent
> at using software as you are at reading documentation?

You strip out to much of the previous post. Try editing less, and
answering more. You posted  sub Fred { "barney" }; someplace else.
Certainly an incomplete demonstration of a constructor that returns
something other than a reference to a blessed object - if it even is
one!


>
> :my $reference = myclass->new();
> :if ( $reference == 0 )
>
> No, that's wrong.  Don't test for 0.
>
> if ($value) suffices for truth, and
> unless ($value) for falsehood.  This == 0 business
> is brain-damange.

Why shackle someone's code style to your biases. Try and be more
libertarian, like Perl and Larry Wall

>
> :{
> :  print "constructor failed\n";
> :}
> :
> :Correct?
>
> No, you should probably be raising an exception.
> printing to stdout is silly.

Is raising and exception supposed to be the die function?
> In C++ and Java, but not in Perl. Does it have them, and if so which
> :perl HTML page section are they documented in?
>
> % man perlfunc
>
> :> What, like $count = keys %hash?
> :
> :Very expensive, not intuitive.
>
> Liar.  Twice.

As it turns out, only once. Someone has proclaimed it not expensive, but
no sane man, woman or child would ever call it intuitive.


>
> :Asumming I just want to test emptiness. Thanks, just tried it, and it
> :worked, but I do have one comment - non-intuitive, non-lookupable,
> :obtuse.
>
> Thrice.

I was dead on on this one, which you deleted but it was:

If ( %hash)
{
   ... has was not empty
}

>
> --tom
> --
> "Make is like Pascal: everybody likes it, so they go in and change it.
"
> 	    --Dennis Ritchie
>


--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---


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

Date: Sat, 15 May 1999 11:50:39 GMT
From: mdichirico@my-dejanews.com
Subject: Perl scripting software
Message-Id: <7hjn2f$u3e$1@nnrp1.deja.com>

Hi, I'm working through "Learning Perl" and I'm doing the examples in
there with NotePad on my Windows computer.  Does anyone have a
suggestion of some good scripting environment software?

Thank you,
Mike


--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---


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

Date: Sat, 15 May 1999 12:00:38 GMT
From: andrew-johnson@home.com (Andrew Johnson)
Subject: Re: Q: regexpr - WHY???? - HELP!!!
Message-Id: <Gld%2.10394$L4.364531@news2.rdc1.on.home.com>

In article <373D7633.B5BB7DEB@informatik.uni-marburg.de>,
 K.Posern <posern@informatik.uni-marburg.de> wrote:
! Hi.
! 
! I don't believe it's "perls-fault" but I DON'T FIND THE ERROR - so
! PLEASE HELP ME.
! 
! Here is the code:
! 
! while ("bla_HQD___blub_MEDICIN" =~
! /(H)([^\1])([^\1\2])([^\1\2\3])([^\1\2\3\4])\4([^\1\2\3\4\5])/g) {
!      print "MATCH='$&'\n"
!      print "1=$1, 2=$2, 3=$3, 4=$4, 5=$5, 6=$6.\n";
! }
! 

backreferences don't make much sense in a character class so they are
interpreted as single digit octal escapes. You might get what you are
looking for using negative look-ahead in a manner like:

/(H)(?!\1)(.)(?!\1|\2)(.)(?!\1|\2|\3)  ... and so on /g

regards
andrew


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

Date: Sat, 15 May 1999 07:45:55 -0500
From: ktb <xyf@inetnebr.com>
Subject: Re: uninitialized value
Message-Id: <373D6C83.12ECA46F@inetnebr.com>

Russ Allbery wrote:
> 
> ktb <xyf@inetnebr.com> writes:
> 
> > Hi, I'm writing this script to search a database.  It works fine when I
> > search the first split, "$parts[0]" but if I try to search "$parts[1]" I
> > get the following errors:
> 
> > Use of uninitialized value at ./testst line 19, <BottleFile> chunk
> > 11461.
> > Use of uninitialized value at ./testst line 19, <BottleFile> chunk
> > 11461.
> 
> Are you sure that line contains a tab?  If it doesn't, $parts[1] won't be
> set and you'll get that error.

Yes the data is separated by a tab between the bottle description and
the citation.  I'm sure there are a few mistakes but there are 6000 +
entries and as far as I can tell all entries but the ones containing the
word searched spit out the error.

Thanks, I'll play around with some of your suggestions.  This is my
first attempt at a programming language.  
kent

> 
> > open(BottleFile, "botglass.txt");
> 
> Always check the return status of open(), just in case.
> 
> > @bottle = <BottleFile>;
> >     foreach $line (@bottle) {
> 
> More easily written as:
> 
>         foreach $line (<BottleFile>) {
> 
> or even:
> 
>         while (<BottleFile>) {
> 
> for more efficiency.
> 
> >         @parts = split(/\t/, $line );
> >         $PartsFile = $parts[1];
> 
> >           } continue {
> 
> Why do this in a continue block?
> 
> >         foreach ($PartsFile) {
> >             if (/\Q$SearchString/i) {
> 
> Why use foreach?  You can just say:
> 
>         if ($PartsFile =~ /\Q$SearchString/i) {
> 
> --
> #!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
> $^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
>  00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
> rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print


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

Date: Sat, 15 May 1999 07:53:32 -0500
From: ktb <xyf@inetnebr.com>
Subject: Re: uninitialized value
Message-Id: <373D6E4C.61C449FE@inetnebr.com>

Russ Allbery wrote:
> 
> ktb <xyf@inetnebr.com> writes:
> 
> > Hi, I'm writing this script to search a database.  It works fine when I
> > search the first split, "$parts[0]" but if I try to search "$parts[1]" I
> > get the following errors:
> 
> > Use of uninitialized value at ./testst line 19, <BottleFile> chunk
> > 11461.
> > Use of uninitialized value at ./testst line 19, <BottleFile> chunk
> > 11461.
> 
> Are you sure that line contains a tab?  If it doesn't, $parts[1] won't be
> set and you'll get that error.

Yes the data is separated by a tab between the bottle description and
the citation.  I'm sure there are a few mistakes but there are 6000 +
entries and as far as I can tell all entries but the ones containing the
word searched spit out the error.

Thanks, I'll play around with some of your suggestions.  This is my
first attempt at a programming language.  
kent

> 
> > open(BottleFile, "botglass.txt");
> 
> Always check the return status of open(), just in case.
> 
> > @bottle = <BottleFile>;
> >     foreach $line (@bottle) {
> 
> More easily written as:
> 
>         foreach $line (<BottleFile>) {
> 
> or even:
> 
>         while (<BottleFile>) {
> 
> for more efficiency.
> 
> >         @parts = split(/\t/, $line );
> >         $PartsFile = $parts[1];
> 
> >           } continue {
> 
> Why do this in a continue block?
> 
> >         foreach ($PartsFile) {
> >             if (/\Q$SearchString/i) {
> 
> Why use foreach?  You can just say:
> 
>         if ($PartsFile =~ /\Q$SearchString/i) {
> 
> --
> #!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
> $^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
>  00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
> rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print


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

Date: Sat, 15 May 1999 08:09:18 -0500
From: ktb <xyf@inetnebr.com>
Subject: Re: uninitialized value
Message-Id: <373D71FE.8AA3EB1F@inetnebr.com>

Russ Allbery wrote:
> 
> ktb <xyf@inetnebr.com> writes:
> 
> > Hi, I'm writing this script to search a database.  It works fine when I
> > search the first split, "$parts[0]" but if I try to search "$parts[1]" I
> > get the following errors:
> 
> > Use of uninitialized value at ./testst line 19, <BottleFile> chunk
> > 11461.
> > Use of uninitialized value at ./testst line 19, <BottleFile> chunk
> > 11461.
> 
> Are you sure that line contains a tab?  If it doesn't, $parts[1] won't be
> set and you'll get that error.

Yes the data is separated by a tab between the bottle description and
the citation.  I'm sure there are a few mistakes but there are 6000 +
entries and as far as I can tell all entries but the ones containing the
word searched spit out the error.

Thanks, I'll play around with some of your suggestions.  This is my
first attempt at a programming language.  
kent

> 
> > open(BottleFile, "botglass.txt");
> 
> Always check the return status of open(), just in case.
> 
> > @bottle = <BottleFile>;
> >     foreach $line (@bottle) {
> 
> More easily written as:
> 
>         foreach $line (<BottleFile>) {
> 
> or even:
> 
>         while (<BottleFile>) {
> 
> for more efficiency.
> 
> >         @parts = split(/\t/, $line );
> >         $PartsFile = $parts[1];
> 
> >           } continue {
> 
> Why do this in a continue block?
> 
> >         foreach ($PartsFile) {
> >             if (/\Q$SearchString/i) {
> 
> Why use foreach?  You can just say:
> 
>         if ($PartsFile =~ /\Q$SearchString/i) {
> 
> --
> #!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
> $^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
>  00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
> rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print


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

Date: Sat, 15 May 1999 08:02:09 -0500
From: ktb <xyf@inetnebr.com>
Subject: Re: uninitialized value
Message-Id: <373D7051.A74FFDD3@inetnebr.com>

Russ Allbery wrote:
> 
> ktb <xyf@inetnebr.com> writes:
> 
> > Hi, I'm writing this script to search a database.  It works fine when I
> > search the first split, "$parts[0]" but if I try to search "$parts[1]" I
> > get the following errors:
> 
> > Use of uninitialized value at ./testst line 19, <BottleFile> chunk
> > 11461.
> > Use of uninitialized value at ./testst line 19, <BottleFile> chunk
> > 11461.
> 
> Are you sure that line contains a tab?  If it doesn't, $parts[1] won't be
> set and you'll get that error.

Yes the data is separated by a tab between the bottle description and
the citation.  I'm sure there are a few mistakes but there are 6000 +
entries and as far as I can tell all entries but the ones containing the
word searched spit out the error.

Thanks, I'll play around with some of your suggestions.  This is my
first attempt at a programming language.  
kent

> 
> > open(BottleFile, "botglass.txt");
> 
> Always check the return status of open(), just in case.
> 
> > @bottle = <BottleFile>;
> >     foreach $line (@bottle) {
> 
> More easily written as:
> 
>         foreach $line (<BottleFile>) {
> 
> or even:
> 
>         while (<BottleFile>) {
> 
> for more efficiency.
> 
> >         @parts = split(/\t/, $line );
> >         $PartsFile = $parts[1];
> 
> >           } continue {
> 
> Why do this in a continue block?
> 
> >         foreach ($PartsFile) {
> >             if (/\Q$SearchString/i) {
> 
> Why use foreach?  You can just say:
> 
>         if ($PartsFile =~ /\Q$SearchString/i) {
> 
> --
> #!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
> $^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
>  00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
> rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print


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

Date: Sat, 15 May 1999 07:52:21 -0500
From: ktb <xyf@inetnebr.com>
Subject: Re: uninitialized value
Message-Id: <373D6E05.7BE2B30E@inetnebr.com>

Russ Allbery wrote:
> 
> ktb <xyf@inetnebr.com> writes:
> 
> > Hi, I'm writing this script to search a database.  It works fine when I
> > search the first split, "$parts[0]" but if I try to search "$parts[1]" I
> > get the following errors:
> 
> > Use of uninitialized value at ./testst line 19, <BottleFile> chunk
> > 11461.
> > Use of uninitialized value at ./testst line 19, <BottleFile> chunk
> > 11461.
> 
> Are you sure that line contains a tab?  If it doesn't, $parts[1] won't be
> set and you'll get that error.

Yes the data is separated by a tab between the bottle description and
the citation.  I'm sure there are a few mistakes but there are 6000 +
entries and as far as I can tell all entries but the ones containing the
word searched spit out the error.

Thanks, I'll play around with some of your suggestions.  This is my
first attempt at a programming language.  
kent

> 
> > open(BottleFile, "botglass.txt");
> 
> Always check the return status of open(), just in case.
> 
> > @bottle = <BottleFile>;
> >     foreach $line (@bottle) {
> 
> More easily written as:
> 
>         foreach $line (<BottleFile>) {
> 
> or even:
> 
>         while (<BottleFile>) {
> 
> for more efficiency.
> 
> >         @parts = split(/\t/, $line );
> >         $PartsFile = $parts[1];
> 
> >           } continue {
> 
> Why do this in a continue block?
> 
> >         foreach ($PartsFile) {
> >             if (/\Q$SearchString/i) {
> 
> Why use foreach?  You can just say:
> 
>         if ($PartsFile =~ /\Q$SearchString/i) {
> 
> --
> #!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
> $^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
>  00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
> rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print


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

Date: Sat, 15 May 1999 13:44:29 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: uninitialized value
Message-Id: <373d78db.272263@news.skynet.be>

ktb wrote:

>> > Hi, I'm writing this script to search a database.  It works fine when I
>> > search the first split, "$parts[0]" but if I try to search "$parts[1]" I
>> > get the following errors:
>> 
>> > Use of uninitialized value at ./testst line 19, <BottleFile> chunk
>> > 11461.
>> > Use of uninitialized value at ./testst line 19, <BottleFile> chunk
>> > 11461.

>Yes the data is separated by a tab between the bottle description and
>the citation.  I'm sure there are a few mistakes but there are 6000 +
>entries and as far as I can tell all entries but the ones containing the
>word searched spit out the error.

>> >         @parts = split(/\t/, $line );
>> >         $PartsFile = $parts[1];

A warning. Even if this line contains a tab, split() removes all empty
fields at the end of the (would be) array. So

	$_ = "let's go\t";
	@parts = split/\t/;

You might expect @parts to be

	("let's go", "")

but in fact you have

	("let's go")

If you then try to access the non-existent field $part[1], this is
automatically filled in as undef() by Perl.

I guess that a nonexistent field isn't interesting to search through,
anyway, so you could just do

	next unless defined($PartsFile = $parts[1]);

which does both the assignment and the test in one line.

   HTH,
   Bart.


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

Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>


Administrivia:

Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing. 

]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body.  Majordomo will then send you instructions on how to confirm your
]subscription.  This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.

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.misc (and this Digest), send your
article to perl-users@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.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

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 V8 Issue 5672
**************************************

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