[19091] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1286 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jul 11 14:10:35 2001

Date: Wed, 11 Jul 2001 11:10:19 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <994875018-v10-i1286@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Wed, 11 Jul 2001     Volume: 10 Number: 1286

Today's topics:
        Simple pattern-matching problem <hcexres@io.com>
    Re: Simple pattern-matching problem (E.Chang)
    Re: Simple pattern-matching problem <laszlo.gerencser@portologic.com>
    Re: Simple pattern-matching problem <hcexres@io.com>
        SSH <syed_altaf@yahoo.com>
    Re: Term::ANSIColor in Windows 2000's CMD <alistair_remove@pwd.hp.com>
        test snafu@mit.edu
        Text variable containing '$' <jocke30_gbg@hotmail.com>
    Re: Text variable containing '$' (E.Chang)
    Re: Text variable containing '$' <jocke30_gbg@hotmail.com>
    Re: Text variable containing '$' <mjcarman@home.com>
    Re: Text variable containing '$' (Anno Siegel)
        time stamp  to a tenth of a second <inna@raykhman.com>
    Re: time stamp  to a tenth of a second (Anno Siegel)
    Re: trimming blank <pascalleprevost@canada.com>
    Re: Very good regex question? (Anno Siegel)
    Re: Where can I get a list of Larry Wall witticisms? (Chris Fedde)
        Where is MD5 (Otto Wyss)
    Re: why is Vars an undefined subroutine? (Villy Kruse)
    Re: why is Vars an undefined subroutine? (Rafael Garcia-Suarez)
    Re: Working with packed strings <tschmelter@statesman.com>
        XML Parser Question <rwoodman_nospam_@verio.net>
    Re: XML Parser Question <cpryce@pryce.net>
    Re: XML Parser Question (Tad McClellan)
    Re: XML Parser Question <rwoodman_nospam_@verio.net>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Wed, 11 Jul 2001 12:08:41 -0500
From: "David A. McMurrey" <hcexres@io.com>
Subject: Simple pattern-matching problem
Message-Id: <3B4C8819.CEB3C919@io.com>

Picture this -- I have an array with elements like this:

$liner[10] = "CarlT|category1|judgeset2|6/13/01";
$liner[11] = "SarahW|category1|judgeset2|6/13/01";
$liner[12] = "SarahW|category13|judgeset2|6/13/01";

I want to select only those elements containing "category1"

$category = "category1";
if ($liner =~ /$category/) . . . .

How do I exclude things like category13 ?

-- David



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

Date: Wed, 11 Jul 2001 17:17:51 GMT
From: echang@netstorm.net (E.Chang)
Subject: Re: Simple pattern-matching problem
Message-Id: <Xns90DB87C62D70Dechangnetstormnet@207.106.93.86>

"David A. McMurrey" <hcexres@io.com> wrote in 
<3B4C8819.CEB3C919@io.com>:

> Picture this -- I have an array with elements like this:
> 
> $liner[10] = "CarlT|category1|judgeset2|6/13/01";
> $liner[11] = "SarahW|category1|judgeset2|6/13/01";
> $liner[12] = "SarahW|category13|judgeset2|6/13/01";
> 
> I want to select only those elements containing "category1"
> 
> $category = "category1";
> if ($liner =~ /$category/) . . . .
> 
> How do I exclude things like category13 ?
> 

Assuming the pipe always immediately follows the digits in the string,

$category = "category1\|";

-- 
EBC


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

Date: Wed, 11 Jul 2001 17:30:12 GMT
From: Laszlo Gerencser <laszlo.gerencser@portologic.com>
Subject: Re: Simple pattern-matching problem
Message-Id: <3B4C8D55.32343A4A@portologic.com>


$category = "|category1|";
Or if you are a little bit paranoid: split the string first (on | of
course), then get your substring and use the
if ($mysubstring eq $category) ...
syntax

