[26251] in Perl-Users-Digest
Perl-Users Digest, Issue: 8435 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Sep 20 11:05:21 2005
Date: Tue, 20 Sep 2005 08:05:05 -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 Tue, 20 Sep 2005 Volume: 10 Number: 8435
Today's topics:
Re: How to clear $1 's values ? <nobull@mail.com>
Re: How to clear $1 's values ? <mark.clementsREMOVETHIS@wanadoo.fr>
Re: scalar and hash slices -- is it supposed to work th (Anno Siegel)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 20 Sep 2005 12:12:46 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: How to clear $1 's values ?
Message-Id: <dgoqrf$82m$1@redhat2.bham.ac.uk>
Graham Wood wrote:
> sonet wrote:
>
>> $a =~/ node\=['|"](.*?)['|"][ |>|\/>]/;
>> $node=$1;
>>
> I'd suggest using an if statement before assigning $1.
>
> if($a =~/ node\=['|"](.*?)['|"][ |>|\/>]/){
> $node = $1;
> }
Or, a better idiom IMNSO...
my ($node) = $a =~/ node\=['|"](.*?)['|"][ |>|\/>]/;
------------------------------
Date: Tue, 20 Sep 2005 13:42:30 +0200
From: Mark Clements <mark.clementsREMOVETHIS@wanadoo.fr>
Subject: Re: How to clear $1 's values ?
Message-Id: <432ff52c$0$17205$8fcfb975@news.wanadoo.fr>
sonet wrote:
> ===========================================================================
> use strict;
> my $a;
> my $from;
> my $to;
> my $id;
> my $node;
> $a="<info id='id1' to='test\@se6.program.com.tw' type='get'
> from='luke\@se6.program.com.tw'/>";
>
> $a =~/ from\=['|"](.*?)['|"][ |>|\/>]/;
> $from=$1;
> $a =~/ id\=['|"](.*?)['|"][ |>|\/>]/;
> $id=$1;
> $a =~/ node\=['|"](.*?)['|"][ |>|\/>]/;
> $node=$1;
>
> print $node;
>
Just a thought (this doesn't answer your question):
If you are trying to parse XML, you are better off using a parser.
XML::Simple may be adequate for your needs, if not try XML::LibXML or
similar.
regards,
Mark
------------------------------
Date: 20 Sep 2005 12:05:20 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: scalar and hash slices -- is it supposed to work this way?
Message-Id: <dgotu0$kn$2@mamenchi.zrz.TU-Berlin.DE>
Richard Harman <usenet@myname.com> wrote in comp.lang.perl.misc:
> On Fri, 16 Sep 2005 15:23:08 +0000, Eric Bohlman wrote:
>
> > Richard Harman <usenet@myname.com> wrote in
> > news:pan.2005.09.16.15.06.41.414122@myname.com:
> >
> >> I think I found a bug in perl when dealing with hash slices. For some
> >
> > May people have thought they found bugs in perl. Few of them really
> > have.
>
> I suspected as much :)
>
> >> reason, scalar is interpreting the returned list from a hash slice as
> >> a 'scalar comma expression' and is returning the final element
> >> (perldoc -f scalar, 3rd paragraph). Is this the way it's supposed to
> >> work? (If this is not the correct place to ask, where do I go?)
> >
> > Yes, it's the way it's supposed to work. The entry "What is the
> > difference between a list and an array?" in perlfaq4 is a good place to
> > start.
>
> Wow, according to perlfaq4 I'm doing all sorts of bad things, like
> ($exits) = grep { m/pattern/ } @array;
What do you think is wrong with that? It's a perfectly good idiom
to retrieve the first element of @array for which /pattern/ matches.
I use it all the time (unless I'm using List::Util::first).
Anno
--
If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers.
------------------------------
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 8435
***************************************