[26173] in Perl-Users-Digest
Perl-Users Digest, Issue: 8362 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Aug 26 21:05:26 2005
Date: Fri, 26 Aug 2005 18:05:04 -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 Fri, 26 Aug 2005 Volume: 10 Number: 8362
Today's topics:
Perl regular expressions help <sgrumpa@yahoo.com>
Re: Perl regular expressions help <1usa@llenroc.ude.invalid>
Re: Perl regular expressions help <abigail@abigail.nl>
Re: Using Crypt::DSA <sisyphus1@nomail.afraid.org>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 26 Aug 2005 15:28:15 -0700
From: Rumpa <sgrumpa@yahoo.com>
Subject: Perl regular expressions help
Message-Id: <deo51v$26ui$1@heap.juniper.net>
Hi,
I am trying to learn perl regular expressions.
I have:
my $store = q(
<store>
<book>
<title>abc</title>
<author>xyz</author>
</book>
<book>
<title>pqr</title>
<author>mno</author>
</book>
</store>);
I want to extract the titles only in a loop. How can I do this?
Thanks,
Rumpa
------------------------------
Date: Fri, 26 Aug 2005 22:56:58 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Perl regular expressions help
Message-Id: <Xns96BEC0BF43B39asu1cornelledu@127.0.0.1>
Rumpa <sgrumpa@yahoo.com> wrote in news:deo51v$26ui$1@heap.juniper.net:
> I am trying to learn perl regular expressions.
But parsing XML is best done by using an XML parser.
> I have:
> my $store = q(
> <store>
> <book>
> <title>abc</title>
> <author>xyz</author>
> </book>
> <book>
> <title>pqr</title>
> <author>mno</author>
> </book>
> </store>);
>
> I want to extract the titles only in a loop. How can I do this?
Use an XML parser. You can build on the following example:
#!/usr/bin/perl
use strict;
use warnings;
use XML::Parser;
my $xml = <<XML
<store>
<book>
<title>abc</title>
<author>xyz</author>
</book>
<book>
<title>pqr</title>
<author>mno</author>
</book>
</store>
XML
;
my $in_title;
my $p = XML::Parser->new(Style => 'Stream', Pkg => 'main');
$p->parse($xml);
sub StartTag {
my ($x, $el) = @_;
return unless $el eq 'title';
$in_title = 1;
}
sub Text {
my ($x) = @_;
print "$_\n" if $in_title;
}
sub EndTag {
my ($x, $el) = @_;
return unless $el eq 'title';
$in_title = 0;
}
__END__
--
A. Sinan Unur <1usa@llenroc.ude.invalid>
(reverse each component and remove .invalid for email address)
comp.lang.perl.misc guidelines on the WWW:
http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
------------------------------
Date: 27 Aug 2005 00:22:03 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: Perl regular expressions help
Message-Id: <slrndgvchb.3h1.abigail@alexandra.abigail.nl>
Rumpa (sgrumpa@yahoo.com) wrote on MMMMCCCLXXVIII September MCMXCIII in
<URL:news:deo51v$26ui$1@heap.juniper.net>:
`' Hi,
`' I am trying to learn perl regular expressions.
`' I have:
`' my $store = q(
`' <store>
`' <book>
`' <title>abc</title>
`' <author>xyz</author>
`' </book>
`' <book>
`' <title>pqr</title>
`' <author>mno</author>
`' </book>
`' </store>);
`'
`' I want to extract the titles only in a loop. How can I do this?
That depends on what is a title. For the given example,
/(abc|pqr)/
will do.
/<title>([^<]+)<\/title>/
works for the given example as well, but it might give false positives.
You are probably much better off with a parser, althouh it is
possible to replace a lot of parsers with regular expressions.
Not that any sane person would want to do it.
Abigail
--
#!/opt/perl/bin/perl -w
$\ = $"; $; = $$; END {$: and print $:} $SIG {TERM} = sub {$ := $_}; kill 15 =>
fork and ($; == getppid and exit or wait) foreach qw /Just another Perl Hacker/
------------------------------
Date: Sat, 27 Aug 2005 09:04:05 +1000
From: "Sisyphus" <sisyphus1@nomail.afraid.org>
Subject: Re: Using Crypt::DSA
Message-Id: <430fa013$0$25524$afc38c87@news.optusnet.com.au>
"Mike Friedman" <mikef@brillig.security.berkeley.edu> wrote in message
[snip]
>
> I want to be able to create a public key file and a signature in formats
> that can be distributed to a user community whose applications may be
> using other DSA implementations (e.g., Java crypto lib, or other scripting
> languages besides perl). So, it's important that the public key file be
> in a reasonably standard format.
Which, afaik, would be a pem file. Crypt::DSA can parse them (as long as you
have Convert::PEM) and so, presumably, can the other DSA implementations. To
write a *public* key pem file with Crypt::DSA you just do (as in 04-pem.t):
$key->priv_key(undef);
$key->write( Type => 'PEM', Filename => $keyfile);
> Also, I'd be passing the signature as
> a base64-encoded string via a web form field. Once the application
> base64-decodes it, the signature should be in a format easily fed to its
> DSA verify routine.
>
Are you saying the signature part is not a problem ? I find some ambiguity
with "the signature should be in a format easily fed to its DSA verify
routine" - not sure whether that means the signature is already in a
suitable format, or whether it means that it needs to be in a suitable
format (but isn't).
Cheers,
Rob
------------------------------
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.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
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 8362
***************************************