--
Laszlo Gerencser
PortoLogic Ltd.


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

Date: Wed, 11 Jul 2001 12:53:41 -0500
From: "David A. McMurrey" <hcexres@io.com>
Subject: Re: Simple pattern-matching problem
Message-Id: <3B4C92A5.8F228ECE@io.com>

Thanks, EBC and Laszlo, but this is what I have -- it prints out *all* the
items! For both ways of handling the variable

-- David

#!/usr/local/bin/perl

$liner[0] = "JoeS|category1|judgeset1|6/13/01";
$liner[1] = "MaryB|category1|judgeset1|6/13/01";
$liner[2] = "JohnC|category1|judgeset1|6/13/01";
$liner[3] = "JoelC|category1|judgeset2|6/13/01";

$liner[4] = "JillW|category2|judgeset1|6/13/01";
$liner[5] = "HenryW|category2|judgeset1|6/13/01";

$liner[6] = "SethY|category3|judgeset1|6/13/01";
$liner[7] = "UrsulaX|category3|judgeset1|6/13/01";
$liner[8] = "BrendaS|category3|judgeset1|6/13/01";
$liner[9] = "MaryZ|category3|judgeset2|6/13/01";
$liner[10] = "CarlT|category3|judgeset2|6/13/01";
$liner[11] = "SarahW|category3|judgeset2|6/13/01";

$liner[12] = "SarahW|category13|judgeset2|6/13/01";

# $category = "|category1|";
$category = "category1\|";

# select only the $ category items
foreach $liner (@liner)
{
        if ($liner =~ /$category/)
        {
                print "$liner \n";
        }
}

"E.Chang" wrote:

> "David A. McMurrey" <hcexres@io.com> wrote in
> <3B4C8819.CEB3C919@io.com>:
>
> > Picture this -- I have an array with elements like this:
> >
> > $liner[10] = "CarlT|category1|judgeset2|6/13/01";
> > $liner[11] = "SarahW|category1|judgeset2|6/13/01";
> > $liner[12] = "SarahW|category13|judgeset2|6/13/01";
> >
> > I want to select only those elements containing "category1"
> >
> > $category = "category1";
> > if ($liner =~ /$category/) . . . .
> >
> > How do I exclude things like category13 ?
> >
>
> Assuming the pipe always immediately follows the digits in the string,
>
> $category = "category1\|";
>
> --
> EBC



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

Date: Wed, 11 Jul 2001 12:39:27 -0400
From: syed hussain <syed_altaf@yahoo.com>
Subject: SSH
Message-Id: <3B4C813F.DE72A2F9@yahoo.com>

Any body has used SSH within PERL on Win32 system
Please let me know'

Thanks
Syed



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

Date: Wed, 11 Jul 2001 09:19:26 +0100
From: Alistair McDonald <alistair_remove@pwd.hp.com>
Subject: Re: Term::ANSIColor in Windows 2000's CMD
Message-Id: <MPG.15b61c6a7a3c7519989697@news.cup.hp.com>

In article <9i6fa8$qsk$1@bob.news.rcn.net>, dont@mail.me says...
> Has anyone successfully used the Term::ANSIColor module in Windows 2000's
> CMD using ActivePerl?  I've tried using code straight from the module's
> documentation, but still see the standard colors.  If I run the same script
> on a Linux console, everything works as expected.  Is this a limitation of
> CMD or is there a special option to allow for ANSI colors in it?  Thanks for
> your help.
> 

