[16718] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4130 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Aug 25 11:05:28 2000

Date: Fri, 25 Aug 2000 08:05:12 -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: <967215912-v9-i4130@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Fri, 25 Aug 2000     Volume: 9 Number: 4130

Today's topics:
        [ANNOUNCE] XML::XPath 0.98 <matt@sergeant.org>
    Re: ActiveState Perl NT Install Problem <elephant@squirrelgroup.com>
        ANNOUNCE: AI::NeuralNet::Mesh v0.31 <jdb@wcoil.com>
    Re: Callling Java method with Perl mr_curmudgeon@my-deja.com
        CGI / Registry question gorbor@my-deja.com
        CGI and perl Objects <dnichols@fhcrc.org>
        Closures? mr_curmudgeon@my-deja.com
    Re: Closures? <Allan@due.net>
    Re: Closures? <graham.wood@iona.com>
    Re: Closures? <timewarp@shentel.net>
    Re: Compiling Perl Modules <eric@urbanrage.com>
        DBI export to file <loadc@my-deja.com>
    Re: Extracting a number of lines in a text file (Hasanuddin Tamir)
    Re: Extracting a number of lines in a text file <abe@ztreet.demon.nl>
    Re: Extracting a number of lines in a text file (Keith Calvert Ivey)
        fortunes.tar.gz: where can I get it? (Michael Wang)
    Re: Just another silly post. (Keith Calvert Ivey)
    Re: Just another silly post. <thunderbear@bigfoot.com>
    Re: newbie question about "uninitialized variables" (Jon S.)
        Preserving HTML entities when HTML:: parsed <ianm@nofusswebsites.com>
    Re: RegEx (Keith Calvert Ivey)
    Re: Replace "XYZ" but not "ABCXYZ"??? - HELP!! <elephant@squirrelgroup.com>
    Re: Stumped by Reg Exp Problem - help?? <elephant@squirrelgroup.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Fri, 25 Aug 2000 15:10:03 +0100
From: Matt Sergeant <matt@sergeant.org>
Subject: [ANNOUNCE] XML::XPath 0.98
Message-Id: <sqcvrf9kt9135@corp.supernews.com>

NAME
        XML::XPath - implementation of the W3C's XPath in Perl

DESCRIPTION

XML::XPath allows you to either locate nodes in an XML document tree, or
detect whether a node matches an XPath expression in a particular context
(as described in the XSLT specification). This allows you to build very
powerful XML based applications in just a few lines of code. For example, to
locate all href attributes on all <a> tags in an XML document, this is all
you need to do:

  use XML::XPath;
  my $xp = XML::XPath->new(filename => $filename);
  my @nodes = $xp->findnodes('//a/@href');

The syntax of XPath is fully described in the XPath spec at
http://www.w3.org/TR/XPath, and also an introductory tutorial is available
on the web site http://www.zvon.org/

XML::XPath implements a DOM like API for nodes. It doesn't use XML::DOM
because this module does not support namespaces at this time, and some
features would be extremely hard to implement with XML::DOM (such as node
sorting). Unlike XML::DOM, XML::XPath document tree's are garbage collected
when they go out of scope.

CHANGES

This version is now 99% compliant with the full XPath specification, the
only missing functionality appears to be support for IEEE numbers (such as
negative zero, and positive and negative infinity). There have been numerous
performance enhancements along the way, and XML::XPath is now fast enough
for interactive web based applications.

-- 
<Matt/>

Fastnet Software Ltd. High Performance Web Specialists
Providing mod_perl, XML, Sybase and Oracle solutions
Email for training and consultancy availability.
http://sergeant.org | AxKit: http://axkit.org




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

Date: Fri, 25 Aug 2000 13:25:39 GMT
From: jason <elephant@squirrelgroup.com>
Subject: Re: ActiveState Perl NT Install Problem
Message-Id: <MPG.1411114270f695c39896ed@localhost>

