[17339] in Perl-Users-Digest
Perl-Users Digest, Issue: 4761 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Oct 30 14:06:20 2000
Date: Mon, 30 Oct 2000 11:05:22 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <972932722-v9-i4761@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Mon, 30 Oct 2000 Volume: 9 Number: 4761
Today's topics:
Re: $whatisthis = %hash (Mark-Jason Dominus)
Re: ActivePerl under Windoze 98 schnurmann@my-deja.com
Alternate solution to (split)[2..-1] problem <ren.maddox@tivoli.com>
Re: Alternate solution to (split)[2..-1] problem <ren.maddox@tivoli.com>
Re: Alternate solution to (split)[2..-1] problem (Daniel Chetlin)
Auth DBI (IP Address) <thomas1280@my-deja.com>
cgi and variables <frank@eentertainment.net>
Re: cgi and variables <bill.kemp@wire2.com>
Re: cgi and variables <jeff@vpservices.com>
Re: CGI.pm + exec = error nobull@mail.com
Re: code counter v1 released :-) <bart.lateur@skynet.be>
Re: code counter v1 released :-) <uri@sysarch.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 30 Oct 2000 16:29:47 GMT
From: mjd@plover.com (Mark-Jason Dominus)
Subject: Re: $whatisthis = %hash
Message-Id: <39fda1fb.cca$217@news.op.net>
In article <hncqvs4ij81evit0dl3bhbj58apelp567a@4ax.com>,
Bart Lateur <bart.lateur@skynet.be> wrote:
>But it does have some use. Most of it is for peeking into the internals,
>for the curious.
I don't find this very compelling. If you want to peek into the
internals, you can use Devel::Peek. I don't know why this one little
internal detail should be exposed at the language level. A more
useful behavior would be if a hash in scalar context always evaluated
to the number of keys in the hash. It would still be useful in a
boolean context without the current special case.
I once proposed in p5p that there should be a pragma to forbid the use
of a hash in a scalar context. Here's the article:
----------------------------------------------------------------
Conversion of a hash to a scalar is rarely useful, except in boolean
context, because the result is an oddity. Would it be a good idea to
have a pragma that forbids this conversion?
use strict 'scalar hashes';
$s = %hash; # compile-time error
$s = scalar(%hash); # OK (explicit scalar())
$d->{k} = %hash; # compile-time error
$d->{k} = \%hash; # OK (no conversion)
if (%hash) { ... } # OK (boolean context)
print $s . %hash; # compile-time error
$n = length(%hash); # compile-time error
{ no strict 'scalar hashes';
$s = %hash; # OK
$d->{k} = %hash; # OK
print $s . %hash; # OK
$n = length(%hash); # OK
}
I don't know how much of this is actually doable (the exemption for
scalar() might be difficult) but perhaps it is worth thinking about.
----------------------------------------------------------------
------------------------------
Date: Mon, 30 Oct 2000 15:23:27 GMT
From: schnurmann@my-deja.com
Subject: Re: ActivePerl under Windoze 98
Message-Id: <8tk3p7$jt3$1@nnrp1.deja.com>
Don't have a directory by that name.
In article <8tj7nj$tue$1@nnrp1.deja.com>,
martin_de_niet@hotmail.com wrote:
> if you have 'x86' sub directory in modules dir rename it to MSWin32-
x86-
> multi-thread (or whatever platform you have installed) this fixed the
> problem on my NT system
>
> Martin
>
> In article <8tcm37$6d1$1@nnrp1.deja.com>,
> schnurmann@my-deja.com wrote:
> > Darwin is a wireless ISP and is ssslllloooowwwwwww. My cable modem
at
> > home is twice as fast.
> >
> > I installed Win 2000 on this machine, still ppm doesn't work
remotely.
> > This did allow for DBI to compile and install though.
> >
> > In article <39F849A2.DD57DA89@mail.uca.edu>,
> > Cameron Dorey <camerond@mail.uca.edu> wrote:
> > > schnurmann@my-deja.com wrote:
> > > >
> > > > My Windoze 98 machine cannot use ppm to install, but another NT
> > machine
> > > > around here, running the same version of ActivePerl can. i
think
> > it is
> > > > related to my being on Darwin, but I am not sure.
> > >
> > > What is Darwin? A firewall or something? If you download the
zipped
> > > module from ActiveState
> (http://www.ActiveState.com/PPMPackages/zips/)
> > > to your hard drive, you can PPM it from there on Win98 machine -
> read
> > > the README. If the module is not available for your version/build,
> as
> > Ed
> > > said, and you have done, download and do it manually. I don't know
> > where
> > > Makefile.pl could be going wrong, I have been lucky enough as yet
to
> > > only need modules available as PPM or Perl-only ones, where I
don't
> > have
> > > to go through all the manual steps.
> > >
> > > Cameron
> > >
> > > --
> > > Cameron Dorey
> > > Associate Professor of Chemistry
> > > University of Central Arkansas
> > > Phone: 501-450-5938
> > > camerond@mail.uca.edu
> > >
> >
> > Sent via Deja.com http://www.deja.com/
> > Before you buy.
> >
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
>
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 30 Oct 2000 10:05:07 -0600
From: Ren Maddox <ren.maddox@tivoli.com>
Subject: Alternate solution to (split)[2..-1] problem
Message-Id: <m38zr6mi18.fsf@dhcp11-177.support.tivoli.com>
A few weeks ago there there was a thread regarding using the
.. operator within an array index to allow it to DWIM when what I mean
is to mix both positive and negative lookups.
I'm not going to go into all of the problems mentioned in that thread,
but one of the final results was that for arrays you could simply say
@array[2..$#array]. The problem, of course, is that this only works
for arrays and not for non-array lists such as the one in the subject.
It occurred to me that a perhaps simple solution would be to provide
some way to index the last element of a list. The obvious solution
presented itself: a bare "#". It would only work within an index and
would also refer to the list being indexed. So the expression desired
in the subject becomes:
print (split)[2..#]
Naturally, this would work for real arrays as well, so the cumbersome
@array[$#array-5, $#array] would become @array[#-5, #] .
The only problem I see with this is the syntactic collision with
comments. Not sure if that's really a problem or not, nor what a good
solution would be.
So, what do you think?
BTW, on a slightly related note, wouldn't it be nice if split had an
OFFSET argument like splice and substr? Then you could do things
like:
$_ = "Here is:some unneeded data:Here is:the data:we need";
@data = split /:/, $_, 3, 2; # assumes offset is the last argument
print "@data\n";
__END__
Which would be the same as (split)[2..5] (which is not what
I really wanted -- (split)[2..#] -- which is really why the OFFSET
should come before the LENGTH just like with splice and substr, but I
don't know how to do that in a compatible way).
--
Ren Maddox
ren@tivoli.com
------------------------------
Date: 30 Oct 2000 10:41:44 -0600
From: Ren Maddox <ren.maddox@tivoli.com>
Subject: Re: Alternate solution to (split)[2..-1] problem
Message-Id: <m3wveql1rr.fsf@dhcp11-177.support.tivoli.com>
Ren Maddox <ren.maddox@tivoli.com> writes:
> Naturally, this would work for real arrays as well, so the cumbersome
> @array[$#array-5, $#array] would become @array[#-5, #] .
Silly me... that was a poor example since it could just be:
@array[-6 .. -1]
A better example is:
@array[5, #-5];
--
Ren Maddox
ren@tivoli.com
------------------------------
Date: 30 Oct 2000 18:36:02 GMT
From: daniel@chetlin.com (Daniel Chetlin)
Subject: Re: Alternate solution to (split)[2..-1] problem
Message-Id: <8tkf2i029ns@news2.newsguy.com>
On 30 Oct 2000 10:05:07 -0600, Ren Maddox <ren.maddox@tivoli.com> wrote:
>It occurred to me that a perhaps simple solution would be to provide
>some way to index the last element of a list. The obvious solution
>presented itself: a bare "#". It would only work within an index and
>would also refer to the list being indexed. So the expression desired
>in the subject becomes:
>
>print (split)[2..#]
Python provides something that works like this; I would not mind seeing
such in Perl:
[~] $ python -c'print "foo:bar:baz:quux".split(":")[2:]'
['baz', 'quux']
(Split in Python doesn't take RExen, but simple strings...)
Ruby does similarly:
[~] $ ruby -e'p "foo:bar:baz:quux".split(/:/)[2..-1]'
["baz", "quux"]
I don't much like the `#' that you're proposing, but I do think the
functionality would be nice.
-dlc
------------------------------
Date: Mon, 30 Oct 2000 14:30:03 GMT
From: Tom Tom <thomas1280@my-deja.com>
Subject: Auth DBI (IP Address)
Message-Id: <8tk0l1$h3v$1@nnrp1.deja.com>
Hi Group,
I'm hosting a site using Apache, Perl and mySQL.
I want to log all access to the restricted areas of the site
by username, IP and time.
I have a piece of code, bit like this:
sub handler
{
my $r = shift;
my( $result, $sent_pwd ) = $r->get_basic_auth_pw;
[...]
my $username = $r->connection->user;
$my db_connecion = &mySQL::Connect( $r->server->host_name );
$db_connection->LogUserAccess( $username, $REQUESTERS_IP_ADDR,
$success );
[...and so forth...]
}
How do I get the IP address? The URI appears to return name only
(and reverse DNS is not on)? Am I, as usualy, missing something
really obvious?
Any help?
--
Cheers,
Tom
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Mon, 30 Oct 2000 10:05:23 -0600
From: "Frank Smith" <frank@eentertainment.net>
Subject: cgi and variables
Message-Id: <8tk65i$lr1$1@news3.kcnet.com>
Quick question.
Can you use variables in the names of parameters when using cgi?
For example:
$query->param('$variable');
or
$query->param('field_$variable');
Thanks in advance for your help.
James
------------------------------
Date: Mon, 30 Oct 2000 17:04:27 -0000
From: "W Kemp" <bill.kemp@wire2.com>
Subject: Re: cgi and variables
Message-Id: <972925795.12253.0.nnrp-03.c3ad6974@news.demon.co.uk>
>Can you use variables in the names of parameters when using cgi?
>$query->param('$variable');
Not if you use single quotes.
------------------------------
Date: Mon, 30 Oct 2000 09:09:10 -0800
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: cgi and variables
Message-Id: <39FDAB36.F35FFE9C@vpservices.com>
Frank Smith wrote:
>
> Quick question.
>
> Can you use variables in the names of parameters when using cgi?
Yes, you can use any expression that evaluates to a string.
> For example:
>
> $query->param('$variable');
>
> or
>
> $query->param('field_$variable');
No, not like that. Variables are not interpolated inside single
quotation marks, you need to omit the quotation marks if it is just a
variable or use double quotation marks when it is a variable and a
string:
$query->param($variable);
$query->param("field_$variable");
or $query->param( 'field_' . $variable );
--
Jeff
------------------------------
Date: 30 Oct 2000 17:53:24 +0000
From: nobull@mail.com
Subject: Re: CGI.pm + exec = error
Message-Id: <u9wveqnrl7.fsf@wcl-l.bham.ac.uk>
andre_sanchez@my-deja.com writes:
> > Wishing to exec() one CGI script from another is a silly thing to
> > wish.
>
> At the risk of continuing in my sillyness, but with the hope of
> reducing it, I have adjusted my objective; With mixed results.
Can you perhaps tell us the revised objective? You appear to be
having problems isolating your "means" from your "ends". You have
show us your revised means, we still have no idea about your ends.
> I have a CGI script (tester.pl) that I wish to have display the output
> of another script (testee.pl). Below are two versions of the testee.pl
> script; version 1 returns the expected results, while version 2
> returns: Malformed multipart POST.
In version 1 you have followed my advice of modifying testee.pl so
that is it not a attempting to interface via the CGI interface. This
was one of two alternatives I suggested to you.
> Given that I prefer to use the technique outlined in version 2, your
> ideas on how to eliminate the misbehavior are greatly appreciated.
So you want testee.pl to interface using CGI. Is that actually part
of you "objective"? That is most easily possible using the other
alternative I offered you: LWP. If my ideas are greatly appreciated
why have you not tried implementing them?
If testee.pl using the CGI interface is not part of the objective but
testee.pl using CGI.pm _is_ part of the objective then I have a third
idea. Look at he description of the new() method in the manuals for
CGI.pm. This will explain how you can create a CGI object in ways
other than using the CGI interface.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Mon, 30 Oct 2000 14:25:17 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: code counter v1 released :-)
Message-Id: <lt0rvsk40egi8p5lu3d3ffuqro0t3h3lq4@4ax.com>
Tarael200 wrote:
>I wasn't entirely sure if this was the right newsgroup to post little releases
>of perl code to, but here's my perl code counter :)
I think it is. For example, Tom Cristiansen already has posted pretty
large scripts here.
>It skips comments and whitespace and concentrates on that which is important in
>a source file - the code ! You run it in the form of "perl coc <code file>" or
>"coc <code file>" if your on a unix machine and you chmod +x it...
It indeed is a simple version. What about here docs? What about mixes of
code and comments? What about some people's habit of writing:
if(something)
{
blah
}
The line with the opening brace will be treated as code (so will the
line of "}", but that happens to everyone.): so people with the above
habit will have more code lines than people who don't, for the same
code!
Parsing perl is not trivial. So I don't even think that patching your
code in a simple manner in order to get all this right, can even be
done.
--
Bart.
------------------------------
Date: Mon, 30 Oct 2000 18:12:11 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: code counter v1 released :-)
Message-Id: <x7aebmjj0k.fsf@home.sysarch.com>
>>>>> "C" == CDM <cdemaeyer1@mmm.com> writes:
C> comp.lang.perl.announce is the group to use
and you had to quote the entire program just to prepend that one line of
comment?
usenet netiquette does not endorse jeopardy quoting and aol-ish one
line <me too> followups.
C> Opinions expressed herein are my own and may not represent those of
C> my employer.
or your waste of net bandwidth and disk space. if you abused those
resources at work like you did here, you wouldn't last long.
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page ----------- http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net ---------- http://www.northernlight.com
------------------------------
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 4761
**************************************