I don't think that it will work. W2K doesn't do ANSI screen stuff at 
all. As Mark Replied, Windows had ansi.sys, but there is no equivalent 
in 2000.  You could try a shell like the cygwin bash 
(http://cygwin.com/), which might work, or even more perverse try 
running a telnet server on the w2k box and telnet to localhost. There's 
a telnet server as part of MS's Services for Unix - but I think it's 
very poor.

Regards,
Alistair


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

Date: 11 Jul 2001 14:19:44 GMT
From: snafu@mit.edu
Subject: test
Message-Id: <9ihna012o1p@enews1.newsguy.com>


zztest




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

Date: Wed, 11 Jul 2001 16:48:23 +0200
From: "JJ" <jocke30_gbg@hotmail.com>
Subject: Text variable containing '$'
Message-Id: <9ihoul$o6v$1@vg170.it.volvo.se>

Hi,

I collect table names from a database and stores them in a array. The table
names can contain the character '$' such as 'My$Table'.
Before I store the value in the array I need to determine if it contains the
character and replace '$' with '\$'.

How can I do this?

--
Best regards
Joacim Jarkeborn





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

Date: Wed, 11 Jul 2001 15:12:32 GMT
From: echang@netstorm.net (E.Chang)
Subject: Re: Text variable containing '$'
Message-Id: <Xns90DB72A061901echangnetstormnet@207.106.92.86>

"JJ" <jocke30_gbg@hotmail.com> wrote in
<9ihoul$o6v$1@vg170.it.volvo.se>: 

> Hi,
> 
> I collect table names from a database and stores them in a array.
> The table names can contain the character '$' such as 'My$Table'.
> Before I store the value in the array I need to determine if it
> contains the character and replace '$' with '\$'.

The following example shows one way:

$in = 'My$Table';
$replace = '\$';
$in =~ s/\$/$replace/g;
print $in";


Output for this example: My\$Table

You can omit the 'g' modifier on the substitution if there will be 
no more than one '$' in a name.  As always, I am sure there are many 
more ways to do it, and I look forward to seeing some of them.

-- 
EBC


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

Date: Wed, 11 Jul 2001 17:39:44 +0200
From: "JJ" <jocke30_gbg@hotmail.com>
Subject: Re: Text variable containing '$'
Message-Id: <9ihruu$3ri$1@vg170.it.volvo.se>

"E.Chang" <echang@netstorm.net> wrote in message
news:Xns90DB72A061901echangnetstormnet@207.106.92.86...
> "JJ" <jocke30_gbg@hotmail.com> wrote in
> <9ihoul$o6v$1@vg170.it.volvo.se>:
>
> > Hi,
> >
> > I collect table names from a database and stores them in a array.
> > The table names can contain the character '$' such as 'My$Table'.
> > Before I store the value in the array I need to determine if it
> > contains the character and replace '$' with '\$'.
>
> The following example shows one way:
>
> $in = 'My$Table';
> $replace = '\$';
> $in =~ s/\$/$replace/g;
> print $in";
>
>
> Output for this example: My\$Table

Thanks, it worked and I can go home for the day ;-)

BR
// Joacim

>
> You can omit the 'g' modifier on the substitution if there will be
> no more than one '$' in a name.  As always, I am sure there are many
> more ways to do it, and I look forward to seeing some of them.
>
> --
> EBC




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

Date: Wed, 11 Jul 2001 10:49:50 -0500
From: Michael Carman <mjcarman@home.com>
Subject: Re: Text variable containing '$'
Message-Id: <3B4C759E.57BFA7FC@home.com>

JJ wrote:
> 
> I collect table names from a database and stores them in a array.
> The table names can contain the character '$' such as 'My$Table'.
> Before I store the value in the array I need to determine if it
> contains the character and replace '$' with '\$'.

Hmm. Why do you think you need to do this? I highly doubt that it's
necessary.
 
> How can I do this?

s/\$/\\\$/g;

-mjc


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

Date: 11 Jul 2001 17:32:29 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Text variable containing '$'
Message-Id: <9ii2jd$igj$2@mamenchi.zrz.TU-Berlin.DE>

