[16927] in Perl-Users-Digest
Perl-Users Digest, Issue: 4339 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Sep 15 21:05:23 2000
Date: Fri, 15 Sep 2000 18:05:09 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <969066309-v9-i4339@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Fri, 15 Sep 2000 Volume: 9 Number: 4339
Today's topics:
Re: Alternativer to SDBM? <bmb@ginger.libs.uga.edu>
Re: can i run a cgi script within javascript tag? (Tony L. Svanstrom)
Re: can i run a cgi script within javascript tag? <mikecook@cigarpool.com>
Re: Can't make DBI ()
How can I do this ? pularis@my-deja.com
Re: How can I do this ? (Craig Berry)
Re: How can I do this ? pularis@my-deja.com
Re: How can I do this ? <bwalton@rochester.rr.com>
Re: Mail::Mailer the Only Way? <bwalton@rochester.rr.com>
Re: Password protecting a script <notkmetcalf@notlighthousemarketingnot.com>
Re: Password protecting a script <g.soper@soundhouse.co.uk>
Re: Password protecting a script <g.soper@soundhouse.co.uk>
Perl and Org. Chart dougawells@my-deja.com
Re: Qualifications for new Perl programmer????? <bcaligari@my-deja.com>
Re: Regexp: matching '|' <mayers@bmc.com>
Re: Segmentation Fault <anders@wall.alweb.dk>
Re: Shortest code for Fibonacci? (Gwyn Judd)
Re: Shortest code for Fibonacci? (Gwyn Judd)
Re: Shortest code for Fibonacci? (Mark-Jason Dominus)
Re: strange warning <thoren@southern-division.com>
Re: strange warning <lr@hpl.hp.com>
Re: strange warning (Abigail)
syslog in perl (Dave Sherohman)
Which environment var can I use? bill@bitco.com
Re: Why does * in a string glob? (Abigail)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 15 Sep 2000 20:11:00 -0400
From: Brad Baxter <bmb@ginger.libs.uga.edu>
Subject: Re: Alternativer to SDBM?
Message-Id: <Pine.A41.4.21.0009152010390.9080-100000@ginger.libs.uga.edu>
On Fri, 15 Sep 2000, Paul Leduc wrote:
> I have been using SDBM to hold template data to be used by a cgi script.
> The problem is that there appears to be a limitation of 1K for each
> value in the hash using SDBM.
>
> Is there an alternate DBM I can use, with the same functionality as
> SDBM, that does not have this limit?
use DB_File;
--
Brad
------------------------------
Date: Sat, 16 Sep 2000 01:39:21 +0200
From: tony@svanstrom.com (Tony L. Svanstrom)
Subject: Re: can i run a cgi script within javascript tag?
Message-Id: <1eh12me.1yl209g1reyfb4N%tony@svanstrom.com>
Peter Wastholm <peter@wastholm.com> wrote:
> klidge wrote:
> >
> > But well,it didn't work,
> > myscript.cgi was something like this:
> > #!/bin/perl
> > use CGI;
> > $q = new CGI;
> >
> > print "document.write('<b>Test</b>');"
> > ------------------------------
> > any (more) ideas?
>
> Try outputting an HTTP header as well, and not just the body.
Yup, if you write the right stuff it works just great; I've had one such
solution up and running for over a year (don't remember how long).
/Tony
--
/\___/\ Who would you like to read your messages today? /\___/\
\_@ @_/ Protect your privacy: <http://www.pgpi.com/> \_@ @_/
--oOO-(_)-OOo---------------------------------------------oOO-(_)-OOo--
on the verge of frenzy - i think my mask of sanity is about to slip
---ôôô---ôôô-----------------------------------------------ôôô---ôôô---
\O/ \O/ ©99-00 <http://www.svanstrom.com/?ref=news> \O/ \O/
------------------------------
Date: Fri, 15 Sep 2000 17:49:35 -0700
From: "Michael Cook" <mikecook@cigarpool.com>
Subject: Re: can i run a cgi script within javascript tag?
Message-Id: <zuzw5.812$eS1.379374@news.uswest.net>
I frequently do the reverse - I generate JavaScript with CGI/Perl.
Michael
"klidge" <klidge@mailbox.gr> wrote in message
news:8prduu$cn2$1@ulysses.noc.ntua.gr...
> I would like to ask you if it's possible for a cgi script written in perl
> to run from within a javascript script
> example:
> Html source:
> <script language="javascript">
> --the code i need here---
> </script>
> In order for the "result" after accessing the page would be the same as
the
> htm source was:
> <script language="javascript">
> document.write('this line has been generated from a cgi perl script');
> </script>
>
> thank you in advance
>
>
------------------------------
Date: Fri, 15 Sep 2000 22:15:41 GMT
From: cybrinjn@daystar.gis.net ()
Subject: Re: Can't make DBI
Message-Id: <slrn8s4e20.pq.cybrinjn@daystar.gis.net>
Dunno if it will help, but: Go to CPAN and download the source
code for 5.6.0 and build it. Try again. I had some problems
making modules and it worked for me.
On Fri, 15 Sep 2000 01:52:59 -0700, Gabe <grichards@flashcom.net> wrote:
>I've got a fresh installation of Redhat 6.2 with Perl 5.00503 that the
>Redhat installer installed. When I try to make DBI I get a bunch of errors
>referring to files with an .h extension saying "No such file or directory".
>The readme says if you get errors related to perl's header files then you
>have a bad perl installation. I don't know how I could have a bad
>installation since perl was installed automatically. I tried reinstalling
>the perl RPM, but that didn't resolve the problem. I couldn't find help in
>the DBI list archives. Does anyone know what the problem is and how to fix
>it?
>
>Thanks!
>Gabe
>
>
------------------------------
Date: Fri, 15 Sep 2000 23:04:42 GMT
From: pularis@my-deja.com
Subject: How can I do this ?
Message-Id: <8pu9tt$n3$1@nnrp1.deja.com>
I need to generate date in the following format:- for 9/15/200 I want
9_15_00. How should I do this ?. All help will be greatly appreciated.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Fri, 15 Sep 2000 23:44:18 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: How can I do this ?
Message-Id: <ss5d2ir4h3t53@corp.supernews.com>
pularis@my-deja.com wrote:
: I need to generate date in the following format:- for 9/15/200 I want
: 9_15_00. How should I do this ?. All help will be greatly appreciated.
A lot depends on what your source format is. Are you working from another
string, differently formatted? An array of localtime-ish values? A
time() epoch-seconds value? Each leads to different techniques.
The best general approach to date formatting is POSIX::strftime(), by the
way.
--
| Craig Berry - http://www.cinenet.net/~cberry/
--*-- "Every force evolves a form."
| - Shriekback
------------------------------
Date: Sat, 16 Sep 2000 00:23:20 GMT
From: pularis@my-deja.com
Subject: Re: How can I do this ?
Message-Id: <8pueh8$5sp$1@nnrp1.deja.com>
Thanks Craig, I was trying to create a file using the date as part of
the filename.
In article <ss5d2ir4h3t53@corp.supernews.com>,
cberry@cinenet.net (Craig Berry) wrote:
> pularis@my-deja.com wrote:
> : I need to generate date in the following format:- for 9/15/200 I
want
> : 9_15_00. How should I do this ?. All help will be greatly
appreciated.
>
> A lot depends on what your source format is. Are you working from
another
> string, differently formatted? An array of localtime-ish values? A
> time() epoch-seconds value? Each leads to different techniques.
>
> The best general approach to date formatting is POSIX::strftime(), by
the
> way.
>
> --
> | Craig Berry - http://www.cinenet.net/~cberry/
> --*-- "Every force evolves a form."
> | - Shriekback
>
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Sat, 16 Sep 2000 00:28:26 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: How can I do this ?
Message-Id: <39C2BEC8.23211E79@rochester.rr.com>
pularis@my-deja.com wrote:
>
> I need to generate date in the following format:- for 9/15/200 I want
> 9_15_00. How should I do this ?. All help will be greatly appreciated.
...
One way:
$date="$1_$2_$3" if $date=~m#^([^/]+)/([^/]+)/.*(\d{2})$#;
--
Bob Walton
------------------------------
Date: Sat, 16 Sep 2000 00:39:33 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: Mail::Mailer the Only Way?
Message-Id: <39C2C163.C4D48D34@rochester.rr.com>
rathmore@tierceron.com wrote:
>
> Is Mail::Mailer the only way to send mail on NT without _really_
> knowing your stuff?
No. Net::SMTP works fine, and is clearly documented with examples.
...
--
Bob Walton
------------------------------
Date: 15 Sep 2000 22:14:05 GMT
From: Kevin Metcalf <notkmetcalf@notlighthousemarketingnot.com>
Subject: Re: Password protecting a script
Message-Id: <39C29F99.7DA4DF27@notlighthousemarketingnot.com>
> <> I would like a script to be only used once having entered a password. What
> <> would the best way of achieving this be?
>
> Huh? I don't understand. You said you want to script to be used only once,
> but now it's used several times?
>
> What do you _really_ want?
I believe the word once is used in the following context:
"Once I was young and restless, now I am just restless."
Perhaps a better way to phrase the question is:
"I would like the script to only be used after a a password has been entered."
(In hindsight, should those be single quotes? :)
Anyway, if you were being sarcastic, then concider my response tongue in cheek. I
am, after all, the son of an english professor. (Not that it should have ANYTHING
to do with my spelling! ;)
Kevin
------------------------------
Date: Sat, 16 Sep 2000 00:26:36 +0100
From: Geoff Soper <g.soper@soundhouse.co.uk>
Subject: Re: Password protecting a script
Message-Id: <49fea63afag.soper@soundhouse.co.uk>
In article <8ptilk$90v$1@msunews.cl.msu.edu>, Eric <eric.kort@vai.org>
wrote:
> This is a cgi script being served by Apache? Use .htaccess and
> .htpasswd. See for example http://faq.clever.net/htaccess.htm
Providing the user closes all instances of his web browser (effectively
logging out) after he finishes is this comepletely secure?
--
Geoff Soper
g.soper@soundhouse.co.uk
Take a look at the Soundhouse page http://www.soundhouse.co.uk/
------------------------------
Date: Sat, 16 Sep 2000 01:09:15 +0100
From: Geoff Soper <g.soper@soundhouse.co.uk>
Subject: Re: Password protecting a script
Message-Id: <49feaa22f8g.soper@soundhouse.co.uk>
In article <39C29F99.7DA4DF27@notlighthousemarketingnot.com>,
Kevin Metcalf <notkmetcalf@notlighthousemarketingnot.com> wrote:
> I believe the word once is used in the following context:
> "Once I was young and restless, now I am just restless."
That's the meaning I was after!
> Perhaps a better way to phrase the question is:
> "I would like the script to only be used after a a password has been
> entered."
Undoubtably!
--
Geoff Soper
g.soper@soundhouse.co.uk
Take a look at the Soundhouse page http://www.soundhouse.co.uk/
------------------------------
Date: Fri, 15 Sep 2000 23:13:23 GMT
From: dougawells@my-deja.com
Subject: Perl and Org. Chart
Message-Id: <8puae2$1cm$1@nnrp1.deja.com>
Has anyone ever created an org chart either with PERL or a compatible
3rd party program which could read directly out of a database, maybe
with a PERL front end? Trying to create a complex org chart using HTML
tables is not pleasant, nor does it look too hot.
Any ideas would be appreciated.
Thanks
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Fri, 15 Sep 2000 22:59:25 GMT
From: Brendon Caligari <bcaligari@my-deja.com>
Subject: Re: Qualifications for new Perl programmer?????
Message-Id: <8pu9k2$4f$1@nnrp1.deja.com>
In article <ORsw5.164$W3.171025408@news.frii.net>,
cfedde@u.i.sl3d.com (Chris Fedde) wrote:
> In article <8pt8kn$n5t$1@nnrp1.deja.com>,
> Brendon Caligari <bcaligari@my-deja.com> wrote:
> >In article <Eccw5.17275$a5.244729@news1.rdc1.mb.home.com>,
> > andrew-johnson@home.com wrote:
> >[ snip snip ]
> >> practices with Perl, or that sound practices cannot be taught using
> >> Perl?
> >>
> >
> >if you start teaching a beginner in perl.....would would he,
> >say....know of sorting routines, lists, trees, graphs...
> >
>
> Why is it important to learn this stuff as a begining programmer?
> Surely we do not teach sentance structure to childeren learning to
> talk. Nether do we start first grade math students with Principia
> Mathematica.
do you give a civil engineering student a box of lego blocks?
>
> Make programming interesting and give the student tools to solve a
problem
> that is real to them. Then if they are interested enough they will
start
> finding out about all that other neat stuff like linked lists, graphs
and
> such.
in the short term, yes..the student will believe he is achieving
something....an incentive not to make an effort. I would like to
make a distinction between learning perl (with no programming
experience) and learning programming using perl. One can write a
script in perl given no programming background. But will that
person be in a position to move to, say, C? On the other hand,
one brought up in a more 'rigid' environment and with problem
solving training can adapt himself more flexibly to...say...perl,
python or whatever is required in a relatively short period of time.
Brendon
++++
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Fri, 15 Sep 2000 17:17:57 -0700
From: Mike Ayers <mayers@bmc.com>
Subject: Re: Regexp: matching '|'
Message-Id: <39C2BC35.D16297BE@bmc.com>
Larry Rosler wrote:
>
> In article <39C2679D.269CB@bmc.com> on Fri, 15 Sep 2000 11:17:01 -0700,
> Mike Ayers <mayers@bmc.com> says...
> +
> + Consider the following:
> +
> + ===========8<--------SNIP--------------------
> + DB<17> $tp='abc|def'
> +
> + DB<18> p $tp
> + abc|def
> + DB<19> if ( $tp =~ m|^([^\|]*)[\|]([^\|]*)| ){print('Matched
> + ',$1,",",$2);}else{print('No match');}
> + Matched abc,def
> + DB<20> if ( $tp =~ m|^([^\|]*)\x7c([^\|]*)| ){print('Matched
> + ',$1,",",$2);}else{print('No match');}
> + Matched abc,def
> + DB<21> if ( $tp =~ m|^([^\|]*)\|([^\|]*)| ){print('Matched
> + ',$1,",",$2);}else{print('No match');}
> + Matched abc,
> + DB<22>
> + ===========8<--------SNIP--------------------
> +
> + I am content to use '[\|]' to match the literal bar. However, I
> + would like to understand what the standalone '\|' is attempting (and
> + failing) to match. Would someone kindly enlighten me?
>
> It isn't trying to match anything. It is acting as the regex
> metacharacter '|', signifying alternation. The left part matches, the
> right part doesn't match, so the regex matches but $2 is undefined.
> (Turn warnings on next time!).
I was hand-typing this code into the debugger to test it before typing
it into my source file. If there is a way to send hand-entered code to
the warning checker, I'd appreciate the tip.
> The problem goes away if you use a different character to delimit the
> regex. So I can only presume that the escaped '|' is recognized as not
> terminating the regex, but not further as an escaped literal '|'.
>
> Why are you causing yourself this pain with an inappropriate choice of
> regex delimiters, when there are so many to choose from (including
> matched pairs of brackets)? Note that if '|' isn't the regex delimiter,
> then 'not |' can be written as [^|] with no escape needed.
I was preparing a pattern for use with Net::Telnet's waitfor(), which
accepts a match pattern as an argument. Since I don't know how it
handles the match pattern and need to match literal bars, I assumed the
worst and tested my potential match patterns to work within bar
delimiters. Probably not necessary, but safe.
/|/|ike
------------------------------
Date: Fri, 15 Sep 2000 22:09:05 GMT
From: Anders Lund <anders@wall.alweb.dk>
Subject: Re: Segmentation Fault
Message-Id: <56xw5.2215$Tn3.55309@news010.worldonline.dk>
Bob Jones wrote:
> Ok, I'm having a problem here that I hope you all can help me out with.
> I'm trying to authenticate against an LDAP database using the Mozilla C
> SDK. I have included my program at the bottom for you to check out.
> Whenever I try to use it I'm getting a Segmentation Fault (core dumped)
> error. I have no idea what could be causing this and would appreciate
> any help.
>
> Thanks in advance
> Bob Jones
> Bob.Jones@WKU.EDU
>
> #!/usr/local/bin/perl5
>
>
> use Mozilla::LDAP::Conn;
>
> #
> # Configuration part, change this
> #
> $BASE = "dc=ldap,dc=wku,dc=edu";
> $EMAIL = $ARGV[0];
> $PASS = $ARGV[1];
>
> # Get User Name from E-mail Address
>
> ($USER,$tmp) = split(/@/,$EMAIL,2);
>
> $conn = new Mozilla::LDAP::Conn({ "host" => "localhost",
> "port" => "389"} );
> die "Can't get an LDAP connection" unless $conn;
>
>
> #
> # Try to find the user using the UID, CN and last MAIL attributes.
> #
> $entry = $conn->search($BASE, "SUB", "(uid=$USER)", 0, ("1.1"));
> if (!$entry || $conn->nextEntry()) {
> $entry = $conn->search($BASE, "SUB", "(cn=$USER)", 0, ("1.1"));
> if (!$entry || $conn->nextEntry()) {
> $entry = $conn->search($BASE, "SUB", "(mail=$USER)", 0, ("1.1"));
> $dn = $entry->getDN() if ($entry && ! $conn->nextEntry());
> } else {
> $dn = $entry->getDN();
> }
> } else {
> $dn = $entry->getDN();
> }
>
> #
> # Now let's verify the authentication credentials, by rebinding with the
> # users DN and password. Note that this leaves the connection bound
> # as the user, do another simpleAuth() to rebind as anonymous again.
> #
> $authenticated = 0;
> if (($PASS ne "") && ($dn ne "") && ($conn->simpleAuth($dn, $PASS))) {
> print("It worked.");
> $authenticated = 1;
> }
>
> if ($authenticated == 0) {
> print("It failed.");
> }
use the w switch.
use the debugger.
make a script that tests 1 phase at a time, and add to it when you have
veryfied that is runs.
Like starting out with
#!/usr/bin/perl -w
use strict;
use Mozilla::LDAP::Conn;
print "so far so good\n";
Hmm, you could try $perl -wMMozilla::LDAP::Conn , which would warn you if
the module fails for some reason...
But you get the idear..
-anders
--
[ the word wall - and the trailing dot - in my email address
is my _fire_wall - protecting me from the criminals abusing usenet]
------------------------------
Date: Fri, 15 Sep 2000 23:33:31 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: Shortest code for Fibonacci?
Message-Id: <slrn8s5cla.12r.tjla@thislove.dyndns.org>
I was shocked! How could Ren Maddox <ren.maddox@tivoli.com>
say such a terrible thing:
>tjla@guvfybir.qlaqaf.bet (Gwyn Judd) writes:
>
>> >> perl -le 'print length while ($ / =~ s|(.*)|s ,. *,$ /,ex, $ / . $ &|e)'
>> >
>> > Correct: Apparently not...
>>
>> The curse of the was working, changed but insufficiently tested code
>> strikes again :) How does this grab you?
>>
>> perl -le 'print length while ($" =~ s|(.*)|s c. *c$ "cex, $ ". $ &|e)
>
>Great.
>
>Took me a long time to catch the fact the $& was not referring to what
>I thought it was referring to, but now I still don't see why the
>previous one doesn't work.
(Hint) I think it has something to do with the '.'
--
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
If at first you do succeed, try to hide your astonishment.
------------------------------
Date: Fri, 15 Sep 2000 23:35:11 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: Shortest code for Fibonacci?
Message-Id: <slrn8s5cof.12r.tjla@thislove.dyndns.org>
I was shocked! How could Russ Jones <russ_jones@rac.ray.com>
say such a terrible thing:
>Gwyn Judd wrote:
>>
>> Whoops. Remember kiddies, this is what happens when you make last minute
>> changes to mission critical code just before it goes out the door!
>
>The word "poopyhead" is reverberating through the server room.
hehe
>Quae narravi, nullo modo negabo. - Catullus
quid?
--
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
Now I lay me down to sleep
I pray the double lock will keep;
May no brick through the window break,
And, no one rob me till I awake.
------------------------------
Date: Fri, 15 Sep 2000 23:55:27 GMT
From: mjd@plover.com (Mark-Jason Dominus)
Subject: Re: Shortest code for Fibonacci?
Message-Id: <39c2b6ee.1368$2cd@news.op.net>
In article <39C27866.5D6C4C8B@strobedata.com>,
Jim Cook <jcook@strobedata.com> wrote:
>> How do you raise powers in constant time?
>
>How about exp(log(x)*y) for x**y?
How do you compute log() and exp() in constant time?
------------------------------
Date: Sat, 16 Sep 2000 00:19:52 +0200
From: "Thoren Johne" <thoren@southern-division.com>
Subject: Re: strange warning
Message-Id: <8pu7g1$6uj$12$1@news.t-online.com>
Larry Rosler <lr@hpl.hp.com> wrote in message
news:MPG.142c32ba9ca6261798ad7c@nntp.hpl.hp.com...
> In article <8pu0g9$4dg$12$1@news.t-online.com> on Fri, 15 Sep 2000
> 22:23:53 +0200, Thoren Johne <thoren@southern-division.com> says...
> > Larry Rosler <lr@hpl.hp.com> wrote in message
> > news:MPG.142c1d056c8cfc3298ad7a@nntp.hpl.hp.com...
>
> ...
>
> > > ? print("$line : $_\n"), $_ = 'two'
> > > : ($_ = 'one', redo)
> >
> > a comma at this place? where did i missed that in the docu?
>
> perlop:
>
> Comma Operator
>
> Binary ``,'' is the comma operator. In scalar context it evaluates its
> left argument, throws that value away, then evaluates its right argument
> and returns that value. This is just like C's comma operator.
ok. i do understand and would use the digraph operator '=>' in this
cases for readability.
but if i look at the docu for 'and', i still fail to understand why
my example doesn't work warning-free if i use a constant instead of a
variable. 'and' should evaluate the right expression if the left expression
evaluates true - which is the case. what makes the difference?
it's not logical to me yet.
> > anyway - it only works for me if i keep the brackets around the if case:
> >
> > ? ( print("$line : $_\n"), $_ = 'two' )
> > : ($_ = 'one', redo)
>
> Sigh, yes. I took them out deliberately, but didn't retest it.
>
> This is actually a difference in the Perl expression grammar from the C
> grammar, whose purpose isn't clear to me.
>
> Excerpting from the C grammar:
>
> conditional-expression:
> logical-OR-expression
> logical-OR-expression ? expression : conditional-expression
>
> assignment-expression:
> conditional-expression
> unary-expression assignment-operator assignment-expression
>
> expression:
> assignment-expression
> expression, assignment-expression
>
> So in C, any expression at all can appear between the '?' and the ':'.
> The Perl grammar should be the same, though expressions exist with lower
> precedence yet than the comma-expression called simply 'expression' in
> the above grammar.
>
> Perl accepts an assignment-expression between '?' and ':', but not a
> comma-expression. Probably this has to do with the possibility of the
> comma being part of a list operator:
>
> 1 ? unlink 'bar', 'baz' : 2
>
> But this list-comma operator is disambiguated from the scalar-comma
> operator in every other context. Why not here?
uhm... hmmm... yeah... and why not an 'and'?
sorry if i'm a bit gormless - it's way late here ;)
gruß
thoren
8#X
--
----------------------------------------------------------------------
Thoren Johne - 8#X - thoren@southern-division.com
Southern Division Classic Bikes - www.southern-division.com
------------------------------
Date: Fri, 15 Sep 2000 15:54:26 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: strange warning
Message-Id: <MPG.142c48802dda54f98ad7d@nntp.hpl.hp.com>
In article <8pu7g1$6uj$12$1@news.t-online.com> on Sat, 16 Sep 2000
00:19:52 +0200, Thoren Johne <thoren@southern-division.com> says...
> Larry Rosler <lr@hpl.hp.com> wrote in message
> news:MPG.142c32ba9ca6261798ad7c@nntp.hpl.hp.com...
> > In article <8pu0g9$4dg$12$1@news.t-online.com> on Fri, 15 Sep 2000
> > 22:23:53 +0200, Thoren Johne <thoren@southern-division.com> says...
> > > Larry Rosler <lr@hpl.hp.com> wrote in message
> > > news:MPG.142c1d056c8cfc3298ad7a@nntp.hpl.hp.com...
> >
> > ...
> >
> > > > ? print("$line : $_\n"), $_ = 'two'
> > > > : ($_ = 'one', redo)
> > >
> > > a comma at this place? where did i missed that in the docu?
> >
> > perlop:
> >
> > Comma Operator
> >
> > Binary ``,'' is the comma operator. In scalar context it evaluates its
> > left argument, throws that value away, then evaluates its right argument
> > and returns that value. This is just like C's comma operator.
>
> ok. i do understand and would use the digraph operator '=>' in this
> cases for readability.
I wouldn't. I use the 'fat comma' for autoquoting, or for hash
initialization, or to separate arguments that are really part of a list
operator (sprintf, pack/unpack, ...) from the operands.
> but if i look at the docu for 'and', i still fail to understand why
> my example doesn't work warning-free if i use a constant instead of a
> variable. 'and' should evaluate the right expression if the left expression
> evaluates true - which is the case. what makes the difference?
>
> it's not logical to me yet.
If perl sees an expression like this:
1 and print 'foo';
the compiler says, "The condition for the test is always TRUE, so I can
optimize it away."
If perl sees an expression like this:
$_ = 1 and print 'foo';
the compiler says, "The condition for the test is always TRUE, so I can
optimize it away. But the bozo used an assignment operator '=', whereas
a conditional operator '==' would make a lot more sense. So I'll issue
a warning, in case the bozo is still awake."
If perl sees an expression like this:
$_ = $x and print 'foo';
the compiler says, "The condition for the test is unknown. The bozo
used an assignment operator '=', whereas a conditional operator '=='
would make a lot more sense. But I'll give the bozo the benefit of the
doubt, and not warn."
Not that I think you're a bozo, of course. :-)
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 15 Sep 2000 23:28:59 GMT
From: abigail@foad.org (Abigail)
Subject: Re: strange warning
Message-Id: <slrn8s5c3o.4mc.abigail@alexandra.foad.org>
Larry Rosler (lr@hpl.hp.com) wrote on MMDLXXII September MCMXCIII in
<URL:news:MPG.142c48802dda54f98ad7d@nntp.hpl.hp.com>:
==
== If perl sees an expression like this:
==
== 1 and print 'foo';
==
== the compiler says, "The condition for the test is always TRUE, so I can
== optimize it away."
==
== If perl sees an expression like this:
==
== $_ = 1 and print 'foo';
==
== the compiler says, "The condition for the test is always TRUE, so I can
== optimize it away. But the bozo used an assignment operator '=', whereas
== a conditional operator '==' would make a lot more sense. So I'll issue
== a warning, in case the bozo is still awake."
Except that Perl *doesn't* optimize it away.
$ perl -wle '$_ = 0; $_ = 1 and print "foo"; print'
Found = in conditional, should be == at -e line 1.
foo
1
$
And this:
$ perl -wle '$_ = 1; $_ = 0 and print "foo"; print'
Found = in conditional, should be == at -e line 1.
0
$
Optimizing things away has nothing to do with it.
$ perl -MO=Deparse -wle '$_ = 0; $_ = 1 and print "foo"; print'
Found = in conditional, should be == at -e line 1.
$_ = 0;
print 'foo' if $_ = 1;
print $_;
-e syntax OK
$
Perl gives a warning because using '$var = constant' in boolean context
is likely a bug; after all, the programmer already knows what the outcome
is, so the test is unnecessary.
If you want to avoid the use of a , and yet keep an expression, use do:
do {$_ = 'one'; redo}
Abigail
--
package Just_another_Perl_Hacker; sub print {($_=$_[0])=~ s/_/ /g;
print } sub __PACKAGE__ { &
print ( __PACKAGE__)} &
__PACKAGE__
( )
------------------------------
Date: Fri, 15 Sep 2000 22:49:43 GMT
From: esper@news.visi.com (Dave Sherohman)
Subject: syslog in perl
Message-Id: <slrn8s59s7.25i.esper@pchan.dojo>
Any suggestions as to why this code doesn't produce anything in my logs? The
system in question is running Debian Linux with their latest perl-5.005
package installed.
---
sub create_account {
use Sys::Syslog;
my ($acct_name, $acct_pass);
openlog($appname, 'cons,pid', 'user');
#openlog($appname, 'pid', 'authpriv');
while ($#_ > 0) {
$acct_name = shift;
$acct_pass = shift;
if (defined getpwnam($acct_name)) {
my $new_name = generate_name($acct_name);
print "$acct_name exists. Try $new_name?\r\n";
} else {
my $message = "Would create user $acct_name, password $acct_pass\r\n";
print $message;
syslog('info', $message);
#syslog('notice', $message);
}
}
closelog();
}
---
If I send a batch of three user/password pairs into this sub, the second
appears on an xconsole, but the other two do not. All three appear on
STDOUT.
I also have
---
# Log everything on tty9
*.* /dev/tty9
---
in /etc/syslog.conf, but nothing shows up there either.
syslog.ph exists; it was installed by apt as part of the perl-5.005 package
in /usr/lib/perl5/5.005/i386-linux/ and /usr/lib/perl5/5.005/i386-linux/sys/,
but they don't appear to be the same - the one in sys is much larger (3574
bytes vs. 53) than the other.
I initially tried logging the messages as authpriv/notice (the lines that are
commented out), but switched it to user/info because that's what the examples
on the manpage use and I thought I might have just gotten the facility/
priority strings wrong.
--
"Two words: Windows survives." - Craig Mundie, Microsoft senior strategist
"So does syphillis. Good thing we have penicillin." - Matthew Alton
Geek Code 3.1: GCS d- s+: a- C++ UL++$ P+>+++ L+++>++++ E- W--(++) N+ o+
!K w---$ O M- V? PS+ PE Y+ PGP t 5++ X+ R++ tv b+ DI++++ D G e* h+ r++ y+
------------------------------
Date: Fri, 15 Sep 2000 23:09:44 GMT
From: bill@bitco.com
Subject: Which environment var can I use?
Message-Id: <8pua7a$qn$1@nnrp1.deja.com>
I have two domain names pointing to the same IP address. It doesn't
matter which one I type in from my browser, I will get the same index
page. I would like to set up a perl redirect script that my index page
will call. This redirect needs to find out which domain name was used
to call the script so it can then redirect to the correct page for that
domain name.
Does anybody know which environment var I could use to deturmine which
domain name was used to get to the IP address? If somebody has already
done somthing like this could you tell me how you did it? Thank You
Bill
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 15 Sep 2000 23:11:50 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Why does * in a string glob?
Message-Id: <slrn8s5b3i.4mc.abigail@alexandra.foad.org>
David J Iannucci (dji@myriad.com) wrote on MMDLXXII September MCMXCIII in
<URL:news:39C28B2F.C6586C84@myriad.com>:
`' I've got a weird problem... I've got a case where I'm
`' putting an SQL statement ("select * from tablename where [...]")
`' into a double-quoted Perl string, and Perl is treating the *
`' character as a glob, and replacing it in the string with a list
`' of all the files in my home directory! (I should say: I guess
`' Perl is the culprit -- I certainly can't imagine the database
`' doing this).
`'
`' I can't find any reason why Perl should treat this as
`' a file glob. There are no funny < > characters around,
`' and certainly no reference to glob(). I did a little
`' test like:
`'
`' print "select * from table";
`'
`' But this fails to reproduce the problem. Can anyone think
`' of a reason why this would be happening?
That's not very helpful. Can you produce a short program (less than 10
lines) that reproduces your problem?
If you can't then it's very likely that you have a bug in your program.
Abigail
--
perl -wle'print"Êõóô áîïôèåò Ðåòì Èáãëåò"^"\x80"x24'
# The King departing
# beside a pond. A pair of
# flying larks. A bear.
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V9 Issue 4339
**************************************