[21938] in Perl-Users-Digest
Perl-Users Digest, Issue: 4160 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Nov 22 09:05:40 2002
Date: Fri, 22 Nov 2002 06:05:07 -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 Fri, 22 Nov 2002 Volume: 10 Number: 4160
Today's topics:
ANNOUNCE: Alzabo 0.70 (Dave Rolsky)
Re: BEGIN block and $:: variables <tassilo.parseval@post.rwth-aachen.de>
grep with multiple expressions n9pgm@xnet.com
Re: grep with multiple expressions <fxn@hashref.com>
Re: grep with multiple expressions (Jay Tilton)
Re: help this Newbie in Distress (Jay Tilton)
Re: List of all modules w/ versions (Salve J. Nilsen)
Re: List of all modules w/ versions <slaven.rezic@berlin.de>
Re: Ordering of command line switches <krahnj@acm.org>
Re: semantics of nested backreferences in regular expre <pinyaj@rpi.edu>
Re: shtml and Perl <tjalbout@hotmail.com>
Re: shtml and Perl <flavell@mail.cern.ch>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 21 Nov 2002 13:07:47 -0600 (CST)
From: autarch@urth.org (Dave Rolsky)
Subject: ANNOUNCE: Alzabo 0.70
Message-Id: <3dde2e83$1_4@news.teranews.com>
Alzabo is a program and a module suite, with two core functions. Its first
use is as a data modelling tool. Through either a schema creation
interface or a perl program, you can create a set of schema, table,
column, etc. objects to represent your data model. Alzabo is also capable
of reverse engineering your data model from an existing system.
Its second function is as an RDBMS to object mapping system. Once you have
created a schema, you can use the Alzabo::Runtime::Table and
Alzabo::Runtime::Row classes to access its data. These classes offer a
high level interface to common operations such as SQL SELECT, INSERT,
DELETE, and UPDATE commands.
Please see http://www.alzabo.org/ for more info. Alzabo can be installed
via the CPAN shell or downloaded from SourceForge.
0.70 November 21, 2002
ENHANCEMENTS:
- The exception thrown when you attempt to set a non-nullable column
to NULL is now an Alzabo::Exception::NotNullable exception, instead of
an Alzabo::Exception::Params exception. In the interests of backwards
compatibility, the former is a subclass of the latter.
- Improved debugging options. See the new Alzabo::Debug module for
details.
BUG FIXES:
- Fixed Alzabo::Table->primary_key, which would die when no primary
key existed and it was called in an scalar context. In an array
context, all the columns in the table were returned. Reported by Eric
Prestemon.
- Alzabo::ObjectCache::Sync::RDBMS created a table that it would later
consider incorrect. This made this module unusable.
- Alzabo::ObjectCache::Sync::RDBMS caused weird random errors when
used with MySQL's InnoDB tables.
- In the schema creator, the link to the graph page, and the link _on_
the graph page to the image, were both broken.
- Alzabo was allowing you to rename a column to a name of an existing
column in a table. Similarly, a table could be renamed to the same
name as an existing table. Doing this could trash a schema.
- Alzabo::Runtime::Table->one_row would return undef if no row was
found, which in a list context evaluated to a true value.
- Allow no_cache option when calling Alzabo::Runtime::Schema->join.
- When displaying SQL, the schema creator now makes sure to
HTML-escape it, because it's possible to have HTML in there (in a
default, most likely).
- The "children" method generated by Alzabo::MethodMaker did not allow
you to add additional where clause constraints to the query.
------------------------------
Date: 22 Nov 2002 10:50:10 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@post.rwth-aachen.de>
Subject: Re: BEGIN block and $:: variables
Message-Id: <arl252$fn3$1@nets3.rz.RWTH-Aachen.DE>
Also sprach Dave Cross:
> On Thu, 21 Nov 2002 11:55:00 +0000, Kevin Brownhill wrote:
>> Does the $::pi package variable need to be declared anywhere with my ?
> Er... no. Like I said it's a _package_ variable. Using "my" would create a
> new lexical variable of the same name.
And that only if you left of the package qualifier. Otherwise you'd get
"my" variable $Package::Name can't be in a package at ...
and/or
Can't use global $::pi in "my" at ...
Tassilo
--
$_=q!",}])(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus;})(rekcah{lrePbus;})(lreP{rehtonabus;})(rehtona{tsuJbus!;
$_=reverse;s/sub/(reverse"bus").chr(32)/xge;tr~\n~~d;eval;
------------------------------
Date: Fri, 22 Nov 2002 09:32:16 +0000 (UTC)
From: n9pgm@xnet.com
Subject: grep with multiple expressions
Message-Id: <arktj0$m77$1@flood.xnet.com>
Hi,
I don't know if grep is the right function for what I need to do. Is the
following possible?
I'm trying to use grep where there are multiple search arguments, and I
want to find the records in a flat file that contain any of the arguments.
If there are a fixed number of arguments, and only a few of them, then I
can do:
@hits = grep (/$arg1/ || /$arg2/ || /$arg3/, <DAT>);
But the number of arguments is different from one execution of the script
to the next, and there may be several arguments. So I'm looking for
something like:
@hits = grep (@args, <DAT>);
Is there some way to do this?
Thanks,
Dan
------------------------------
Date: Fri, 22 Nov 2002 11:22:28 +0000 (UTC)
From: Francesc Xavier Noria <fxn@hashref.com>
Subject: Re: grep with multiple expressions
Message-Id: <arl41j$jdc$1@news.ya.com>
In article <arktj0$m77$1@flood.xnet.com>, n9pgm@xnet.com wrote:
: I'm trying to use grep where there are multiple search arguments, and I
: want to find the records in a flat file that contain any of the arguments.
:
: If there are a fixed number of arguments, and only a few of them, then I
: can do:
:
: @hits = grep (/$arg1/ || /$arg2/ || /$arg3/, <DAT>);
:
: But the number of arguments is different from one execution of the script
: to the next, and there may be several arguments. So I'm looking for
: something like:
:
: @hits = grep (@args, <DAT>);
:
: Is there some way to do this?
A possible solution would be to construct the regexp dinamically:
my $regexp = join '|', @args;
@hits = grep /$regexp/, <DAT>;
We assume there that @args contains regexps itself, if you want to match
against strings instead then they would need to be quoted:
my $regexp = join '|', map "\Q$_\E", @args
-- fxn
------------------------------
Date: Fri, 22 Nov 2002 12:48:44 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: grep with multiple expressions
Message-Id: <3dde2413.84539197@news.erols.com>
n9pgm@xnet.com wrote:
: I don't know if grep is the right function for what I need to do.
Filtering elements from one list into another?
grep() is exactly the right tool.
: I'm trying to use grep where there are multiple search arguments, and I
: want to find the records in a flat file that contain any of the arguments.
:
: If there are a fixed number of arguments, and only a few of them, then I
: can do:
:
: @hits = grep (/$arg1/ || /$arg2/ || /$arg3/, <DAT>);
:
: But the number of arguments is different from one execution of the script
: to the next, and there may be several arguments. So I'm looking for
: something like:
:
: @hits = grep (@args, <DAT>);
:
: Is there some way to do this?
my @hits = grep
&{sub{
for my $arg (@args) {
return 1 if /$arg/;
}
return 0;
}},
<DAT>;
Or give the anonymous sub a name if it could be useful to other parts of
the program.
my @hits = grep test($_), <DAT>;
sub test {
for my $arg (@args) {
return 1 if $_[0] =~ /$arg/;
}
return 0;
}
Nice in that it stops trying after the first successful match.
------------------------------
Date: 22 Nov 2002 02:14:59 -0800
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: help this Newbie in Distress
Message-Id: <34dfc94a.0211220214.1423378f@posting.google.com>
D <doris@chris.com> wrote in message news:<3DDCEBAB.32AD1736@chris.com>...
: What I liked about it was the "colons" to the left of the quoted mail.
: The colons are what looks cool rather than those arrows.
I choose the colon because it can help break up deeply nested '>'-quoted
replies, making it easier to see who said what.
: By the way, regarding, "top-posting"
A note dropped about top-posting is not an invitation to debate, nor is
it a rebuke or attack. It is advice on composing an article that has
the best chance of being noticed by the readers who are most capable and
most willing to assist. Effective communication places the audience's
needs and expectations above the author's.
: Anyway... you did NOT answer my question.
If you mean to say that I did not provide code that does exactly what
you desire, you're right. I chose instead to try persuading you that
the stated goals are mutually exclusive
: Maybe I didn't really want to implement it. Maybe I just wanted to
: know the perl syntax for, "but not this."
: I would guess it would look something like
: $_ = lc!(cd|cd-rom|rom),
: blah blah blah
Pseudocode is pointless unless it's based on an algorithm--in this case,
an algorithm that can isolate 'CD' or 'CD-ROM' while still recognizing
all word boundaries.
How's about this
s/\b(CD(?:-ROM)?)|(\w+)\b/$1||"\u\L$2"/eg;
Maybe fold in some of the other tasks,
s/\b(CD(?:-ROM)?)|(\w+)\b/
$1||(pos!=0&&$2=~m!('s|of|and|the)!i?"\L$1":"\u\L$2")/eg;
Or this other stab, exploiting features for the entertainment of
obfuscation.[1]
s x\b(cd)?(?(1)((?:-${\v82.79.77})?)|(\w+))\bx!$3?"$1$2":0!=
pos&&$3=~m
m('s|of|and|the)mi?"\L$1":qq s\u\L$3sxegi;
But, in the end, there's a difference between skipping "CD-ROM" and just
replacing the substring with itself.
: And, I DID search and read for days trying to learn.
Did someone say that you did not?
: I never post questions that are stupid.
Did someone say that you did?
[1] I'm still amazed that alphanums can be legal alternative delimiters.
------------------------------
Date: 22 Nov 2002 13:02:37 +0100
From: sjn+njus@pvv.org.invalid (Salve J. Nilsen)
Subject: Re: List of all modules w/ versions
Message-Id: <m3el9dx15u.fsf@benzen.eiendomsnett.no>
Keep it to Usenet please <idontreadthis56@hotmail.com> writes:
> Is there a simple way to get a list of all the modules in @INC with
> their version numbers?
ExtUtils::Installed might be useful for that....
- Salve
--
"Don't worry about what anybody else is going to do... The best way
to predict the future is to invent it." -- Alan Kay, 1971
------------------------------
Date: 22 Nov 2002 10:46:58 +0100
From: Slaven Rezic <slaven.rezic@berlin.de>
Subject: Re: List of all modules w/ versions
Message-Id: <87n0o2c4x9.fsf@vran.herceg.de>
roberson@ibd.nrc.ca (Walter Roberson) writes:
> In article <arjtmm$s37@netnews.proxy.lucent.com>,
> Tulan W. Hu <twhu@lucent.com> wrote:
> :"Keep it to Usenet please" <idontreadthis56@hotmail.com> wrote in
> :> Is there a simple way to get a list of all the modules in @INC with
> :> their version numbers?
> :1) download 'Inside' from cpan.
>
> perl -MCPAN -e shell
> cpan> i /inside/
> CPAN: Storable loaded ok
> Going to read /disk2/packages/perls/Metadata
> Database was generated on Thu, 21 Nov 2002 12:53:32 GMT
> No objects found of any type for argument /inside/
>
> cpan> i /Inside/
> No objects found of any type for argument /Inside/
>
It's just a script, not a module. Look at:
$CPAN/authors/id/P/PH/PHOENIX/Inside-1.01.tar.gz
Regards,
Slaven
--
Slaven Rezic - slaven.rezic@berlin.de
tknotes - A knotes clone, written in Perl/Tk.
http://ptktools.sourceforge.net/#tknotes
------------------------------
Date: Fri, 22 Nov 2002 13:18:37 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Ordering of command line switches
Message-Id: <3DDE2E70.A25FDDDE@acm.org>
Matt Knecht wrote:
>
> Getting the ordering of command line switches to get expected
> behaviour has been an exercise in trial and error.
>
> The chunk of code I'm working on sets a user's passwd to their
> username, and is called as a shell function:
>
> update_shadow()
> {
> perl -lnaF: -i -e "
> BEGIN { @s = (0..9, 'A'..'Z', 'a'..'z', '.', '/'); };
> \$F[2] = 0, \$F[1] = crypt('$1', $s[rand @s] . $s[rand @s]) if /^$1:/;
> print +join ':', @F[0..7];
> " /etc/shadow
> }
>
> From a purely aesthetic sense, I'd like to pack the switches as
> tightly as possible. -lnaF:ie doesn't do the trick. Any suggestions?
You have got them as tight as they are going to get as -F, -i and -e
expect a following argument and can't be run together with other
switches. It is also better to use single quotes for -e so the shell
doesn't interpolate something.
update_shadow()
{
perl -F: -i -lane'
BEGIN { $name = shift; @s = (0..9,"A".."Z","a".."z",".","/") }
$F[0] eq $name and @F[1,2] = (crypt($name, $s[rand @s] . $s[rand
@s]), 0);
print join ":", @F
' $1 /etc/shadow
}
John
--
use Perl;
program
fulfillment
------------------------------
Date: Fri, 22 Nov 2002 08:37:07 -0500
From: Jeff 'japhy' Pinyan <pinyaj@rpi.edu>
To: Edi Weitz <edi@agharta.de>
Subject: Re: semantics of nested backreferences in regular expressions
Message-Id: <Pine.A41.3.96.1021122081855.86942A-100000@cortez.sss.rpi.edu>
[posted & mailed]
On 21 Nov 2002, Edi Weitz wrote:
>Yes, I understand that, too. My problem is not that I don't understand
>what's happening (I have in fact implemented a regular expression
>matcher myself), my problem is that I think the two cases aren't
>mutually consistent - or at least that the behaviour shown here is
>counter-intuitive.
I'll explain how they aren't.
>Hmm. I've always seen the 'while /.../g' thing as asking the _same_
>regex to continue where it left off - I didn't see it as _different_
>regexes at work all of which start with a 'clear' state (so to
>say). That explains this part but IMHO the inconsistency remains (see
>below).
>> > print Dumper $1, $2, $3 while /((a)|(b))/g'
>> > $VAR1 = 'a';
>> > $VAR2 = 'a';
>> > $VAR3 = undef;
>> >
>> > $VAR1 = 'b';
>> > $VAR2 = undef;
>> > $VAR3 = 'b';
But when the SECOND match happens, all new $<DIGIT> variables are set, and
since the second time the match occurs, $2 isn't matched, and it becomes
undef.
>> "XY" =~ m{ (?: (X) | (Y) ){2} }x
>>
>> stores X in $1, and store Y in $2 without undef'ing $1.
>
>OK, and here we return to my initial problem: In the first example -
>"a" =~ /((a)*)*/ - $2 is undef'ed before entering the outer group for
>the second time. In the second example - "ab" =~ /((a)|(b))*/ - $2 is
>_not_ undef'ed before entering the outer group for the second time. It
>keeps its value "a" from the first repetition while in the first
>example $2 does _not_ keep its value "a" from the first repetition.
Yes, there is a reason I think this makes sense.
"XY" =~ /(?:(X)|(Y)){2}/
is comprised of the following regex opcodes:
1: CURLYX[0] {2,2}(19)
3: BRANCH(10)
4: OPEN1(6)
6: EXACT <X>(8)
8: CLOSE1(18)
10: BRANCH(17)
11: OPEN2(13)
13: EXACT <Y>(15)
15: CLOSE2(18)
17: TAIL(18)
18: WHILEM(0)
19: NOTHING(20)
20: END(0)
and the execution (on the 2nd time around) looks like this
1 <X> <Y> | 4: OPEN1
1 <X> <Y> | 6: EXACT <X>
failed...
1 <X> <Y> | 11: OPEN2
1 <X> <Y> | 13: EXACT <Y>
2 <XY> <> | 15: CLOSE2
Since we have no CLOSE1, we don't change the value of $1 (not even to
undef). And since there IS a value for $1 at the end of the execution of
the regex, it is ALSO not undef'ed.
Does this clear things up for you? I can make references to the
underlying source code if it'll help. (But I don't know if that'll help.
;) )
--
Jeff "japhy" Pinyan RPI Acacia Brother #734 2002 Acacia Senior Dean
"And I vos head of Gestapo for ten | Michael Palin (as Heinrich Bimmler)
years. Ah! Five years! Nein! No! | in: The North Minehead Bye-Election
Oh. Was NOT head of Gestapo AT ALL!" | (Monty Python's Flying Circus)
------------------------------
Date: Fri, 22 Nov 2002 10:30:05 GMT
From: "Talid" <tjalbout@hotmail.com>
Subject: Re: shtml and Perl
Message-Id: <NGnD9.4828$ea.158294@news2.calgary.shaw.ca>
Okay so the best way is to get the perl script to run the other perl script.
So to convert:
<!--#include virtual="test.pl?info"-->
Would I use:
$timeleft = do("MKCountDown.pl?christmas");
display('signup.html', { lists => $data, timeleft => $timeleft });
.
I'm not having much success with this.
Thanks for the help!
-t
"Steven May" <stevenm@blackwater-pacific.com> wrote in message
news:arkl9t$9pd$1@quark.scn.rain.com...
> Steven May wrote:
> > News wrote:
> >
> >> Got a question, I have a perl script that calls a shtml file.
> >> In the shtml file I have a "<!--#include virtual= " function. If I
> >> run the
> >> shtml file by itself, it works fine but if I run it through the perl
> >> script,
> >> the include doesn't work.
> >> Any ideas? Am I missing a server config?
> >>
> >> Thanks!
> >> -T
> >>
> >>
> >
> > Not really a Perl question, but more than likely this is a path
issue....
> >
> > s.
> >
> >
> >
>
> It's been a long day..... I was thinking javascript and etc. above and
> didn't realize my mistake until about 1/2 second after hitting the send
> button. Sheesh.
>
> Html generated by a cgi script does NOT get run through the SSI
> processeor, so it's a waste of time to even try shtml markup in such
> pages....
>
> s.
>
------------------------------
Date: Fri, 22 Nov 2002 12:35:35 +0100
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: shtml and Perl
Message-Id: <Pine.LNX.4.40.0211221218090.9178-100000@lxplus076.cern.ch>
On Nov 22, Benjamin Goldberg inscribed on the eternal scroll:
> I think you trick Apache to running the output of the CGI through the
> SSI preprocessor, if it's content-type is text/x-server-parsed-html.
Well, I think that reading the documentation for the version of Apache
that you're using would be a more appropriate move.
> But this is just a vague recollection, and definitely not tested.
And also off-topic, so wouldn't it be better to either
1. not post until you've verified your facts, and/or
2. refer the questioner to the documentation and the more appropriate
usenet group?
The Apache documentation points out that doing this has serious
security implications: so casually recommending it to someone who
doesn't seem capable of reading the documentation might be an unwise
move.
best regards
obDocumentation:
http://httpd.apache.org/docs/misc/FAQ.html#ssi-part-iii
oh, and news:alt.possessive.its.has.no.apostrophe
--
"I'm an independent virtual web consultant" -
spotted in comp.security.misc
------------------------------
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:
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.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 V10 Issue 4160
***************************************