[26587] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 8718 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Nov 29 03:05:41 2005

Date: Tue, 29 Nov 2005 00:05:06 -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           Tue, 29 Nov 2005     Volume: 10 Number: 8718

Today's topics:
    Re: Matching escaped delimiter chars robic0
    Re: XML::Simple array size robic0
    Re: XML::Simple array size robic0
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Tue, 29 Nov 2005 00:02:19 -0800
From: robic0
Subject: Re: Matching escaped delimiter chars
Message-Id: <sn2oo1pu3bpdgeil7buc35spe1ifgknuru@4ax.com>

On Mon, 28 Nov 2005 21:21:09 +0100, Witold Rugowski
<witold.rugowski@hp.com> wrote:

>Hi!
>I want to match with regexp substring, which is delimited by, let's say ". It is trivial, but I don't know how to match escaped quotes with \. OK, example will be better ;-))
>
>Let's take string such:
>AAAAAAA "blah blah \" blah blah" BBBBBB
>
>How to match all what is in between quotes, not counting escaped quote. In this case it should match to:
>blah blah \" blah blah
>
>How it can be done????
>
>Best regards,
>Witold Rugowski

my @regx_esc_codes = ( "\\", '/', '(', ')', '[', ']', '?', '|',
     '+', '.', '*', '$', '^', '{', '}', '@' );

my $funky_string = 'AAAAAAA "blah blah \" blah blah" BBBBBB';
my $match_string = 'your_logic_here';
for (@regx_esc_codes)
{
	my $tc = $_;
	 # code template for regex
	my $xx = "\$match_string =~ s/\\$tc/\\\\\\$tc/g;";
	eval $xx;
	#print "$xx\n";
}

## match should be ready now,
## be sure to trap regex violations

$fnd = 0;
# -- #
my $ctmpl = "if (\$funky_string =~ /$match_string/ {\$fnd = 1;}";
eval $ctmpl;
# -- #

if ($@) {
	## Check the $ctmpl, get the control code, log this error as a
code issue.
	## This shouldn't happen ... the compiler will show the escape
char, add
	## the char to "@regx_esc_codes", now its fixed!
	$@ =~ s/^[\x20\n\t]+//; $@ =~ s/[\x20\n\t]+$//;
	print $@,"\n";
	exit;
}

Note - I may be wrong in this context, its been a while




------------------------------

Date: Mon, 28 Nov 2005 22:51:08 -0800
From: robic0
Subject: Re: XML::Simple array size
Message-Id: <g5uno11r6901vv00tnpln9r35j3q4v3jfc@4ax.com>

On Sat, 14 Feb 2004 17:58:08 -0500, Mark J Fenbers
<Mark.Fenbers@noaa.gov> wrote:

>In my sample XML file...
>
><main>
>    <level1>
>        <level2>whatever</level2>
>        <level2>whatever</level2>
>        <level2>whatever</level2>
>        <level2>whatever</level2>
>        <level2>whatever</level2>
>         ...
>    </level1>
></main>
>
>I have an variable number of level2 tags.  Using XML::Simple, I can access the
>value of the 4th one by something like this:
>
>    my $main = XMLin("myfile.xml");
>    print $main->{level1}->{level2}->[3]->{content};
>
>But I really want to know how many level2 records there are.  I tried variations
>
Hey isn't the "$main" name take already?
New rule, you have to give more details than "I want to count all
animals on Noah's ark". Noah didn't coun't them for a reason....
Unless you positively know ahead of time the structure of the xml
in question, you can't rely on xml::simple's output structure.
I guess thats the other question.....


------------------------------

Date: Mon, 28 Nov 2005 22:54:42 -0800
From: robic0
Subject: Re: XML::Simple array size
Message-Id: <oluno11vrd6f7qehjs5moap5llrdvg36l8@4ax.com>

On Mon, 28 Nov 2005 22:51:08 -0800, robic0 wrote:

>On Sat, 14 Feb 2004 17:58:08 -0500, Mark J Fenbers
><Mark.Fenbers@noaa.gov> wrote:
>
>>In my sample XML file...
>>
>><main>
>>    <level1>
>>        <level2>whatever</level2>
>>        <level2>whatever</level2>
>>        <level2>whatever</level2>
>>        <level2>whatever</level2>
>>        <level2>whatever</level2>
>>         ...
>>    </level1>
>></main>
>>
>>I have an variable number of level2 tags.  Using XML::Simple, I can access the
>>value of the 4th one by something like this:
>>
>>    my $main = XMLin("myfile.xml");
>>    print $main->{level1}->{level2}->[3]->{content};
>>
>>But I really want to know how many level2 records there are.  I tried variations
>>
>Hey isn't the "$main" name take already?
>New rule, you have to give more details than "I want to count all
>animals on Noah's ark". Noah didn't coun't them for a reason....
>Unless you positively know ahead of time the structure of the xml
>in question, you can't rely on xml::simple's output structure.
>I guess thats the other question.....
Would you know that its simple xml and not nested content?
Are you analyzing unknown xml structure?
Did you write this xml structure that you want to analyze?


------------------------------

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 8718
***************************************


home help back first fref pref prev next nref lref last post