According to E.Chang <echang@netstorm.net>:
> "JJ" <jocke30_gbg@hotmail.com> wrote in
> <9ihoul$o6v$1@vg170.it.volvo.se>: 
> 
> > Hi,
> > 
> > I collect table names from a database and stores them in a array.
> > The table names can contain the character '$' such as 'My$Table'.
> > Before I store the value in the array I need to determine if it
> > contains the character and replace '$' with '\$'.
> 
> The following example shows one way:
> 
> $in = 'My$Table';
> $replace = '\$';
> $in =~ s/\$/$replace/g;
> print $in";
> 
> 
> Output for this example: My\$Table
> 
> You can omit the 'g' modifier on the substitution if there will be 
> no more than one '$' in a name.  As always, I am sure there are many 
> more ways to do it, and I look forward to seeing some of them.

Perl lets you choose the delimiters in s/// expressions:

    $in =~ s'\$'\$';

Question: Why does the "$" in the left part still need an escape?

Anno


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

Date: Wed, 11 Jul 2001 13:32:25 -0500
From: <inna@raykhman.com>
Subject: time stamp  to a tenth of a second
Message-Id: <84037.3$4M4.890@news.nyc.globix.net>

Hi,

am looking for smth in perl that would give me a timestamp to a tenth of
second, preferable in a single number.

if anyone knows of smth, please let me know.

thanks,
inna




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

Date: 11 Jul 2001 17:35:38 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: time stamp  to a tenth of a second
Message-Id: <9ii2pa$igj$3@mamenchi.zrz.TU-Berlin.DE>

According to  <inna@raykhman.com>:
> Hi,
> 
> am looking for smth in perl that would give me a timestamp to a tenth of
> second, preferable in a single number.
> 
> if anyone knows of smth, please let me know.

Get Time::Hires from the cpan.

Anno


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

Date: Wed, 11 Jul 2001 15:30:17 GMT
From: "Pascal" <pascalleprevost@canada.com>
Subject: Re: trimming blank
Message-Id: <di_27.22765$E93.3831264@news1.telusplanet.net>

Thanks guys for all your help.  As a Visual Basic programmer I am very
impressed by the Perl People response to help so quickly.  I should really
switch to Linux as well but don't know which vendor to select.  Anyway, have
a good one.


"Pascal" <pascalleprevost@canada.com> wrote in message
news:uzG27.26803$MO1.3773060@news0.telusplanet.net...
> What is the best way to remove spaces before or after a sentence.
>
> Example before: "             Hello World          "
> Example after: "Hello World"
>
> I appreciate any help.  Thanks
> --
> Pascal Leprevost
> Winsoft Solutions Ltd.
> winsoft@canda.com
>
>




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

Date: 11 Jul 2001 17:10:41 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Very good regex question?
Message-Id: <9ii1ah$igj$1@mamenchi.zrz.TU-Berlin.DE>

According to Philip Newton  <nospam.newton@gmx.li>:
> On Wed, 11 Jul 2001 07:42:21 +0000 (UTC), Ilya Zakharevich
> <nospam-abuse@ilyaz.org> wrote:
> 
> > Unless //e, the second half *of the substitution* is in the same
> > context wrt quoting of '.
> 
> Not like "? The right-hand side of a substitution interpolates
> variables, and ' doesn't.

I feel presumptuous, let me speak for Ilya :)

Both sides of an s/// (normally) interpolate variables, that's
not the point.  The status of "'" is the same on both sides in
that it doesn't need to be backwhacked.

Though that isn't strictly true too, looking at

    s{abc} 'xyz';

Anno


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

Date: Wed, 11 Jul 2001 17:00:50 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: Re: Where can I get a list of Larry Wall witticisms?
Message-Id: <6D%27.25$T3.170774016@news.frii.net>

In article <gOi27.15949$B56.2735637@news2-win.server.ntlworld.com>,
Stuart Moore <stumo@bigfoot.com> wrote:
>PerlFAQ Server <faq@denver.pm.org> wrote in message
>news:2hh27.76$T3.200270336@news.frii.net...
>>
>>     Newer examples can be found by perusing Larry's postings:
>>
>>
>