coder3555@my-deja.com <coder3555@my-deja.com> wrote ..
>Hi, I've got a problem trying to install Active State's Perl for NT
>implementation v5.6.  Here's the scenario:
>
>I had Windows NT v4.0 SP3 installed.  I downloaded the two files:
>
>  InstMsi.exe
>  ActivePerl-5.6.0.616-MSWin32-x86-multi.msi
>
>And then ran the InstMsi.exe from Explorer.
>
>Well, I didn't read the ActiveState install instructions first, which
>state I need at *least* SP4.  rtfm, right?  Okay, so I installed SP5 and
>re-did the install.
>
>The Windows Installer states that it completed sucessfully, but in fact
>it did not install anything.  I tried to remove registry entries related
>to Perl and tried to reinstall to no avail.
>
>Can anybody help me?

yep .. ActiveState .. it's their installer - and in the absence of 
anyone here with that specific problem - they're your best bet for a 
resolution

-- 
  jason -- elephant@squirrelgroup.com --


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

Date: 25 Aug 2000 08:49:41 GMT
From: "Josiah Bryan" <jdb@wcoil.com>
Subject: ANNOUNCE: AI::NeuralNet::Mesh v0.31
Message-Id: <sqcu6v3dt9143@corp.supernews.com>

Greetings!

Announcing the release of:

    AI::NeuralNet::Mesh, version 0.31

(AI::NeuralNet::Mesh is an optimized, accurate neural network Mesh
written in Perl.)

Download at: (***recomended download url***):
http://josiah.countystart.com/modules/get.pl?mesh:clpa

This module has also been released on the CPAN as:
   file: $CPAN/authors/id/J/JB/JBRYAN/AI-NeuralNet-Mesh-0.31.zip
  size: 82087 bytes


** What's new?

>From the POD:
This is version *0.31*, the second release of this module.

In this version, I have included three major features. Also in this
release I have included two minor fixes which increase the learning
speed of networks. I also fixed a bug in the load_pcx() method which
prevented it from loading the PCX::Loader module correctly. This
version also has the ability to have negative weights in the network.

The major features added are:

LAYER SIZES

Rodin Porrata once suggested it would be good to have control over
each layer's node size. Well, Rodin, here you go. Each layer can
have a custom number of nodes, which you can set in two ways, detailed
in the new() constructor, below. Layer sizes are preserved across load()
and save() calls.

LAYER EXTENSION

With the ability to have custom layer sizes, I have also included the
ability to extend layer sizes after network construction. You can add
nodes with extend() or extend_layer() after the network is constructed
or loaded.


CUSTOM NODE ACTIVATION

Ahh, and another treat. You can choose from one of four activation
functions and set the activation function by layer, or you can even
set each individual node to a seperate activation function. Possible
activation types are:
        'linear' (simply transfer sum of inputs as output)
        'sigmoid' (also called 'sigmoid_1') (0 or 1, threshold based)
        'sigmoid_2' (-1,0,1, threshold based)
        user specified (passed as a CODE ref.)

You can also customize threshold levels on a per-layer, or per-node basis.

** What is this?

AI::NeuralNet::Mesh is an optimized, accurate neural network Mesh
written in Perl. It was designed with accruacy and speed in mind.
This better learning accuracy (by twenty-three percent), as well
as a much faster learning rate and run speed over any other neural
network simulater that I know of in Perl.(*)

Included are fifteen seperate example scripts. In particular demonstration
of the accuracy and speed of this network model, check out ex_add2.pl,
ex_dow.pl, and ex_add.pl.

As always, included is a cleaned, CSS-ed, HTML-format of the POD docs.


** What do you think?

Now I know you people are out there that are using the module...
I can hear the fists hitting the keyboards in frustration. :-) Relieve
some of that frustration by e-mailing me and letting me know what
you think of the module and any suggestions you got.

