[9503] in Perl-Users-Digest
Perl-Users Digest, Issue: 3096 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jul 8 14:17:22 1998
Date: Wed, 8 Jul 98 11:00:26 -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 Wed, 8 Jul 1998 Volume: 8 Number: 3096
Today's topics:
Re: -w on production code (was Re: better way of gettin (Abigail)
Re: -w on production code (was Re: better way of gettin (Mike Stok)
Re: <STDIN> chunk 1 - Error <maierc@chesco.com>
Re: Accessing shell variables in a perl script <xmarkjones@mindless.com>
aside: my .signature just got shorter <merlyn@stonehenge.com>
Capturing Output of Individual SQL Queries <rxruck2@uswest.com>
Re: Capturing Output of Individual SQL Queries (brian d foy)
Comparing arbitrary dates <xmarkjones@mindless.com>
Determination of end of record? <chewie@nuernberg.netsurf.de>
Re: Docs for a2p/walk.c? <Russell_Schulz@locutus.ofB.ORG>
explaining the whys of referencing... WAS Re: on the fl <dtbaker_@flash.net>
Re: explaining the whys of referencing... WAS Re: on th (Larry Rosler)
good research methods WAS Re: on the fly subs with spec <dtbaker_@flash.net>
I have a question. <jackx@cs.itc.hp.com>
Re: Indexing servers (brian d foy)
Re: NEVER "call warn() and return undef" (Re: question (Peter Scott)
Re: NEVER "call warn() and return undef" (Re: question (Mike Stok)
Re: NEVER "call warn() and return undef" (Re: question <zenin@bawdycaste.org>
Re: new charter and moderator for comp.lang.perl.announ <merlyn@stonehenge.com>
Re: Oh man, DO I love Perl ! (References to things that (Tye McQueen)
Re: Oh man, DO I love Perl ! (References to things that <zenin@bawdycaste.org>
Re: Oh man, DO I love Perl ! (References to things that <tchrist@mox.perl.com>
Re: perl 5.004.04 on AIX 4.2.1 <Walter.Harms@Informatik.Uni-Oldenburg.DE>
Re: Placeholders in Perl? (Mike Stok)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 8 Jul 1998 17:15:44 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: -w on production code (was Re: better way of getting the last modified file?)
Message-Id: <6o09g0$pj8$1@client3.news.psi.net>
Harald Joerg (Harald.Joerg@mch.sni.de) wrote on MDCCLXXII September
MCMXCIII in <URL: news:35A33487.93DF2802@mch.sni.de>:
++ Abigail wrote:
++ >
++ > You wrote:
++ > ++ And when people then use -w the net result is a furiously scrolling
++ > ++ screen, with absolutely *no* way of seeing any of the more serious
++ > ++ errors that might occur.
++ >
++ > Anything that contains "serious errors" is alpha code in my book.
++
++ In an error log the errors of *all* actions performed by the server
++ are concatenated. It is hard to spot a serious error in program A
++ when program B will print some screenfuls of warnings twice per
++ minute.
Ever heard of grep?
++ This does not make program B alpha code in your book ;-)
Screenfuls of warnings twice a minute? Nope, that's not alpha code.
Pre-alpha code it is.
++ I feel that we have some confusion about the term "production code".
++ Not all production code is CGI. CGI itself is not "production" at all.
++
++ > ++ [...]
++ > ++ In other words, and again, leave off -w in *production* code. IMnsHO.
++ >
++ > Just for those once in more than a year events of upgrading Perl?
++ > Don't you want to know what might be broken now, or will be broken
++ > in the next release? Ever considered *testing* your scripts before
++ > installing a new version of Perl?
++
++ All scripts should be tested. With -w.
++ Having scripts tested by web users invoking a CGI is a different story.
Each run is a test, and if it triggers a warning, it means the program
encountered a (possible dangerous) situation you had not anticipated.
(Else the warning wouldn't have been triggered).
++ You can (and should) test your CGI *with* -w, you can do so in automated
++ procedures if you like. Just invoke it with "perl -w mycgi".
++ You can test the CGI interface itself with automated web clients.
++ The -w flag can then tell you about errors in your HTML form
++ (misspelled NAME attribute), and you know *when* to look at the
++ error log.
++ You should not even consider testing production code per hand only.
Unless you have formally proven your code to be correct, every invocation
of your program is another testrun.
Abigail
--
perl -we 'print split /(?=(.*))/s => "Just another Perl Hacker\n";'
------------------------------
Date: 8 Jul 1998 17:44:53 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: -w on production code (was Re: better way of getting the last modified file?)
Message-Id: <6o0b6l$nkg@news-central.tiac.net>
In article <6o09g0$pj8$1@client3.news.psi.net>,
Abigail <abigail@fnx.com> wrote:
>Each run is a test, and if it triggers a warning, it means the program
>encountered a (possible dangerous) situation you had not anticipated.
>(Else the warning wouldn't have been triggered).
This seems a tad misleading.
How can the perl interperter tell if I hadn't anticipated the warning?
Maybe I know things about my data or code which mean that I have accounted
for the situations or I just don't care if things fail. If I want to dump
the contents of a file which might not exist then this is fine:
open F, "</some/file";
print while <F>;
close F;
Larry Wall did a good job in making a tool which gives you the flexibility
to do things the way you want (and the associated responsibility...)
>Unless you have formally proven your code to be correct, every invocation
>of your program is another testrun.
If the test run gets the job done then that's fine :-) Sometimes other
pressures preclude such vigourous testing even if it's considered a "good
thing".
The advice of "*always* use -w" seems to smack of cargo cult programming
to me.
Mike
--
mike@stok.co.uk | The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/ | PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/ | 65 F3 3F 1D 27 22 B7 41
stok@colltech.com | Collective Technologies (work)
------------------------------
Date: Wed, 08 Jul 1998 17:23:49 GMT
From: Charles Maier <maierc@chesco.com>
Subject: Re: <STDIN> chunk 1 - Error
Message-Id: <35A1D837.45B3@chesco.com>
Larry Rosler wrote:
>
> In article <35A1329A.D9D5A89F@provideo.dk> on Mon, 06 Jul 1998 13:24:58 -
> 0700, Thomas Albech <thomas@provideo.dk> says...
> > Hi everyone,
> >
> > I just bought the Learning Perl book. I got to page 14 and typed in the
> > following code as in the book:
> ...
> > if ($name =~ "randal") {
>
> Type more carefully.
>
> if ($name eq "randal") {
>
> --
> Larry Rosler
> Hewlett-Packard Laboratories
> http://www.hpl.hp.com/personal/Larry_Rosler/
> lr@hpl.hp.com
Thats ok.. the operator =~ means "contains" to ME. I read his line as
saying "$name contains randal"... which should work just as well.
His problem appears to be.. he is printing a possible NULL value. If the
name enterred is NOT in the hash.. he does not test for it.... and tries
to print it.
> $secretword = $words{$name}; # get the secret word
> print "$secretword\n"; # Displays secret word
A better choice might be:
if exists($words{$name}) {
$secretword = $words{$name}; # get the secret word
print "$secretword\n"; # Displays secret word
} else {
$secretword = "groucho";
}
..yada yada
--
Chuck Maier
CDM Consulting Services
http://www.cdmcon.com
(610) 943-2726
------------------------------
Date: Wed, 08 Jul 1998 11:17:42 -0500
From: Mark Evan Jones <xmarkjones@mindless.com>
Subject: Re: Accessing shell variables in a perl script
Message-Id: <35A39BA5.2858A79E@mindless.com>
Thanks for the help; I got them to change the variable to a setenv one
in their script.
Mark Jones
(remove the x to reply by email)
------------------------------
Date: Wed, 08 Jul 1998 17:33:44 GMT
From: Randal Schwartz <merlyn@stonehenge.com>
Subject: aside: my .signature just got shorter
Message-Id: <8ck95ofdsn.fsf@gadget.cscaper.com>
For many years, you've seen something like this at the bottom of my Perl
newsgroup postings:
print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $22,319.19 collected, $186,159.85 spent; just 54 more days
## before I go to *prison* for 90 days; email fund@stonehenge.com for details
Most of you know what it's about, but if you don't, email that address
for details. :-)
Today, I appeared in court, as requested in the original sentencing
hearing three years ago, and begged the court to remove the 90 day
prison sentence that was to begin on the first of September. The
judge agreed that my behavior during probation met and exceeded all of
his expectations and requirements, so he changed the sentence from
deferred to suspended, while still leaving me on probation (for up to
two more years).
Needless to say, this thrills me to no end. I'm not out of the woods
yet. I've got another 18 months in the appeal process (which might
result in a re-trial in about two years), but at least I don't face
the upcoming pain of being in jail for 90 days.
For more details, look at the "Friends of Randal Schwartz" site at:
http://www.lightlink.com/fors/
and the Jeffrey Kegler "Oregon v. Schwartz" site at:
http://www.rahul.net/jeffrey/ovs/
Thanks.
(Look... no extra lines down here... :-)
print "Just another Perl hacker,"
--
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me
------------------------------
Date: Wed, 08 Jul 1998 11:49:00 -0500
From: Ryan Rucker <rxruck2@uswest.com>
Subject: Capturing Output of Individual SQL Queries
Message-Id: <35A3A2FC.27A1CDF0@uswest.com>
Hello,
I'm using the code below to open a pipe to an Oracle database and pass
some queries to it (contained in file queries.txt):
open(SQL, "| sqlplus -s scott/tiger\@database")or
die "Can't run SQL*Plus: $!\n";
open(QRY, "queries.txt") or die "Can't open queries.txt: $!\n";
$queries=<QRY>;
while ($queries ne "") {
print SQL "$QRY\n"; # want to capture output here
$queries=<QRY>; # skip a line of non-query text
$queries=<QRY>;
}
My problem is that at the point where I print a line back to SQL (which
contains a transaction), I'd like to capture the output from Oracle and
take some action based on a success or non-success.
With the help of the FAQ and reading Deja News archives, I'm able to
redirect output to a file, but only at the "open(SQL...)" line. That
doesn't work because it captures the output ok, but I need to be able to
detect an error in Oracle as soon as it happens, take some action, then
move on.
Is there a way to catch the output coming back from Oracle and put it in
a variable? If so, I could examine the variable as soon as each
transaction is passed to Oracle and take whatever action I need to.
Is this something that must be done in Oraperl or with some of the
SQL-friendly modules? I'd hate to have to re-write this script from
scratch (very long).
Thanks for your help,
Ryan
------------------------------
Date: Wed, 08 Jul 1998 13:04:09 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: Capturing Output of Individual SQL Queries
Message-Id: <comdog-ya02408000R0807981304090001@news.panix.com>
Keywords: from just another new york perl hacker
In article <35A3A2FC.27A1CDF0@uswest.com>, rxruck2@uswest.com posted:
>Is there a way to catch the output coming back from Oracle and put it in
>a variable? If so, I could examine the variable as soon as each
>transaction is passed to Oracle and take whatever action I need to.
see the perlipc man page, although you might want to go ahead
and start having fun with DBI.
good luck :)
--
brian d foy <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
Perl Mongers Travel Deals! <URL:http://www.pm.org/travel.html>
------------------------------
Date: Wed, 08 Jul 1998 11:25:23 -0500
From: Mark Evan Jones <xmarkjones@mindless.com>
Subject: Comparing arbitrary dates
Message-Id: <35A39D73.9AD430F1@mindless.com>
I am looking to find code that can both compare two dates and tell me
the difference in days as well as return a date when a number of days
are added to an initial one. I have located a few modules that do what I
want (most notably Steffen Beyer's Date::Calc), but I do not currently
have install access on these machines, and I was wondering if there were
equivilent modules/scripts included with the standard distribution of
perl 5.00404? I can't seem to find any summary information on all these
.pl and .pm files in the libraries do. Can someone point me to such a
list, or point out a script that can do what I need that doesn't require
access to the lib dirs?
------------------------------
Date: Tue, 07 Jul 1998 20:28:32 +0200
From: Stephan Barth <chewie@nuernberg.netsurf.de>
Subject: Determination of end of record?
Message-Id: <35A268D0.307B20E5@nuernberg.netsurf.de>
Hi all of you,
I'm using perl for nearly one year, but I'd still call me a beginner.
I want to convert some files from an old DOS-Compiler for the RPG
programming language. The files are all ascii but they all contain
the data in ONE!! record (only one record length each!!). There
are no end of record marks! No CR/LF or anything.
So what is the best way to cut this record into the REAL number
of records? I tried different things but I often get 'out of
record' warning messages (of course).
In addition to that one file has 14000 records in this one record
and I don't want to fill up my memory with all of them!
--
Bye,
Stephan
*********************************************************
* Stephan Barth, Ahornstr. 1, 90765 Fuerth, Germany *
* chewie@nuernberg.netsurf.de *
* http://www.nuernberg.netsurf.de/User/stebarth *
*********************************************************
"They say I lost my brain... but I gave it away"
Suicidal Tendencies 'Breakdown'
------------------------------
Date: Wed, 8 Jul 1998 12:47:38 +0100
From: Russell Schulz <Russell_Schulz@locutus.ofB.ORG>
Subject: Re: Docs for a2p/walk.c?
Message-Id: <19980708.124738.9e1.rnr.w164w@locutus.ofB.ORG>
pjfarley@banet.net (Peter J. Farley III) writes:
> OK, I'm reading the source for it assiduously, and some things are
> clear, and some other things are not. As for why I'm doing it, well
> I'm trying to bring a2p up to gawk 3.0.3 level, fixing the known bugs
> in the process.
are the two in the awk FAQ really the only known ones? cool!
> It would really be a great help, though, if there was *any* sort of
> commentary at all besides the source.
I've included c.l.awk in case others there know (I don't).
--
Russell_Schulz@locutus.ofB.ORG Shad 86c
------------------------------
Date: Wed, 08 Jul 1998 10:55:02 -0500
From: Dan Baker <dtbaker_@flash.net>
Subject: explaining the whys of referencing... WAS Re: on the fly subs with special tag markers
Message-Id: <35A39656.7642@flash.net>
Larry Rosler wrote:
> > TC> print template("/home/httpd/templates/simple.template", \%fields);
> > TC>
> > TC> sub template {
> > TC> my ($filename, $fillings) = @_;
---
> The second argument is a *reference* to a hash; a reference is a scalar.
> Note how it is used to access the hash: $fillings->{key} which you
> might find easier at first to understand as ${$fillings}{key} (where
> the braces around $fillings are included only for clarity).
---------
eep, I was afraid it would be something like that! references are a
topic I am still having a lot of trouble with. I think my brain is stuck
in old fashioned pass-the-value... can you recommend any specific book
that does a good job of explaining references to beginners? I have read
the syntax of references a couple of times, but have trouble really
*grokking* the concept because I don't see why you would choose to use
them... what they do better than other constructs? There are obviously
reasons they are implemented, and I haven't been able to really get to
that level....
thanx,
Dan
------------------------------
Date: Wed, 8 Jul 1998 10:37:28 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: explaining the whys of referencing... WAS Re: on the fly subs with special tag markers
Message-Id: <MPG.100d4e2f1fbc74ac9896f3@nntp.hpl.hp.com>
In article <35A39656.7642@flash.net> on Wed, 08 Jul 1998 10:55:02 -0500,
Dan Baker <dtbaker_@flash.net> says...
...
> eep, I was afraid it would be something like that! references are a
> topic I am still having a lot of trouble with. I think my brain is stuck
> in old fashioned pass-the-value... can you recommend any specific book
> that does a good job of explaining references to beginners? I have read
> the syntax of references a couple of times, but have trouble really
> *grokking* the concept because I don't see why you would choose to use
> them... what they do better than other constructs? There are obviously
> reasons they are implemented, and I haven't been able to really get to
> that level....
'References are absolutely essential for creating complex data
structures' (Advanced Perl Programming, p. 8) -- structures whose members
are allocated dynamically (during program execution), hence whose names
are not known (during program compilation).
References on references: perldoc perlref and Chapter 1 of 'Advanced
Perl Programming'
References on data structures: perldoc perldsc and Chapter 2 of
'Advanced Perl Programming'
Understanding and using references may be the boundary between novice
and intermediate in Perl programming, like switching from snowplow turns
to stem turns in skiing. Welcome to Middle School. :-)
--
Larry Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Wed, 08 Jul 1998 10:45:04 -0500
From: Dan Baker <dtbaker_@flash.net>
Subject: good research methods WAS Re: on the fly subs with special tag markers
Message-Id: <35A39400.2E12@flash.net>
brian d foy wrote:
> actually, i'll breifly outline what i do when learning some new perl
> thingy. i usually don't go past 4a). it might seem cumbersome
> at first, but the more you practice, the better you get :)
-------------
thanx for outlining your methods.... it actually does help a lot! I am
still having trouble finding things in perldoc, and many topics aren't
covered too well in any one book. The other problem I keep running into
is that most of the books are slightly outdated by the time they are
printed and new features are available that are not in the books, or are
slightly different from one book to the next so I can't tell which is
*best*.
I must say that I thought I was a patient man, but your persistance in
research puts me to shame.... I don't think I often have the will to
spend hours on an issue when I KNOW that there are a half-dozen people
in the newsgroup who can explain an issue in 30 seconds. I don't mind
reading on my own, I EXPECT to and it really is the best way to learn,
but about a 1/2 hour on any given problem is all I can stand at one
time.
I am finding that the more I go thru the perl books and docs, the better
I can do in that 1/2 hour... but I really value the personal interaction
with the group, and enjoy the "discussions" for their own sake as well
as educational value.... after all, I'm working from home, and don't get
to talk to many people around the water cooler! I hope that if people
want to help out, they'll post a reply, and if they think it's a stupid
question, they'll just ignore it rather than post a flame.
I'll try not to ask too many really obtuse questions before doing *some*
research... Thank you for your outline of good research practice; I'll
work on making my research time more effective. ;)
Dan
------------------------------
Date: Wed, 08 Jul 1998 11:44:19 -0600
From: Jack Xie <jackx@cs.itc.hp.com>
Subject: I have a question.
Message-Id: <35A3AFF3.5F13@cs.itc.hp.com>
Hi:
I was reading Teach yourself Perl5 for 21 days. I stamble across this
code:
$string =~ s/\d{2} ([\W]) \d{2} \1 \d{2}/$1-$2-$3/x;
The book says that it converts a day-month-year string to the dd-mm-yy
format. I don't understand how this code works, can anyone explain it to
me?
Thank you.
Jack Xie
------------------------------
Date: Wed, 08 Jul 1998 12:10:06 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: Indexing servers
Message-Id: <comdog-ya02408000R0807981210060001@news.panix.com>
Keywords: from just another new york perl hacker
In article <6o04mg$34q$1@taliesin.netcom.net.uk>, "Clinton Gormley" <clint@netcomuk.co.ukXX> posted:
>thank you brian for adding exactly nothing to the conversation except
>sarcasm
i was not being sarcastic. when someone's trying to fleece you,
someone needs to step in and call a spade a "spade". don't be
fooled because you saw buzzwords in a person's post.
>jim added to my limited knowledge and i appreciate that. if you could share
>some of this infinite wisdom then you would fulfill the purpose of this
>newsgroup... as opposed to now, when you just sound a bit sad
there's nothing infinite in reading about search engines in resources
easily found through Yahoo. things that SWISH and glimpse usually come
with docs that meticuously explain their operation (not to mention you
get to look at the source).
once you've done that you can spot the bullshit too.
--
brian d foy <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
Perl Mongers Travel Deals! <URL:http://www.pm.org/travel.html>
------------------------------
Date: 8 Jul 1998 16:01:45 GMT
From: psh@euclid.jpl.nasa.gov (Peter Scott)
Subject: Re: NEVER "call warn() and return undef" (Re: question about objects)
Message-Id: <6o0559$at9@netline.jpl.nasa.gov>
In article <35A37D98.2EFB@min.net>, John Porter <jdporter@min.net> writes:
> Mark-Jason Dominus wrote:
> > Errors should be propogated back
> > up the call stack until they can be handled.
>
> Surely.
> That's why Perl needs a robust exception mechanism -- as everyone will
> agree, I'm sure.
Absolutely. I couldn't wait for it, so I'm using Graham Barr's Error.pm,
even though it's advertised as alpha, experimental; I just can't face
implementing a large operational system without try...catch semantics.
Somebody please put his stuff in the Perl core.
--
This is news. This is your | Peter Scott, NASA/JPL/Caltech
brain on news. Any questions? | (psh@euclid.jpl.nasa.gov)
Disclaimer: These comments are the personal opinions of the author, and
have not been adopted, authorized, ratified, or approved by JPL.
------------------------------
Date: 8 Jul 1998 16:26:48 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: NEVER "call warn() and return undef" (Re: question about objects)
Message-Id: <6o06k8$l4g@news-central.tiac.net>
In article <35A37D98.2EFB@min.net>, John Porter <jdporter@min.net> wrote:
>Mark-Jason Dominus wrote:
>>
>> Errors should be propogated back
>> up the call stack until they can be handled.
>
>Surely.
>That's why Perl needs a robust exception mechanism -- as everyone will
>agree, I'm sure.
No. It depends what you use perl for and what you expect of it...
You may be sure but I don't agree.
Mike
--
mike@stok.co.uk | The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/ | PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/ | 65 F3 3F 1D 27 22 B7 41
stok@colltech.com | Collective Technologies (work)
------------------------------
Date: 8 Jul 1998 16:58:17 GMT
From: Zenin <zenin@bawdycaste.org>
Subject: Re: NEVER "call warn() and return undef" (Re: question about objects)
Message-Id: <899917637.572649@thrush.omix.com>
Gisle Aas <aas@sn.no> wrote:
>snip<
: I'm sure that not everyone will agree that Perl lack a robust
: exception mechanism today. What's un-robust with what we have?
eval {
do_something() or die "I didn't do_somthing";
};
if ($@) {
if ($@ =~ /do_something/) {
handle_do_something_error();
}
else { die };
}
Look a little closer if you missed it.
--
-Zenin
zenin@archive.rhps.org
------------------------------
Date: Wed, 08 Jul 1998 17:26:18 GMT
From: Randal Schwartz <merlyn@stonehenge.com>
Subject: Re: new charter and moderator for comp.lang.perl.announce
Message-Id: <8cogv0fe51.fsf@gadget.cscaper.com>
>>>>> "Nathan" == Nathan Torkington <gnat@frii.com> writes:
Nathan> I just want us all to get along, and (just as important) I
Nathan> want posts to start flowing through comp.lang.perl.announce
Nathan> again.
You perhaps imply that posts have "stopped" flowing. They haven't.
I've been doing my job all along. I've just been enforcing the
previously approved charter a little more rigidly in the past six
months.
--
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me
------------------------------
Date: 8 Jul 1998 10:54:37 -0500
From: tye@fohnix.metronet.com (Tye McQueen)
Subject: Re: Oh man, DO I love Perl ! (References to things that go out of scope)
Message-Id: <6o04nt$kgf@fohnix.metronet.com>
Just to stress some of this more, mostly for those watching from home...
) John Chambers <jc@eddie.mit.edu>, wrote:
) > Also, OO is much more difficult to learn and debug. The perl debugger
) > seems to have problems with it:
Not at all.
) > "my" variables always come up null,
Wrong. The "X" and "V" commands of the debugger use the symbol
table and "my" variables aren't in the symbol table. But
that doesn't stop you from using the "x" and "p" commands or
just throwning in more complicated perl code to test things.
I too was used to using "X" and "V" and was confused when they
didn't work on "my" variables so I can sympathize.
) > references display as hex values, and so on.
Only if you do C<printf "%x", 0+$ref>. ;> There are many options
for displaying references. One of the most fun is the "x" command.
One of my wishes for the debugger's "x" command is to be able to
"x2 $ref" so that it only goes 2 levels deep. I'll have to work
up a patch for that some day.
) > You are pretty much reduced
) > to the old "add another print" to find out what's gone wrong.
No you aren't and even if you were you could still do that better
by using the debugger. You can even write little subroutines to
dump just the interesting bits of complicated things and call
those at-will from the debugger. But most of the time just the
built-in debugger commands are all you need.
) > So it's easy to write something first in a non-OO fashion, so
) > you can use the debugger.
That is just funny.
ilya@math.ohio-state.edu (Ilya Zakharevich) writes:
) Not for people who took a minute and did what the debugger suggests to
) do:
) h h
)
) Ilya
I guess we need a stronger version of the welcome message? :)
--
Tye McQueen Nothing is obvious unless you are overlooking something
http://www.metronet.com/~tye/ (scripts, links, nothing fancy)
------------------------------
Date: 8 Jul 1998 17:17:56 GMT
From: Zenin <zenin@bawdycaste.org>
Subject: Re: Oh man, DO I love Perl ! (References to things that go out of scope)
Message-Id: <899918815.843192@thrush.omix.com>
Gisle Aas <aas@sn.no> wrote:
: The '_foo' in B and the '_foo' in D is separate. The same 'foo' is
: visible in all classes. The 'bar' in B and the 'bar' in D is
: separate. In E 'foo' from B and 'bar'/'baz' from D is visible; the
: private fields (and 'bar' from B) are not.
: If 'B' at some point introduce a new field called 'baz', then there
: will be no conflict with the use of the field 'baz' in D.
...Ok, I think we're one the same page, but I'm not sure I
understand the logic you've got here for why what is which.
What exactly desides that one field is private vs public?
Is it the leading underscore? Is everything else public/protected,
unless declared with use fields? In which case, the last one
to be declared (in the highest sub package) is the one visible
as public/protected until something else declares it with
fields?
Personally (if I read this correctly), I think I would have
much preferred syntax like:
package B;
use public qw(foo bar);
use private qw(_foo);
Or at least:
use fields::public qw(foo bar);
...etc...
Thus giving the ability to call the fields whatever one likes,
and also allow for a "use protected" if such support is possible.
-Perl, beyond all other languages, typically trys hard to let
the user do what they like the way they like without forcing
conventions, such as leading underscores, globals in leading
caps, constants in all caps, etc. Why force name convetion
here?
Don't get me wrong, I think fields and what it represents is
absolutely great (possibly, one of the best things to happen
to perl since it moved away from 4.x), I just think the
syntax could be a little cleaner.
--
-Zenin
zenin@archive.rhps.org
------------------------------
Date: 8 Jul 1998 17:44:09 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Oh man, DO I love Perl ! (References to things that go out of scope)
Message-Id: <6o0b59$d1n$1@csnews.cs.colorado.edu>
All data should always be private. Totally. Once you start
messing around with an objects internals and you are not that
class, you have violated the abstraction. Don't do that.
--tom
--
This is UNIX; if you can't get the sources, it isn't freeware.
--Peter Salus
------------------------------
Date: 8 Jul 1998 16:40:19 GMT
From: "Walter Harms" <Walter.Harms@Informatik.Uni-Oldenburg.DE>
Subject: Re: perl 5.004.04 on AIX 4.2.1
Message-Id: <6o07dj$grd@news.Informatik.Uni-Oldenburg.DE>
darren@Quint.somtel.com (Darren Henderson) writes:
>I'm having some trouble getting perl 5.004.04 to compile under AIX 4.2.1.
i compiled with gcc 272 with no problems but i had to run the ./Configure
script to get the autoconfig work properly.
the link error is a bit strage but it happens when you link with option
-nobloadmap (or so) check this with gcc -v.
walter
>It's comming down to the following.....
> AutoSplitting perl library
>
> Making DynaLoader (static)
> gcc -L/usr/local/lib -bE:perl.exp -o perl perlmain.o
>lib/auto/DynaLoad
>er/DynaLoader.a libperl.a `cat ext.libs` -lnsl -ldbm -ldl -lld -lm -lc
>-lbsd -l
>PW
>ld: 0706-005 Cannot find or open file: libgcc.a
> ld:open(): No such file or directory
>ld: 0706-005 Cannot find or open file: libgcc.a
> ld:open(): No such file or directory
>gcc: file path prefix `/usr/local/lib/gcc-lib/E:perl.exp/2.8.1/' never
>used
>make: The error code from the last command is 1.
>
>
>Stop.
>This paticular attempt was using gcc 2.8.1. I'm really not sure what to
>make of this. libgcc.a exists and lives in the deafult location. Also note
>the gcc: line toward teh end, the path prefix listed there is incorrect
>(the E:perl.exp should be rs6000-ibm-aix4.2.1.0), the correct value was
>being used up to that point.
>Any one have similar problems or thoughts on the possible problem?
>Thanks,
>Darren
>______________________________________________________________________________
>Darren Henderson
>darren@bmv.state.me.us
--
-----
"Let's just say that on *this* ship--or probably any other--
you don't want to wear a red shirt on landing-party duty."
-----
------------------------------
Date: 8 Jul 1998 16:15:20 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Placeholders in Perl?
Message-Id: <6o05uo$jm7@news-central.tiac.net>
In article <35A3555B.EBCC81E8@analog.com>,
Brian Coffey <brian.coffey@analog.com> wrote:
>the problem:
>
>nmos_ M2( .SUBSTRATE(VSS), .G(I), .D(ZN), .S(VSS));
>pmosob M1( .SUBSTRATE(VSS), .D(ZN), .S(VDD), .BG(VDD), .G(I));
>
>I want to use the above two lines as regular expressions on a file that
>contains
>similar lines but has different strings in the brackets. For example :
>
>nmos_ M2( .SUBSTRATE(VSS), .G(I_DIFF), .D(ZN), .S(VSS));
>pmosob M1( .SUBSTRATE(VSS), .D(ZN), .S(VDD), .BG(VDD), .G(I_DIFF));
>
>should also match the reg. expression. Is there such a thing as a
>template or
>placeholder in Perl? Something like this?
>
>nmos_ M2( .SUBSTRATE(X1), .G(X2), .D(X3), .S(X1));
>pmosob M1( .SUBSTRATE(X1), .D(X3), .S(X4), .BG(X4), .G(X2));
In a regex . can match any character (except \n, usually) and there are
other "special" characters which we need to deal with. Regexes match
character by character so the number of space characters is significant.
One quick way to attack a problem like this might be (using the debugger)
[mike@mike mike]$ perl -de 1
Loading DB routines from perl5db.pl version 1.02
Emacs support available.
Enter h or `h h' for help.
main::(-e:1): 1
DB<1> $template = 'nmos_ M2( .SUBSTRATE(VSS), .G(I), .D(ZN), .S(VSS));'
DB<2> $pattern = quotemeta $template
DB<3> print $pattern
nmos_\ \ M2\(\ \.SUBSTRATE\(VSS\)\,\ \.G\(I\)\,\ \.D\(ZN\)\,\ \.S\(VSS\)\)\;
perl's quotemeta escapes characters which might be special, . and () in
particular are very significant.
Now we want to replace the sequences of just letters in () in the pattern.
Perl has a character class, \w, which contains letters, numbers and _ so I
can look in the pattern for \(<one or more \w characters>\) and replace it
with the regex fragment \(\w+\) - the backslashing may be a little
confusing, but:
DB<4> $pattern =~ s/(\\\()\w+(\\\))/$1\\w+$2/g
DB<5> print $pattern
nmos_\ \ M2\(\ \.SUBSTRATE\(\w+\)\,\ \.G\(\w+\)\,\ \.D\(\w+\)\,\ \.S\(\w+\)\)\;
so now $pattern contains something which should match one of the original
lines:
DB<6> print "matched" if 'nmos_ M2( .SUBSTRATE(VSS), .G(I_DIFF), .D(ZN), .S(VSS));' =~ /^$pattern$/
I matched against ^$pattern$ to anchor both ends of the search.
Please read the perlre documentation as it'll explain why various
characters are special and what they do. This might be a useful point to
get started rather than a complete solution...
Hope this helps,
Mike
--
mike@stok.co.uk | The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/ | PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/ | 65 F3 3F 1D 27 22 B7 41
stok@colltech.com | Collective Technologies (work)
------------------------------
Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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.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 3096
**************************************