I've truncated these lines from the faq.
-- 
    This space intentionally left blank


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

Date: Wed, 11 Jul 2001 17:15:05 +0200
From: otto.wyss@bluewin.ch (Otto Wyss)
Subject: Where is MD5
Message-Id: <1ewe4yb.18or3j9howa0yN%otto.wyss@bluewin.ch>

I've used module MD5 (on Debian testing) but since I upgraded to perl
5.6.1 this module is gone! How do I find out where I have to look for
it?

I tried perldoc MD5 => nothing, I tried perldoc -q MD5 => nothing! How
do I find out what modules where installed?

O. Wyss


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

Date: 11 Jul 2001 13:38:16 GMT
From: vek@pharmnl.ohout.pharmapartners.nl (Villy Kruse)
Subject: Re: why is Vars an undefined subroutine?
Message-Id: <slrn9kolm7.ou8.vek@pharmnl.ohout.pharmapartners.nl>

On Wed, 11 Jul 2001 10:53:49 GMT,
    TuNNe|ing <troll@gimptroll.com> wrote:


>
>Thanks for copy and pasting the CGI.pm document. I've read this and
>tried just about all combinations provided, previous to posting.
>
>Does this mean I need to get a newer version of CGI.pm?
>perl -v tells me "This is perl, version 5.005_03 build for i386 linux"
>


Pick up a new version of CGI from CPAN (perldoc -f CPAN gives you
some hints how to).  Although CGI is included with Perl it is also
released with newer version independent of the particular Perl version.

Try locate /CGI.pm and grep for the string VERSION.  This tells the
version of CGI itself.

Villy


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

Date: 11 Jul 2001 13:53:53 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: why is Vars an undefined subroutine?
Message-Id: <slrn9komk9.bge.rgarciasuarez@rafael.kazibao.net>

Villy Kruse wrote in comp.lang.perl.misc:
> Try locate /CGI.pm and grep for the string VERSION.  This tells the
> version of CGI itself.

or :

  perl -MCGI -le 'print $INC{"CGI.pm"};print $CGI::VERSION'

-- 
Rafael Garcia-Suarez


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

Date: Wed, 11 Jul 2001 13:07:21 GMT
From: Tim Schmelter <tschmelter@statesman.com>
Subject: Re: Working with packed strings
Message-Id: <3B4C4F88.7E21ACA7@statesman.com>

Philip Newton wrote:

> > i.e., will the following always put the first 15 bytes of $buffer into
> > $subsetted, no matter what info $buffer contains?
> >
> > sysread(INFILE, $buffer, 8, 32);
> > $subsetted=substr($buffer, 0, 15);
>
> Yes, as long as $buffer is at least 15 bytes long, of course.

perldoc -q multibyte says that Perl pretends that a byte and a character are
synonymous, but didn't I read that there are plans to make Perl6 Unicode-aware?

If so, wouldn't scalars containing arbitrary binary data be interpreted as
two-byte strings? In which case, the unpack() version of substring documented in
perldoc -f unpack might be safer, in the sense of "treat bytes as bytes, not as
multibyte characters":
    sub substr {
        my($what,$where,$howmuch) = @_;
        unpack("x$where a$howmuch", $what);
    }

Or am I just being paranoid? :-)

--
Tim Schmelter
Public Key available from http://www.keyserver.net
CAD7 2ABB 05A4 2F00 4CAE 7D2F 127C 129A 7173 2951




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

Date: Wed, 11 Jul 2001 14:06:17 GMT
From: Randall Woodman <rwoodman_nospam_@verio.net>
Subject: XML Parser Question
Message-Id: <3B4C5D80.936D238D@verio.net>

I posted this in alt.perl and got no response so I'm posting it here as
well.  Apoligies to all for not cross-posting the first time.

Remove the _nospam_ from my email to reply directly.

Yes, I have read the docs.