Use it, let me know what you all think. This is just a
groud-up write of a neural network, no code stolen or
anything else. Don't expect a classicist view of nerual
networking here. I simply wrote from operating theory,
not math theory. Any die-hard neural networking gurus out
there? Let me know how far off I am with
this code! :-)

Regards,

        ~ Josiah Bryan, <jdb@wcoil.com>


(*) In regards to the speed claim: I only know of two neural networks
in Perl, AI::NeuralNet::Mesh (this module) and AI::NeuralNet::BackProp,
both of which I wrote. If someone else has written a neural-net in Perl
I would love to see how or what techniques you have used. I am sorry if
I have missed anybody's Perl neural-net. If I have, it was not an
intentional error on my part.

--
Josiah Bryan
VP of Product Development
TDCJ, Inc.
"Anything is possible."

vp@tdcj.com
http://www.josiah.countystart.com/

Tel: 937.316.6256






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

Date: Fri, 25 Aug 2000 13:21:36 GMT
From: mr_curmudgeon@my-deja.com
Subject: Re: Callling Java method with Perl
Message-Id: <8o5rsc$gq9$1@nnrp1.deja.com>

In article <Kyvo5.167322$1h3.3068407@news20.bellglobal.com>,
  "Etienne Laverdiere" <info@digitaltango.com> wrote:
> Hi all,
>
> can I call a Java Method from a Perl script?
>

http://www.w3.org/TR/SOAP/

http://www.perl.com/CPAN/modules/by-module/SOAP/

http://xml.apache.org/soap/index.html





Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Fri, 25 Aug 2000 13:42:55 GMT
From: gorbor@my-deja.com
Subject: CGI / Registry question
Message-Id: <8o5t4q$ihh$1@nnrp1.deja.com>

Anyone know how to write a CGI script that will read the registry to
determine the name and location of the data file in order to upload it
 ... ???

Also, anyone know a good FTP script?


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Fri, 25 Aug 2000 13:19:10 -0700
From: Douglas Nichols <dnichols@fhcrc.org>
Subject: CGI and perl Objects
Message-Id: <39A6D4BE.D3BDA7E3@fhcrc.org>

I have a little object called obj. When I create it( my $obj1 = new
obj(); ) using the one of the new methods listed below I get
dramatically diffferent results- like the fields are completely
incorrect in the first example. Would someone tell me why example one
doesn't work?

Thanks

sub new {
    my $self = shift;
    my $cgi = new CGI;
    $self = {
        MODE   => $cgi->param('mode'),
        ACTION => $cgi->param('action'),
        PILL       => $cgi->param('pill'),
    };
    bless $self;
    $self->showFields();
}

sub new {
    my $self = shift;
    my $cgi = new CGI;
    $self = {
        MODE   => undef,
        ACTION => undef,
        PILL       => undef,
    };
    bless $self;
    $self->{MODE}   = $cgi->param('mode'),
    $self->{ACTION} = $cgi->param('action'),
    $self->{PILL}      = $cgi->param('pill'),
    $self->showFields();
}


--
Cheers, dn

Douglas Nichols                              dnichols@fhcrc.org
---------------------------------------------------------------
National Wilms Tumor Study Group                   206.667.4283
Seattle, WA





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

Date: Fri, 25 Aug 2000 12:59:06 GMT
From: mr_curmudgeon@my-deja.com
Subject: Closures?
Message-Id: <8o5qig$f3a$1@nnrp1.deja.com>

Is it

knit 1, perl 2

or

perl 1, knit 2

I'm never gonna get this sweater done unless I figure it out!


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Fri, 25 Aug 2000 10:21:47 -0400
From: "Allan M. Due" <Allan@due.net>
Subject: Re: Closures?
Message-Id: <8o5vfh$44h$1@slb2.atl.mindspring.net>

