[31946] in Perl-Users-Digest
Perl-Users Digest, Issue: 3209 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Nov 14 06:09:30 2010
Date: Sun, 14 Nov 2010 03:09:12 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Sun, 14 Nov 2010 Volume: 11 Number: 3209
Today's topics:
Re: if ('A:B:C' =~ /:(.*?)$/) then why the heck is $1 ' <xhoster@gmail.com>
Re: if ('A:B:C' =~ /:(.*?)$/) then why the heck is $1 ' <hjp-usenet2@hjp.at>
Re: Indicating dependencies in multi-file xs compiles <nospam-abuse@ilyaz.org>
reading file containg passwords <john1949@yahoo.com>
Re: reading file containg passwords <vilain@NOspamcop.net>
Re: reading file containg passwords <cartercc@gmail.com>
Re: reading file containg passwords <m@rtij.nl.invlalid>
What is the array that contains all of $1, $2, $3 ...? jidanni@jidanni.org
Re: What is the array that contains all of $1, $2, $3 . <skye.shaw@gmail.com>
Re: What is the array that contains all of $1, $2, $3 . <skye.shaw@gmail.com>
Re: What is the array that contains all of $1, $2, $3 . <uri@StemSystems.com>
Re: What is the array that contains all of $1, $2, $3 . <uri@StemSystems.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 12 Nov 2010 19:37:11 -0800
From: Xho Jingleheimerschmidt <xhoster@gmail.com>
Subject: Re: if ('A:B:C' =~ /:(.*?)$/) then why the heck is $1 'B:C' and not just 'C'
Message-Id: <4cdf4ab8$0$14784$ed362ca5@nr5-q3a.newsreader.com>
OwlHoot wrote:
> To repeat the title, in case it is munged by Google Groups:
>
> if ('A:B:C' =~ /:(.*?)$/) then why the heck is $1 'B:C' and not just
> 'C'
>
> I've been developing with perl for years; but even simple things in it
> still
> sometimes throw up surprises.
>
> The regexp /:(.*?)$/ is anchored on the right by $, then
There is no "then". Being anchored at the end does not change the order
of evaluation (or at least, does not do so in a way that effects the
outcome--the optimized engine can do things in whatever order it wants,
as long as behaves as if it were done left to right.)
> comes a non-
> greedy
Really it is not non-greedy. It is still greedy, it just greedy for
less, rather than greedy for more. It it is still greedy because it
satisfies itself, without looking around at the "wants" of others.
> match which, AIUI, is the "shortest string it can get away with",
> preceded
> by a colon.
The colon is also greedy. It is greedy to match as far left as it can
get away with. And because it comes before the .*? does, its greed wins.
Xho
------------------------------
Date: Sun, 14 Nov 2010 11:49:28 +0100
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: if ('A:B:C' =~ /:(.*?)$/) then why the heck is $1 'B:C' and not just 'C'
Message-Id: <slrnidvflo.buf.hjp-usenet2@hrunkner.hjp.at>
On 2010-11-13 03:37, Xho Jingleheimerschmidt <xhoster@gmail.com> wrote:
> Really it is not non-greedy. It is still greedy, it just greedy for
> less, rather than greedy for more. It it is still greedy because it
> satisfies itself, without looking around at the "wants" of others.
> The colon is also greedy. It is greedy to match as far left as it can
> get away with. And because it comes before the .*? does, its greed wins.
Please. "Greedy" in the context of regular expressions is a technical
term with a precisely defined meaning. You are not helping by inventing
a different meaning for the word based on its meaning in common English.
hp
------------------------------
Date: Sat, 13 Nov 2010 00:23:48 +0000 (UTC)
From: Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: Indicating dependencies in multi-file xs compiles
Message-Id: <slrnidrmkk.vl7.nospam-abuse@powdermilk.math.berkeley.edu>
On 2010-11-12, John Stanley <stanley@peak.org> wrote:
> gotten too large for this mortal to understand, so I split most of the
> functions off into their own files and now INCLUDE them in the main .xs
> file (Engine.xs). This has created two potentially related problems.
>
> 1. How do I tell "the system" that Engine.xs is dependent upon, e.g, a.xs,
> b.xs, and c.xs, so that changes to a.xs will cause 'make' to recompile
> Engine.xs?
>
> 2. To work around #1, I've been touching Engine.xs before I 'make'. Even
> when I do that, Engine.c often doesn't get rebuilt from the xs and the
> compiler continues to report errors that I've corrected in the xs
> source.
Check your make (or clocks if you use multiple machines). [I assume
that you checked the generated Makefile for this dependency?]
> I've read through the MakeMaker, MakeMaker::Tutorial and MakeMaker::FAQ
> docs on perl.org, but I don't see any option to put in the Makefile.PL to
> record this dependency.
One can modify ANY MakeMaker subroutine which emits a chunk of
Makefile to put the dependency there.
I see that I use MY::Postamble in Math::Pari...
> I did a "perl Makefile.PL" and I see all the
> source files listed in the generated Makefile, but they aren't listed as
> dependencies.
Do not you have .xs.c: line?
But for me, the simplest solution is to compile .xs separately, and
use the (documented?)
OBJECT => '$(O_FILES)', # Several .xs files
as I do in SOM.
Ilya
------------------------------
Date: Sat, 13 Nov 2010 16:07:12 -0000
From: "John" <john1949@yahoo.com>
Subject: reading file containg passwords
Message-Id: <ibmd3d$dj$1@news.albasani.net>
Hi
I have a web perl script. In the script I need to access a SQL database. I
have the password as a string in the script. Clearly anyone downloading the
script can see it. I tried putting the password in a file (chmod 0400 -
read by owner only). Unforunately, being on the web I need to set it to
0444 - read by everyone - which defeats the aim. I appreciate it is more of
a linux problem that Perl but what do other do when they have passwords they
need to send to a SQL database etc. when running a Perl script on the web.
Regards
John
------------------------------
Date: Sat, 13 Nov 2010 09:00:04 -0800
From: Michael Vilain <vilain@NOspamcop.net>
Subject: Re: reading file containg passwords
Message-Id: <vilain-EE1A1E.09000413112010@news.individual.net>
In article <ibmd3d$dj$1@news.albasani.net>, "John" <john1949@yahoo.com>
wrote:
> Hi
>
> I have a web perl script. In the script I need to access a SQL database. I
> have the password as a string in the script. Clearly anyone downloading the
> script can see it. I tried putting the password in a file (chmod 0400 -
> read by owner only). Unforunately, being on the web I need to set it to
> 0444 - read by everyone - which defeats the aim. I appreciate it is more of
> a linux problem that Perl but what do other do when they have passwords they
> need to send to a SQL database etc. when running a Perl script on the web.
>
> Regards
> John
I think the usual way around this is to place the file outside the
DOCROOT directory, protect it from being read by Apache's process (e.g.
it's owned by the account that downloaded the file and only that UID can
read it) and run the CGI script through cgiwrap:
http://cgiwrap.sourceforge.net/
--
DeeDee, don't press that button! DeeDee! NO! Dee...
[I filter all Goggle Groups posts, so any reply may be automatically ignored]
------------------------------
Date: Sat, 13 Nov 2010 10:21:24 -0800 (PST)
From: ccc31807 <cartercc@gmail.com>
Subject: Re: reading file containg passwords
Message-Id: <c1c19ace-b031-4df5-9ea9-2f2979292f0d@n24g2000prj.googlegroups.com>
On Nov 13, 11:07=A0am, "John" <john1...@yahoo.com> wrote:
> I have a web perl script. =A0In the script I need to access a SQL databas=
e. =A0I
> have the password as a string in the script. =A0Clearly anyone downloadin=
g the
> script can see it.
Unfortunately, if you script a connection to a database, or anything
else requiring credentials, you have to also script the credentials.
The only alternative is to require entry of the credentials at the
keyboard, which defeats the purpose of scripting.
You need credentials to authenticate the user. There are only two ways
to present the credentials: either type them in at the keyboard, or
save them to some kind of persistent storage. The former is safer, the
latter is more convenient. You can't have safety and convenience in
this situation, you have to choose one or the other.
My solution is to place the credentials in a separate configuration
file, and have the script read the configuration file to initialize.
It doesn't really matter where you put the configuration file -- any
person who has access to the machine, and read privileges for the
file, can read your configuration file. There simply isn't any way
around this.
CC.
------------------------------
Date: Sun, 14 Nov 2010 00:05:13 +0100
From: Martijn Lievaart <m@rtij.nl.invlalid>
Subject: Re: reading file containg passwords
Message-Id: <96i3r7-ss.ln1@news.rtij.nl>
On Sat, 13 Nov 2010 09:00:04 -0800, Michael Vilain wrote:
> In article <ibmd3d$dj$1@news.albasani.net>, "John" <john1949@yahoo.com>
> wrote:
>
>> Hi
>>
>> I have a web perl script. In the script I need to access a SQL
>> database. I have the password as a string in the script. Clearly
>> anyone downloading the script can see it. I tried putting the password
>> in a file (chmod 0400 - read by owner only). Unforunately, being on
>> the web I need to set it to 0444 - read by everyone - which defeats the
>> aim. I appreciate it is more of a linux problem that Perl but what do
>> other do when they have passwords they need to send to a SQL database
>> etc. when running a Perl script on the web.
>>
>> Regards
>> John
>
> I think the usual way around this is to place the file outside the
> DOCROOT directory, protect it from being read by Apache's process (e.g.
> it's owned by the account that downloaded the file and only that UID can
> read it) and run the CGI script through cgiwrap:
Even without cgiwrap, get it outside the webroot. There are several ways,
but either use-ing a module that does the db connection or reading a
config file are the easiest and most obvious.
HTH,
M4
------------------------------
Date: Sun, 14 Nov 2010 14:53:32 +0800
From: jidanni@jidanni.org
Subject: What is the array that contains all of $1, $2, $3 ...?
Message-Id: <ibo12d$nt9$1@news.datemas.de>
What is the array that contains all of $1, $2, $3 ...?
man perlvar doesn't say which.
I would like to say
print "@zzz";
instead of
print "$1 $2 $3".
------------------------------
Date: Sun, 14 Nov 2010 00:43:35 -0800 (PST)
From: "Skye Shaw!@#$" <skye.shaw@gmail.com>
Subject: Re: What is the array that contains all of $1, $2, $3 ...?
Message-Id: <2118489a-bd77-4bbc-9143-2ecc107162f8@29g2000prb.googlegroups.com>
On Nov 13, 10:53=A0pm, jida...@jidanni.org wrote:
> What is the array that contains all of $1, $2, $3 ...?
I don't think there is one
> I would like to say
> print "@zzz";
> instead of
> print "$1 $2 $3".
my @zzz =3D do {
no strict 'refs';
grep defined $$_, (1..9)
};
print "@zzz";
------------------------------
Date: Sun, 14 Nov 2010 00:59:33 -0800 (PST)
From: "Skye Shaw!@#$" <skye.shaw@gmail.com>
Subject: Re: What is the array that contains all of $1, $2, $3 ...?
Message-Id: <cc93c84d-e58d-4d53-af11-edc6570a156e@35g2000prt.googlegroups.com>
On Nov 14, 12:43=A0am, "Skye Shaw!@#$" <skye.s...@gmail.com> wrote:
> On Nov 13, 10:53=A0pm, jida...@jidanni.org wrote:
>
> > What is the array that contains all of $1, $2, $3 ...?
>
> my @zzz =3D do {
> =A0 no strict 'refs';
> =A0 grep defined $$_, (1..9)
>
> };
oops, the last line should read:
map $$_, grep defined $$_, (1..9)
------------------------------
Date: Sun, 14 Nov 2010 04:56:31 -0500
From: "Uri Guttman" <uri@StemSystems.com>
Subject: Re: What is the array that contains all of $1, $2, $3 ...?
Message-Id: <871v6ogre8.fsf@quad.sysarch.com>
>>>>> "SS" == Skye Shaw!@#$ <skye.shaw@gmail.com> writes:
SS> On Nov 13, 10:53 pm, jida...@jidanni.org wrote:
>> What is the array that contains all of $1, $2, $3 ...?
SS> I don't think there is one
>> I would like to say
>> print "@zzz";
>> instead of
>> print "$1 $2 $3".
SS> my @zzz = do {
SS> no strict 'refs';
SS> grep defined $$_, (1..9)
SS> };
SS> print "@zzz";
that is horrible. symrefs should avoided at all costs.
there are two real solutions.
first you can assign the results of a regex in list context and you will
get all the grabs in that.
secondly there are special arrays @- and @+ which hold the beginning and
ending char offsets of each grab. you can loop over them and use substr
to get all the grabs.
also there can be more than 9 grabs so your code (however horrible) is
still limited. my solutions are not and they are strict clean.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.sysarch.com --
----- Perl Code Review , Architecture, Development, Training, Support ------
--------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------
------------------------------
Date: Sun, 14 Nov 2010 04:57:15 -0500
From: "Uri Guttman" <uri@StemSystems.com>
Subject: Re: What is the array that contains all of $1, $2, $3 ...?
Message-Id: <87wrogfcsk.fsf@quad.sysarch.com>
>>>>> "SS" == Skye Shaw!@#$ <skye.shaw@gmail.com> writes:
SS> On Nov 14, 12:43 am, "Skye Shaw!@#$" <skye.s...@gmail.com> wrote:
>> On Nov 13, 10:53 pm, jida...@jidanni.org wrote:
>>
>> > What is the array that contains all of $1, $2, $3 ...?
>>
>> my @zzz = do {
>> no strict 'refs';
>> grep defined $$_, (1..9)
>>
>> };
SS> oops, the last line should read:
SS> map $$_, grep defined $$_, (1..9)
twice as horrible as it uses symrefs twice. i hope you don't code this
way in production.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.sysarch.com --
----- Perl Code Review , Architecture, Development, Training, Support ------
--------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
Back issues are available via anonymous ftp from
ftp://cil-www.oce.orst.edu/pub/perl/old-digests.
#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 V11 Issue 3209
***************************************