[13082] in Perl-Users-Digest
Perl-Users Digest, Issue: 492 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Aug 12 21:17:19 1999
Date: Thu, 12 Aug 1999 18:10:14 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Thu, 12 Aug 1999 Volume: 9 Number: 492
Today's topics:
ssi passing params with exec <webmgr@agilitysystems.com>
Re: String Matching html with indents (Eric Bohlman)
Sys::Syslog problems (Graham Ashton)
Re: warnings and init (was: reese) (Larry Rosler)
Re: Which group is appropriate? (Michael South)
Re: Which group is appropriate? (Martien Verbruggen)
Why doesn't this Pass by Reference work? (Phil Goetz)
Re: Why doesn't this Pass by Reference work? <uri@sysarch.com>
Re: Why doesn't this Pass by Reference work? (Donovan Rebbechi)
Re: Why use Perl when we've got Python?! <tchrist@mox.perl.com>
Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 12 Aug 1999 19:24:20 -0400
From: Paul Alcock <webmgr@agilitysystems.com>
Subject: ssi passing params with exec
Message-Id: <37B357A4.CEA244EA@agilitysystems.com>
Anyone know a solution to this?
In an shtml document file I have successfully executed a cgi using the
exec command
<!--#exec cgi="/cgi-local/rc_ASI.cgi" -->
That works fine, but if I try to pass any parameters, such as...
<!--#exec cgi="/cgi-local/rc_ASI.cgi?param1+param2" -->
The exec cgi fails with a printable error.
[an error occurred while processing this directive]
Would appreciate your response.
Thanks.
Paul ps if answering directly the get rid of the N the O and the S
before @ in my address.
------------------------------
Date: 13 Aug 1999 00:52:30 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: String Matching html with indents
Message-Id: <7ovq8e$9m2@dfw-ixnews7.ix.netcom.com>
Vox (v0xman@yahoo.com) wrote:
: Thank you so much for your clue it worked. I know that ^ is the beginning
: of a line and $ is the end of a line. I got that from a tutorial but the
: tutorial didn't explain what all the flags do except for 'g' which is global
: changes every occurrence and ' i ' which ignores case but the rest i just
: got out of another free perl program off the net and it worked fine so i
: left them there. At the moment I don't have a perl book so I got to get out
: and buy one to have full working knowledge of perl.
You wouldn't have needed a book to answer the question "what do all those
modifiers at the end of a match or substitution do?"; you'd merely have
needed to look up the m// and s/// operators in the perlop document that
comes free with every installation of Perl.
*Please*, *please*, *PLEASE*, if you're looking at someone else's code and
you don't know what a construct means, look it up in the documentation
instead of blindly copying it into your own code. Doing the latter is
what we call "cargo cult programming" and it usually leads to buggy and
unreliable code which often gets made publicly available and winds up
teaching bad habits to a whole new generation of Perl novices (e.g. Matt's
Script Archive). Doing the former makes you a better programmer; when I
was learning Perl, I'd read code posted here and turn to my trusty Camel
whenever I saw anything I didn't understand. I learned a lot about Perl
that way. Every time you see something you don't understand, you have a
"teachable moment"; don't let one of those pass you by.
------------------------------
Date: 13 Aug 1999 00:32:26 GMT
From: billynospam@mirror.bt.co.uk (Graham Ashton)
Subject: Sys::Syslog problems
Message-Id: <slrn7r6psr.c9k.billynospam@wing.mirror.bt.co.uk>
I've just had my first stab at writing to syslogd with Sys::Syslog.pm,
and (unfortunately) it wasn't as successful as I'd hoped.
Here's my test script (pretty much ripped out of the Camel);
---cut---
#!/usr/bin/perl -w
use strict;
use File::Basename;
use Sys::Syslog;
my $script = basename $0;
openlog($script, 'cons,pid', 'user') or warn "Can't open syslog: $!\n";
syslog('info', 'this is a test') or warn "Can't write to syslog: $!\n";
closelog() or warn "Can't close syslog: $!\n";
---cut---
When I run it, it gives;
shandy% ./syslog_test
Can't open syslog: No such file or directory
Can't close syslog: Bad file descriptor
If I add 'ndelay' to the second parameter of openlog() it reduces the
problem to;
shandy% ./syslog_test
Can't close syslog: Bad file descriptor
In neither case is anything written to my syslog files. syslogd is
definitely running, and I've made sure that syslog.ph exists (I even
re-ran h2ps to make sure). Running it as root makes no difference.
The docs haven't enlightened me further, and reading syslog(3) hasn't
helped.
Any thoughts? I'm desperate to get my warnings sent to syslog instead of
STDERR.
TIA.
P.S. I'm running Perl 5.004_04 on Debian 2.1, and /etc/syslog.conf is
the default supplied with Debian.
--
Graham
P.S. <billynospam@mirror.bt.co.uk> is a fully working address...
------------------------------
Date: Thu, 12 Aug 1999 17:13:52 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: warnings and init (was: reese)
Message-Id: <MPG.121d031dc0135f49989e4b@nntp.hpl.hp.com>
In article <x71zd87srq.fsf_-_@home.sysarch.com> on 12 Aug 1999 14:34:01
-0400, Uri Guttman <uri@sysarch.com> says...
> >>>>> "A" == Abigail <abigail@delanet.com> writes:
...
> perhaps that should say "Coercion of undef to ''"?
> and the paired warning should say:
>
> "Coercion of undef to 0"?
>
> i will post to p5p about changing this.
It makes a lot more sense than the current misleading message, which
talks about uninitialized values when it means undefined values.
> makes more sense to me than the current warning. in fact it is better as
> it covers assigned undef values being coerced.
>
> A> "" is a nice idempotent value for concatination. Do you realize that
> A> forcing people to initialize variables can actually *increase* the
> A> number of mistakes?
>
> they are poor programmers if they do things like the second one below.
>
> A> my $foo;
> A> ...
> A> foreach my $fruit (qw /apple pear banana/) {
> A> $foo .= "$fruit "; # Gives a warning, but is ok.
> A> }
>
> should be my warning text above.
But there is no warning now, as has been observed in this thread.
Dispensation is granted for all the assignment operators and the auto
increment/decrement operators.
...
> A> That is true, but it irks me that Perl isn't consistent in its warnings.
>
> it is consistant. aggregates are empty when created so there is no
> coercion when first used in any context. scalars are undef which needs
> coercion when used in string or numeric contexts. that can be a bug so
> it is a warning. undef values don't get coerced in boolean contexts
> which is used a lot and is fine as undef makes for a useful out of band
> error or not assigned value.
No, it is not consistent for scalars in string or numeric contexts.
$foo = $foo + 1;
draws a warning, but these:
$foo += 1;
$foo++;
do not. Yet they are all semantically identical.
I don't have an answer for this. I would hate to see a warning suddenly
appear for the latter two statements. That would be yet another
argument for those who object to using '-w' in released code. Probably
too much existing code would suffer.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Thu, 12 Aug 1999 20:04:07 -0400
From: msouth@fulcrum.org (Michael South)
Subject: Re: Which group is appropriate?
Message-Id: <msouth-1208992004070001@user-2ivf7d4.dialup.mindspring.com>
In article <379abcd0$0$210@nntp1.ba.best.com>, John Callender
<jbc@shell2.la.best.com> wrote:
>Abigail <abigail@delanet.com> wrote:
>> Kevin Kinnell (kejoki@netdoor.com) wrote on MMCLIV September MCMXCIII in
>> <URL:news:379A7B23.237A5761@netdoor.com>:
>
>> ** Is there a group where Perl novices--who don't have all of
>> ** the faqs memorized and are just exploring how to get things
>> ** done--should be posting so that they may figure things out
>> ** together instead of pestering the experts and exposing them-
>> ** selves to the inevitable ridicule that attends learning how
>> ** to fit into a new culture?
[chop]
>Even his
>original article here, which I thought was a model of appropriateness,
>from the good subject line, to the provision of necessary information,
>to the careful and specific formulation of the question, and even the
>respectful tone it displayed towards the group's experts, got him the
>patented Abigail brush-back, with a hard fastball up under the chin.
Well, in defense of Abigail, the "respectful" quality of the tone is
questionable--original poster referred to "the inevitable ridicule that
attends learning how to fit into a new culture", which is loaded, because
it implies that the experts are commiting the morally questionable act of
ridiculing people who are innocently "learning how to fit into a new
culture". Not only does that (indirectly, perhaps even unintentionally)
attack the experts, but it defends the (to many people) very odious
practice of posting questions on usenet without reading FAQs first.
[chop]
>A group specifically for beginners could help ease some of the cultural
>clashes, I believe. I've heard many of the standard arguments against
>it, but I really think it would be worth a try.
[chop]
I think the most valuable outcome of the creation of
comp.lang.perl.questions or whatever would be that we would finally see if
any of the predictions, dire or glowing, play out...
mike
comp.lang.perl.no.meanies
comp.lang.perl.i.dont.read.faqs
comp.lang.perl.free.consulting
comp.lang.perl.post.before.you.think
comp.lang.perl.i.love.you.you.love.me
comp.lang.perl.its.september.here.too
------------------------------
Date: Fri, 13 Aug 1999 00:21:34 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Which group is appropriate?
Message-Id: <iyJs3.140$lx1.3044@nsw.nnrp.telstra.net>
In article <msouth-1208992004070001@user-2ivf7d4.dialup.mindspring.com>,
msouth@fulcrum.org (Michael South) writes:
> comp.lang.perl.i.love.you.you.love.me
I love you, you love me is totally unrelated to Perl. Please post to
alt.tv.dinosaurs.barney.die.die.die
:)
Martien
--
Martien Verbruggen |
Interactive Media Division | I took an IQ test and the results were
Commercial Dynamics Pty. Ltd. | negative.
NSW, Australia |
------------------------------
Date: 12 Aug 1999 23:08:09 GMT
From: goetz@cse.buffalo.edu (Phil Goetz)
Subject: Why doesn't this Pass by Reference work?
Message-Id: <7ovk4p$rha$1@prometheus.acsu.buffalo.edu>
>:I've gone through my Perl manual without finding a built-in
>:method to ask whether a variable is a member of an array.
Sorry, there is an answer in the FAQ, but before Tom C. pointed it
out to me I tried this code, which I think is the most straightforward
way of going about it to a Perl newbie like me:
#!/util/bin/perl -w
$input = "hi:there:fred:flintstone";
@hello = split(/:/, $input);
if (&string_member("fred", \@hello)) {
print "It's a member!\n";
}
# Returns 1 iff $element is in @array
# String arrays only!
sub string_member {
my $element = $_[0];
my @subcat_array = @$_[1]; # dereference
print @subcat_array;
print "\n";
print "That was the input.\n";
foreach $i(0 .. $#subcat_array) {
print $subcat_array[$i] . "\n";
if ($subcat_array[$i] eq $element) { return (1); }
}
print "It's not a member.\n";
return(0);
}
Why isn't @hello passed to string_member?
This is essentially the question "How do I pass by reference?"
This is also in the FAQ, but the link to it
( See <A HREF="perlsub.html#Pas_by_Reference">Pass by Reference</A>)
is broken.
Phil
------------------------------
Date: 12 Aug 1999 19:43:59 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Why doesn't this Pass by Reference work?
Message-Id: <x7g11o5zuo.fsf@home.sysarch.com>
>>>>> "PG" == Phil Goetz <goetz@cse.buffalo.edu> writes:
>> :I've gone through my Perl manual without finding a built-in
>> :method to ask whether a variable is a member of an array.
PG> Sorry, there is an answer in the FAQ, but before Tom C. pointed it
PG> out to me I tried this code, which I think is the most
PG> straightforward way of going about it to a Perl newbie like me:
even so it has wins many newbie stype points
PG> #!/util/bin/perl -w
PG> $input = "hi:there:fred:flintstone";
PG> @hello = split(/:/, $input);
PG> if (&string_member("fred", \@hello)) {
no need for & if you are calling a sub with ().
PG> print "It's a member!\n";
PG> }
PG> # Returns 1 iff $element is in @array
PG> # String arrays only!
PG> sub string_member {
PG> my $element = $_[0];
PG> my @subcat_array = @$_[1]; # dereference
@{$_[1]}
here is your bug. the @ binds tightly to $_. you need to use {} around
the ref. i generally use them in most case even when not needed to point
out that a deref is going on
PG> print @subcat_array;
PG> print "\n";
PG> print "That was the input.\n";
PG> foreach $i(0 .. $#subcat_array) {
PG> print $subcat_array[$i] . "\n";
PG> if ($subcat_array[$i] eq $element) { return (1); }
why use indexing? why not just loop over the elements themselves? this
is c code not perl.
return 1 if $_ eq $element for @subcat_array ;
PG> }
PG> print "It's not a member.\n";
PG> return(0);
PG> }
uri
--
Uri Guttman ----------------- SYStems ARCHitecture and Software Engineering
uri@sysarch.com --------------------------- Perl, Internet, UNIX Consulting
Have Perl, Will Travel ----------------------------- http://www.sysarch.com
The Best Search Engine on the Net ------------- http://www.northernlight.com
"F**king Windows 98", said the general in South Park before shooting Bill.
------------------------------
Date: 12 Aug 1999 21:04:20 -0400
From: elflord@news.newsguy.com (Donovan Rebbechi)
Subject: Re: Why doesn't this Pass by Reference work?
Message-Id: <slrn7r6roi.npn.elflord@panix3.panix.com>
On 12 Aug 1999 23:08:09 GMT, Phil Goetz wrote:
>>:I've gone through my Perl manual without finding a built-in
>>:method to ask whether a variable is a member of an array.
>
>Sorry, there is an answer in the FAQ, but before Tom C. pointed it
>out to me I tried this code, which I think is the most straightforward
>way of going about it to a Perl newbie like me:
The problem is where you say
subcat_array=@$_[1];
You need to say @{$_[1]};
Meanwhile, some comments:
># Returns 1 iff $element is in @array
># String arrays only!
>sub string_member {
> my $element = $_[0];
my $element=shift;
> my @subcat_array = @$_[1]; # dereference
my $a_ref=shift;
> foreach $i(0 .. $#subcat_array) {
foreach $item ( @subcat_array ) {
or
foreach $teim ( @$a_ref ) {
>Why isn't @hello passed to string_member?
It is.
>This is essentially the question "How do I pass by reference?"
The way you did. You passed it correctly, but dereferenced it
wrongly.
--
Donovan
------------------------------
Date: 12 Aug 1999 18:40:05 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Why use Perl when we've got Python?!
Message-Id: <37b36965@cs.colorado.edu>
[courtesy cc of this posting mailed to cited author]
In comp.lang.perl.misc,
"Michael P. Reilly" <arcege@shore.net> writes:
:Hi Tom, I don't usually pipe up to your comments. You and I have had
:our minor bi-/annual debates over Perl vs. Python for some time. You
:always been fair and concise (surprising considering some of the
:adversity in the field that both Perl and Python get).
Well, that's because I somewhat like Python, or at least, various
aspects of it. It is a bit tedious in comparison to Perl, however.
:I am a little surprised at some of your comments below.
Again, it's because of the question I was responding to. If the question
had instead been the other way around, I would have provided rather
different answers.
--tom
--
"If Dennis Ritchie were the man who developed Modula-2 then C would be
long forgotten." --Tarjei Jensen
------------------------------
Date: 1 Jul 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 1 Jul 99)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
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" from
almanac@ruby.oce.orst.edu. The real FAQ, as it appeared last in the
newsgroup, can be retrieved with the request "send perl-users FAQ" from
almanac@ruby.oce.orst.edu. 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" from
almanac@ruby.oce.orst.edu.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V9 Issue 492
*************************************