<mr_curmudgeon@my-deja.com> wrote in message
news:8o5qig$f3a$1@nnrp1.deja.com...
: Is it
: knit 1, perl 2
: or
: perl 1, knit 2
: I'm never gonna get this sweater done unless I figure it out!

#! /usr/local/bin/perl -w
use strict;
sub get_closure {
    my $perl =0;
    return sub {
        return $perl+=2;
    };
}

sub sweater_work {
    my $knit = 0;
    return sub {
        my $sweater = shift;
        foreach (1..5) {
            $knit++;
            print "knitted $knit, perled ",&$sweater,"\n";
        }
        return $knit;
    }
}
my $sweater1  = get_closure;
my $sweater2  = get_closure;
my $work_on_sweater1  = sweater_work;
my $work_on_sweater2  = sweater_work;

&$work_on_sweater1($sweater1);
print "worked on sweater 1\n\n";
&$work_on_sweater2($sweater2);
print "worked on sweater 2\n\n";
&$work_on_sweater1($sweater1);
print "worked on sweater 1\n\n";
&$work_on_sweater2($sweater2);
print "worked on sweater 2\n\n";

HTH

AmD
--
$email{'Allan M. Due'} = ' All@n.Due.net ';
--random quote --
"How can you think and hit at the same time?"
 - Yogi Berra




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

Date: Fri, 25 Aug 2000 15:24:11 +0100
From: "Graham Wood" <graham.wood@iona.com>
Subject: Re: Closures?
Message-Id: <8o5vva$r48$1@bvweb.iona.com>

knit wit


<mr_curmudgeon@my-deja.com> wrote in message
news:8o5qig$f3a$1@nnrp1.deja.com...
> Is it
>
> knit 1, perl 2
>
> or
>
> perl 1, knit 2
>
> I'm never gonna get this sweater done unless I figure it out!
>
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.




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

Date: Fri, 25 Aug 2000 11:00:46 -0400
From: Albert Dewey <timewarp@shentel.net>
Subject: Re: Closures?
Message-Id: <39A68A1D.F1EC4738@shentel.net>

Try -

foreach $perl(@knit)
    {
    if(knit_1)
        {
        perl_2;
        }
    }

> <mr_curmudgeon@my-deja.com> wrote in message
> news:8o5qig$f3a$1@nnrp1.deja.com...
> > Is it
> >
> > knit 1, perl 2
> >
> > or
> >
> > perl 1, knit 2
> >
> > I'm never gonna get this sweater done unless I figure it out!
> >
> >
> > Sent via Deja.com http://www.deja.com/
> > Before you buy.



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

Date: Fri, 25 Aug 2000 09:06:14 -0500
From: eric <eric@urbanrage.com>
Subject: Re: Compiling Perl Modules
Message-Id: <39A67D56.873CA6BA@urbanrage.com>

Sven Khatri wrote:
> 
> I have a perl module, foobar.pm, that I'm trying to compile.
> so I run perlcc foobar.pm. This generates a share object,
> foobar.so. I move the shared object to auto/foobar/ and
> write a perl wrapper around the shared object using DynaLoader
> and bootstrap. This perl wrapper replaces the original foobar.pm.
> This code works fine.
> 
> When I modify the original foobar.pm to specify a namespace,
> 
> package baz::foobar;
> 
> and repeat the above when I call foobar it can't find the shared
> object so I move the shared object to:
> 
> /usr/lib/perl5/site_perl/5.005/i386-linux/auto/baz/foobar/
> 
> which is where all the other perl .so files reside. At this point
> I get the following error:
> 
> Can't find 'boot_baz__foobar' symbol in
> /usr/lib/perl5/site_perl/5.005/i386-linux/auto/baz/foobar/foobar.so
> 
> Any ideas of what I'm doing wrong? How things are different when
> a namespace is specified? Pointer to a good reference for how to
> compile perl modules?
> 
> thanx...
> 
> Sven

you might want to consider using h2xs to generate the base perl module. 
it creates the directory structure and a makefile that places things in
the appropriate directories when it compiles, taking care of the problem
for you.