I am using the XML::Parser module.  The problem I'm having is when special
characters are sent through the parser.  First some background.

At the start of this project, it was assumed that text between the tags
(e.g. <example>text</example>) would be captured with one call of the
character handler routine.  However, with special characters, (e.g. &amp;
&lt; etc) this does not seem to be the case.  Observe the following data
file.

=====================
<header>
<option1>&lt;blink>Hi&lt;/blink></option1>

<option2>plain text</option2>

<option3>less than &lt;</option3>

<option4>greater than &gt;</option4>
</header>
======================

When run through a very simple parser (code is below) we get the following
output.

======================
starting . . .
Finished reading file
START: tagname = header
CHAR: tagname = header, value =

START: tagname = option1
CHAR: tagname = option1, value = <
CHAR: tagname = option1, value = blink>Hi
CHAR: tagname = option1, value = <
CHAR: tagname = option1, value = /blink>
END: tagname = option1
CHAR: tagname = header, value =

CHAR: tagname = header, value =

START: tagname = option2
CHAR: tagname = option2, value = plain text
END: tagname = option2
CHAR: tagname = header, value =

CHAR: tagname = header, value =

START: tagname = option3
CHAR: tagname = option3, value = less than
CHAR: tagname = option3, value = <
END: tagname = option3
CHAR: tagname = header, value =

CHAR: tagname = header, value =

START: tagname = option4
CHAR: tagname = option4, value = greater than
CHAR: tagname = option4, value = >
END: tagname = option4
CHAR: tagname = header, value =

END: tagname = header
ending . . .
============================

The assumption was that all text through the character handler, regardless
of context, would appear as option 2; all on the same line.  This is
clearly not the case.  So, how do I resolve this issue?  I could rewrite
the character handler to act as a collector and then report (manipulate,
etc) data in the end handler.  However, I have a significent amount of
effort invested already and would really hate to rewrite the thing.  I'm
looking for suggestions on how to resolve this issue.

FWIW, here's the code that produced the output from the data shown above.

============================
#!/usr/local/bin/perl -w

use strict;

### Standard Modules and Libraries
use XML::Parser;

use vars( qw (
        $xml_input
));

######################################################
# determine the data destination
sub parse_destination
{
    my $parser = new XML::Parser(Style => 'Debug');

    $parser->setHandlers(Start => \&xmlGenStart,
                         End   => \&xmlGenEnd,
                         Char  => \&xmlGenCharData);
    $parser->parse($xml_input);
}

######################################################
sub xmlGenStart
{
    my ($xhandler,$element,%data) = @_;
    print "START: tagname = $element\n";
}

######################################################
sub xmlGenEnd
{
    my ($xhandler, $element, @data) = @_;
    print "END: tagname = $element\n";
}

######################################################
sub xmlGenCharData
{
    my ($xhandler,$string) = @_;
    my ($element) = $xhandler->current_element;

    print "CHAR: tagname = $element, value = $string\n";
}

############################################################
sub read_xmlfile
{
   my $xmlfilename = shift;
   my $filesize;
   if (!(-e $xmlfilename))
   {
      print "File \"$xmlfilename\" was not found. Can't continue.\n";
      exit 1;
   }
   $filesize = (stat($xmlfilename))[7];
   open XMLFH, "$xmlfilename" or die "Cannot open $xmlfilename. ($!)";
   read XMLFH, $xml_input, $filesize;
   close XMLFH;
   print "Finished reading file\n";
}

print "starting . . .\n";
my $xmlfile = shift;
die ("supply a file name.\n") if (! defined $xmlfile);

read_xmlfile($xmlfile);
&parse_destination;
print "ending . . .\n";

================================

Thanks for any help you choose to provide.