example (perl module no underlying c)

h2xs -n baz::foobar -X -f

This would create baz/foobar and in foobar it would make foobar.pm
Changes, MANIFEST, test.pl and Makefile.PL

at this point edit foobar.pm to be whatever it is you want it to be (the
h2xs provides a nice framework to put code into).

then perl Makefile.PL followed by make

you modify test.pl to exercise your module then make test to run these
tests.  alternatively you can make a t directory and put your tests
there.

Hope this helped,

Eric
  eric@urbanrage.com


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

Date: Fri, 25 Aug 2000 14:02:46 GMT
From: loadc <loadc@my-deja.com>
Subject: DBI export to file
Message-Id: <8o5u9o$jvr$1@nnrp1.deja.com>

Hello-

     Sort of a newbie question:

       What do I use to export to a text file in the DBI?  I have seen
examples for lo_export, this is the large object export with format
options for BLOBs (as far as I am aware).  Can I use 'export'?  If so,
what are the format options, do I need any (apparently I do, it failed
without)?  Thanks for any help,

                     loadc


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Sat, 26 Aug 2000 03:07:35 GMT
From: hasant@trabas.co.id (Hasanuddin Tamir)
Subject: Re: Extracting a number of lines in a text file
Message-Id: <slrn8qcqfi.nh3.hasant@borg.intern.trabas.co.id>

On Fri, 25 Aug 2000 13:21:45 +0200, Ulrich Ackermann <uackermann@orga.com>
wrote:
## Ulrich Ackermann wrote:
## > 
## > 
## > while (<INFILE>) {
## >         $_ =~ /^+(.*)/;
##                  ^^^
## 
## of course, here is a backslash missing:
##          $_ =~ /^\+(.*)/;
## 

Not enough, the OP wanted a single whitespace after
the + to be eliminated as well.


san
-- 
trabasLabs * hasant@trabas.com * http://www.trabas.com
Zero Point * hasant@zp.f2s.com * http://www.zp.f2s.com


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

Date: Fri, 25 Aug 2000 15:37:13 +0200
From: Abe Timmerman <abe@ztreet.demon.nl>
Subject: Re: Extracting a number of lines in a text file
Message-Id: <npscqso4g5hj70obn1al86nr3cn7rbngbg@4ax.com>

On Fri, 25 Aug 2000 10:30:26 GMT, Hasanuddin Tamir <hasant@trabas.com>
wrote:

> In article <8o5drh$b91$1@perki.connect.com.au>,
>   "Minh Le" <lem@ocean.com.au> wrote:
> > Hi,
> > I have been strucgling, from my perl script,  to extract a number of
> text
> > lines from a file and them to a new file.
> > The text string that I would like to extract,  always starts with a +
> sign
> > and then has a whitespace then the rest is a text  (ie +  hello I need
> > help..)
> > and when it writes to these text strings to a new file, I need to drop
> the
> > "+" sign and only add the rest of the text strings to the new file.
> > Please help !!!
> >
> 
> Iterate the file and for each line,
> 
>   s/^\+ //;
> 
> In case you the file directly modified instead of printing
> the modification to the new file you can use the inplace-edit
> at command line,
> 
>   perl -pi.bak -e 's/^\+ //' filename

Nope, that prints all the lines in the file and not just the ones
starting with '+ '.

It also renames the original file which wasn't the intension as I
understand it.

	perl -ne 's/^\+ // and print' oldfile > newfile

or to remove all leading white space after the '+' sign:

	perl -ne 's/^\+\s+// and print' oldfile > newfile

-- 
Good luck,
Abe


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

Date: Fri, 25 Aug 2000 14:09:47 GMT
From: kcivey@cpcug.org (Keith Calvert Ivey)
Subject: Re: Extracting a number of lines in a text file
Message-Id: <39b17d6a.41270171@news.newsguy.com>

"Minh Le" <lem@ocean.com.au> wrote:

>The text string that I would like to extract,  always starts with a + sign
>and then has a whitespace then the rest is a text  (ie +  hello I need
>help..)
>and when it writes to these text strings to a new file, I need to drop the
>"+" sign and only add the rest of the text strings to the new file.

This can be done from the command line:

    perl -ne "print if s/^\+ //" old_file > new_file

or possibly

    perl -ne "print if s/^\+\s+//" old_file > new_file

depending on exactly what you mean by "a whitespace" (your
example has two spaces, but maybe you want to keep the second).

-- 
Keith C. Ivey <kcivey@cpcug.org>
Washington, DC


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

Date: Fri, 25 Aug 2000 13:07:59 GMT
From: mwang@mindspring.com (Michael Wang)
Subject: fortunes.tar.gz: where can I get it?
Message-Id: <Pcup5.56$VK3.18077@wdc-read-01.qwest.net>

The link on Perl Power Tool does not have public permission,
so where can I get fortunes.tar.gz? Email reply is also
welcome. Thanks. 


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

Date: Fri, 25 Aug 2000 13:08:46 GMT
From: kcivey@cpcug.org (Keith Calvert Ivey)
Subject: Re: Just another silly post.
Message-Id: <39ad6f48.37651324@news.newsguy.com>

mgjv@tradingpost.com.au (Martien Verbruggen) wrote:

>$ ls -a
>.  ..  ...  ..foo  ..foo..  .foo  .foo.  foo.  foo..
>$ perl -wle 'print for (grep !m!/\.\.?$!, glob("./* ./.*"))'
>./foo.
>./foo..
>./...
>./..foo
>./..foo..
>./.foo
>./.foo.
>$
>
>I'm wondering which sorts of file names this would get rid of, or did
>you miss the '/' at the start of the regexp? I find that hard to believe
>from the queen of the YAPH.

I believe the file names Abigail was referring to end in
newlines.

-- 
Keith C. Ivey <kcivey@cpcug.org>
Washington, DC


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

Date: Fri, 25 Aug 2000 15:51:28 +0200
From: =?iso-8859-1?Q?Thorbj=F8rn?= Ravn Andersen <thunderbear@bigfoot.com>
Subject: Re: Just another silly post.
Message-Id: <39A679E0.67E2CCC2@bigfoot.com>

Policy Man wrote:

> I am aware of the <> operator. I just don't see how it fits with the requirements I made.

He moved the actual work out of the restricted domain.

-- 
  Thorbjørn Ravn Andersen         "...plus...Tubular Bells!"
  http://bigfoot.com/~thunderbear


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

Date: Fri, 25 Aug 2000 14:24:54 GMT
From: jonceramic@nospammiesno.earthlink.net (Jon S.)
Subject: Re: newbie question about "uninitialized variables"
Message-Id: <39a67fab.3334402@news.earthlink.net>

On 23 Aug 2000 21:46:17 GMT, Ilmari Karonen <iltzu@sci.invalid> wrote:

>In article <39a403ac.13574088@news.earthlink.net>, Jon S. wrote:
>>On 23 Aug 2000 14:20:37 GMT, Ilmari Karonen <iltzu@sci.invalid> wrote:
>>>The latest version of CGI::Carp (1.20) includes a patch I wrote that
>>>adds this feature.  See http://search.cpan.org/search?dist=CGI.pm
>>
>>Now let's see if my webhoster has that version installed.  *sigh*
>
>If not, you can always use your own copy.
>
>First you should make a module directory, /home/username/perlmod or
>anything else you may wish to call it.  You could now install the
>whole CGI distribution according to the standard procedure, giving
>that directory as the install prefix.  However, as CGI::Carp needs no
>special installation, you could also just extract the file from the
>archive and copy it to /home/username/perlmod/CGI/Carp.pm .
>
>In your script, you'd simply write:
>
>  use lib '/home/username/perlmod';
>  use CGI::Carp qw(fatalsToBrowser warningsToBrowser);