-=} Randall {=-  Well...At least the bug works properly...


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

Date: Wed, 11 Jul 2001 09:34:44 -0500
From: cp <cpryce@pryce.net>
Subject: Re: XML Parser Question
Message-Id: <B771CE34.841C%cpryce@pryce.net>

in article 3B4C5D80.936D238D@verio.net, Randall Woodman at
rwoodman_nospam_@verio.net wrote on 07/11/2001 9:06 AM:

> I am using the XML::Parser module.  The problem I'm having is when special
> characters are sent through the parser.  First some background.
> 
> At the start of this project, it was assumed that text between the tags
> (e.g. <example>text</example>) would be captured with one call of the
> character handler routine.  However, with special characters, (e.g. &amp;
> &lt; etc) this does not seem to be the case.  Observe the following data
> file.
> 
> =====================
> <header>
> <option1>&lt;blink>Hi&lt;/blink></option1>
> 
> <option2>plain text</option2>
> 
> <option3>less than &lt;</option3>
> 
> <option4>greater than &gt;</option4>
> </header>


If they are HTML Entities, could you run it through the HTML::Entities
module and use the decode_entities function first?

cp



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

Date: Wed, 11 Jul 2001 10:53:00 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: XML Parser Question
Message-Id: <slrn9koq2c.el8.tadmc@tadmc26.august.net>

Randall Woodman <rwoodman_nospam_@verio.net> wrote:

>Yes, I have read the docs.


Thank you.

But it appears that you missed the relevant part :-)


>I am using the XML::Parser module. 

>At the start of this project, it was assumed 
                               ^^^^^^^^^^^^^^

Warning Will Robinson!


>that text between the tags
>(e.g. <example>text</example>) would be captured with one call of the
>character handler routine.  


from the XML::Parser docs (my emphasis):

-----------------------------------------
=head2 Char             (Expat, String)

This event is generated when non-markup is recognized. The non-markup
sequence of characters is in String. A single non-markup sequence of
characters may generate multiple calls to this handler. Whatever the
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
encoding of the string in the original document, this is given to the
handler in UTF-8.
-----------------------------------------


>So, how do I resolve this issue?  I could rewrite
>the character handler to act as a collector and then report (manipulate,
>etc) data in the end handler.  


You already know how to resolve this issue then  :-)

"buffer in char handler" and "process in end tag handler" is
How You Are Supposed To Do It.


>However, I have a significent amount of
>effort invested already and would really hate to rewrite the thing.  


Erroneous assumptions can lead to much pain.

Itsabummer to learn it the hard way though. You have my sympathy.


>I'm
>looking for suggestions on how to resolve this issue.


You have a serious bug that will not be trivial to fix, but
must be fixed anyway.


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Wed, 11 Jul 2001 15:58:21 GMT
From: Randall Woodman <rwoodman_nospam_@verio.net>
Subject: Re: XML Parser Question
Message-Id: <3B4C77CA.379DE4C7@verio.net>



Tad McClellan wrote:

> Randall Woodman <rwoodman_nospam_@verio.net> wrote:
>
> >that text between the tags
> >(e.g. <example>text</example>) would be captured with one call of the
> >character handler routine.
>
> from the XML::Parser docs (my emphasis):
>
> -----------------------------------------
> =head2 Char             (Expat, String)
>
> This event is generated when non-markup is recognized. The non-markup
> sequence of characters is in String. A single non-markup sequence of
> characters may generate multiple calls to this handler. Whatever the
>                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> encoding of the string in the original document, this is given to the
> handler in UTF-8.
> -----------------------------------------
>
> >So, how do I resolve this issue?  I could rewrite
> >the character handler to act as a collector and then report (manipulate,
> >etc) data in the end handler.
>
> You already know how to resolve this issue then  :-)
>
> "buffer in char handler" and "process in end tag handler" is
> How You Are Supposed To Do It.

Thanks for your reply and pointing out where I missed that small, but
significent part in the documentation. <sigh> Looks like I may have to go
back to the drawing board.

Some lessons are painful but those are the ones you don't forget.




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

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


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