Okay, I think I've got it, but it looks like you've got a nested
instruction there...  :)

My webhoster only has CGI.pm 2.49 installed.  So, I went searching,
and after a brief download of cgi-modules v. 2.76, I found CGI.pm
2.72.  Like you said, Carp.pm can live independent of the entire world
of CGI.pm (I didn't see any calls for pm's outside of it...).

But, to use it, I'd just need to place Carp.pm in my cgi-bin, and call
it via a... 
use Carp qw(fatalsToBrowser); 
#with 'fatalsToBrowser(1);' inserted later

Rather than the...
>  use lib '/home/username/perlmod';
>  use CGI::Carp qw(fatalsToBrowser warningsToBrowser);
 ...you listed at the end of the message, which applies only if I can
actually install the entire module locally.  

Right?  (Just making sure I understand before I do something dumb...)

Thanks again,

Jon


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

Date: Fri, 25 Aug 2000 15:54:43 +0100
From: "Ian McDonald at No Fuss Websites.com" <ianm@nofusswebsites.com>
Subject: Preserving HTML entities when HTML:: parsed
Message-Id: <39a6889e@news.server.worldonline.co.uk>

This deletes the HTML entities;

$tree = HTML::Parse::parse_html( $text );
$text = $tree->as_HTML;

What can I do to preserve them?

Thanks,

Ian

--
Dr. Ian McDonald
Web Site Developer
No Fuss Websites.com
T: +44 (0) 20 761 32110  F: +44 (0) 20 769 25461
E: ianm@nofusswebsites.com W: www.nofusswebsites.com




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

Date: Fri, 25 Aug 2000 13:27:41 GMT
From: kcivey@cpcug.org (Keith Calvert Ivey)
Subject: Re: RegEx
Message-Id: <39af72bf.38538255@news.newsguy.com>

zejames@my-deja.com wrote:

>But I think I don't really understand what it does. I thought that
>being greedy means, with    m#/(.*)#
>
>  /(usr/local/bin/perl)   matches
>  /usr/(local/bin/perl)   matches too
>  /usr/local/(bin/perl)   matches :-))
>  /usr/local/bin/(perl)   matches
>
>  How does it choose between all this possibilities. Can anyone tell
>what it really does internally?

The match attempt stops after the first of the four above, so
the other three aren't even considered.  The regular expression
engine takes the first (leftmost) match it finds, making it as
long as possible.

By the way, I think Martien Verbruggen misunderstood what you
were doing above -- unless I did.  I'm assuming the four lines
are listing possible matches (marked by parentheses) for the
parenthesized part of the regex m#/(.*)#.  Martien thought they
were alternative regular expressions.

If you're really interested in the details of regular
expressions, you might want to get Jeffrey E.F. Friedl's book
"Mastering Regular Expressions" (O'Reilly).  It doesn't include
the newer features in Perl regular expressions, though.

-- 
Keith C. Ivey <kcivey@cpcug.org>
Washington, DC


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

Date: Fri, 25 Aug 2000 13:23:59 GMT
From: jason <elephant@squirrelgroup.com>
Subject: Re: Replace "XYZ" but not "ABCXYZ"??? - HELP!!
Message-Id: <MPG.141110e494b4deff9896ec@localhost>

Keith Calvert Ivey <kcivey@cpcug.org> wrote ..
>Stephen Kloder <stephenk@cc.gatech.edu> wrote:
>>Marcus wrote:
>>
>>> I am having some trouble using regular expressions to search and
>>> replace.  The problem is that I want to replace the occurrence
>>> of "\w+@\w+\.\S+" (i.e. any email address like jack@whatever.com) with
>>> some other text, but if "\w+@\w+\.\S+" is preceded by "XYZ"
>>> (i.e. "XYZjack@whatever.com") then I DO NOT want the replacement to
>>> take place.
>[snip]
>>s/(?<!XYZ)\w+@\w+\.\S+/WHATEVERTEXT/ should do the trick.
>
>Did you try it?  An e-mail address that starts with 'XYZ' is
>preceded by something that doesn't match 'XYZ'.
>
>    #!/usr/bin/perl -w
>    use strict;
>    $_ = 'XYZjack@whatever.com';
>    s/(?<!XYZ)\w+@\w+\.\S+/WHATEVERTEXT/;
>    print;
>
>The output is 'XYZjack@whatever.com'.
>
>One possibility is
>
>    s{(\w+@\w+\.\S+)}
>     { substr($1, 0, 3) eq 'XYZ' ?
>           $1 :
>           'WHATEVERTEXT' }e;

eww .. that's a smelly WTDI .. even if you're trying to conform to some 
sort of "everything must be done within a s///" then you've already got 
everything in the regex in $_ (or something else assuming the =~ 
operator somewhere) so why capture it to test it ?

I don't know why everyone would try to cram everything into the regex 
when Perl maps so perfectly onto the pseudo-code of

  make the substitution unless it begins with 'XYZ'

with

  s/\w+@\w+\.\S+/WHATEVERTEXT/ unless substr( $_, 0, 3) eq 'XYZ';

>Of course, the regex doesn't match e-mail addresses very well.

a fact that I hope doesn't get lost in all our tomfoolery ;)

-- 
  jason -- elephant@squirrelgroup.com --


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

Date: Fri, 25 Aug 2000 13:43:30 GMT
From: jason <elephant@squirrelgroup.com>
Subject: Re: Stumped by Reg Exp Problem - help??
Message-Id: <MPG.1411157b594a1c349896ee@localhost>

Eli the Bearded <elijah@workspot.net> wrote ..
>In comp.lang.perl.misc, Scott <shamilton@plateausystems.holdthespam.com> wrote:
>> In short, I want to be able to quickly scan through a file and convert all
>> web http addresses into HTML links.  So far, this is fairly easy (after much
>> experimentation I came up with $data =~
>> s/(http:\/\/[\w\/\-~]*(\.[\w\/\-~]+)+)/<a href="$1">$1<\/a>/ig).
>
>http://www.example.com:8080/	valid URL broken by that
>
>http://___~-./			invalid URL accepted by that
>
>Maybe you want something more like
>
>    s!(https?:// 					# scheme
>	(?: [^:]+ (?: : [^@]+ )? @ ) ?			# username/password
>	(?: [a-z0-9] (?: [a-z0-9]+ | -[a-z0-9] )* \. )+ # hostname fragment
>	(?: [a-z0-9] (?: [a-z0-9]+ | -[a-z0-9] )*    )  # top level domain
>        (?: : \d+ )?					# port number
>	(?: / \S* ) ? 					# local part
>	(?= [.>'"\s] | $ )				# probable boundary
>      ) !<a href="$1">$1</a>!xig;
>
>I specifically avoid things like "http://www/file.html" but do allow
>"http://www.internal/file.html" for subdomains that may just work
>for you.

http://www/ works for me .. and http://localhost/ works for a great deal 
more people than that .. requiring a period in the host name is going to 
break far more anchors than allowing http://___~-./

>> Here's what I can't figure out, though: if the link in question is ALREADY
>> formatted as an HTML link, then I don't want to perform the conversion,
>> otherwise things get REAL messy.
>
>Surround the above with:
>
>     if (!/<a \s+ [^>]* \b href=/i) {
>	# s!!!xig here
>     }

oops

  <a href = "http://www.pedantic.com/">Pedantic</a>

HTML::Parser to the rescue .. check it out at a CPAN near you

-- 
  jason -- elephant@squirrelgroup.com --


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

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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 V9 Issue 4130
**************************************


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