[24197] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 6389 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Apr 12 11:10:40 2004

Date: Mon, 12 Apr 2004 08:10:11 -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           Mon, 12 Apr 2004     Volume: 10 Number: 6389

Today's topics:
        searching a structured text data base <friendly@yorku.ca>
        searching a structured text data base <friendly@yorku.ca>
        striped name to variable <bill@hotmail.com>
    Re: striped name to variable (Sam Holden)
    Re: striped name to variable <ittyspam@yahoo.com>
    Re: What about this script?  HTML::Parser <tadmc@augustmail.com>
    Re: What about this script?  HTML::Parser <dannywork5@hotmail.com>
    Re: Where To Go For Classroom Training in CGI? <spamtrap@dot-app.org>
    Re: Why are arrays and hashes this way? (Xavier Noria)
    Re: Why are arrays and hashes this way? <uri@stemsystems.com>
    Re: Why does split operate over multiple lines in the a <krahnj@acm.org>
    Re: Why doesn't this UserAgent script work? <tadmc@augustmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 08 Apr 2004 14:01:50 -0400
From: Michael Friendly <friendly@yorku.ca>
Subject: searching a structured text data base
Message-Id: <c5442f$svp$1@sunburst.ccs.yorku.ca>

I have a LaTeX document composed of historical items with structured 
fields (on the history of data visualization, 
http://www.math.yorku.ca/SCS/Gallery/milestone/)

I'd like to create a web-based facility to provide searching of these 
items.  As a first step, I've written a perl script to translate the 
LaTeX stuff into various formats: tagged, CSV, HTML, XML.  But I don't 
know how to choose a data format and appropriate software tools to 
accomplish this most easily.

There's a bewildering array of perl modules for databases, XML, etc.
but I'm not sure what would be most useful in this context.  Can anyone
help point me in useful directions?  I'm doing this on a debian linux
system, and a solution involving software other than perl is possible.

For example, the tagged format looks like this:

KEY:    Ptolemy150
YEAR:   c. 150
WHAT:   Map projections of a spherical earth and use of latitude and 
longitude to characterize position (first display of   longitude)
WHO:    Claudius Ptolemy
WHERE:  Alexandria, Egypt
TXT:    http://portico.bl.uk/exhibitions/maps/ptolemy.html::Ptolemy's 
world map, description and high-res image::
TXT: 
http://www-groups.dcs.st-and.ac.uk/~history/Mathematicians/Ptolemy.html::Ptolemy 
history::
PIC:    /SCS/Gallery/images/portraits/ptolemy.gif::Ptolemy, portrait 
from ca. 1400 (90 x 109; 9K)::
FIG:    /SCS/Gallery/images/ptolemy-map.jpg::Ptolemy's world map, 
republished in 1482 (640 x 496; 40K)::
ADD:    11/22/00

and the XML format like this (I have a basic DTD):

<hdbitem key="Ptolemy150" added="11/22/00">
   <keywords>latitude,longitude,projection,map!projection</keywords>
   <description>Map projections of a spherical earth and use of latitude 
and longitude to characterize position (first display of   longitude)
   </description>
   <authors>
     <who first="Claudius" last="Ptolemy" lived="c. 85--c. 165">Claudius 
Ptolemy</who>
   </authors>
   <date from="c. 150" to="c. 150">c. 150</date>
   <where>Alexandria, Egypt</where>
   <commentary url="http://portico.bl.uk/exhibitions/maps/ptolemy.html" 
text="Ptolemy's world map, description and high-res image" />
   <commentary 
url="http://www-groups.dcs.st-and.ac.uk/~history/Mathematicians/Ptolemy.html" 
text="Ptolemy history" />
   <figure type="portrait" 
url="/SCS/Gallery/images/portraits/ptolemy.gif" height="109" width="90" 
size="9K">
      <caption>Ptolemy, portrait from ca. 1400</caption>
   </figure>
   <figure type="figure" url="/SCS/Gallery/images/ptolemy-map.jpg" 
height="496" width="640" size="40K">
      <caption>Ptolemy's world map, republished in 1482</caption>
   </figure>
</hdbitem>



-- 
Michael Friendly     Email: friendly@yorku.ca
Professor, Psychology Dept.
York University      Voice: 416 736-5115 x66249 Fax: 416 736-5814
4700 Keele Street    http://www.math.yorku.ca/SCS/friendly.html
Toronto, ONT  M3J 1P3 CANADA



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

Date: Fri, 09 Apr 2004 10:50:02 -0400
From: Michael Friendly <friendly@yorku.ca>
Subject: searching a structured text data base
Message-Id: <c56d6q$atr$1@sunburst.ccs.yorku.ca>

I have a LaTeX document composed of historical items with structured 
fields (on the history of data visualization, 
http://www.math.yorku.ca/SCS/Gallery/milestone/)

I'd like to create a web-based facility to provide searching of these 
items.  As a first step, I've written a perl script to translate the 
LaTeX stuff into various formats: tagged, CSV, HTML, XML.  But I don't 
know how to choose a data format and appropriate software tools to 
accomplish this most easily.

There's a bewildering array of perl modules for databases, XML, etc.
but I'm not sure what would be most useful in this context.  Can anyone
help point me in useful directions?  I'm doing this on a debian linux
system, and a solution involving software other than perl is possible.

For example, the tagged format looks like this:

KEY:    Ptolemy150
YEAR:   c. 150
WHAT:   Map projections of a spherical earth and use of latitude and 
longitude to characterize position (first display of   longitude)
WHO:    Claudius Ptolemy
WHERE:  Alexandria, Egypt
TXT:    http://portico.bl.uk/exhibitions/maps/ptolemy.html::Ptolemy's 
world map, description and high-res image::
TXT: 
http://www-groups.dcs.st-and.ac.uk/~history/Mathematicians/Ptolemy.html::Ptolemy 
history::
PIC:    /SCS/Gallery/images/portraits/ptolemy.gif::Ptolemy, portrait 
from ca. 1400 (90 x 109; 9K)::
FIG:    /SCS/Gallery/images/ptolemy-map.jpg::Ptolemy's world map, 
republished in 1482 (640 x 496; 40K)::
ADD:    11/22/00

and the XML format like this (I have a basic DTD):

<hdbitem key="Ptolemy150" added="11/22/00">
   <keywords>latitude,longitude,projection,map!projection</keywords>
   <description>Map projections of a spherical earth and use of latitude 
and longitude to characterize position (first display of   longitude)
   </description>
   <authors>
     <who first="Claudius" last="Ptolemy" lived="c. 85--c. 165">Claudius 
Ptolemy</who>
   </authors>
   <date from="c. 150" to="c. 150">c. 150</date>
   <where>Alexandria, Egypt</where>
   <commentary url="http://portico.bl.uk/exhibitions/maps/ptolemy.html" 
text="Ptolemy's world map, description and high-res image" />
   <commentary 
url="http://www-groups.dcs.st-and.ac.uk/~history/Mathematicians/Ptolemy.html" 
text="Ptolemy history" />
   <figure type="portrait" 
url="/SCS/Gallery/images/portraits/ptolemy.gif" height="109" width="90" 
size="9K">
      <caption>Ptolemy, portrait from ca. 1400</caption>
   </figure>
   <figure type="figure" url="/SCS/Gallery/images/ptolemy-map.jpg" 
height="496" width="640" size="40K">
      <caption>Ptolemy's world map, republished in 1482</caption>
   </figure>
</hdbitem>



-- 
Michael Friendly     Email: friendly@yorku.ca
Professor, Psychology Dept.
York University      Voice: 416 736-5115 x66249 Fax: 416 736-5814
4700 Keele Street    http://www.math.yorku.ca/SCS/friendly.html
Toronto, ONT  M3J 1P3 CANADA



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

Date: Mon, 12 Apr 2004 13:35:57 GMT
From: "blnukem" <bill@hotmail.com>
Subject: striped name to variable
Message-Id: <1Xwec.5948$467.1540351@news4.srv.hcvlny.cv.net>

Hi All

How do I strip a word out of a phrase and save the striped part as a
variable example:

$phrase = "My name is Nick<br>";
$phrase =~ s/Nick//is;

Now how do I set a new variable that equals the striped part "Nick"




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

Date: 12 Apr 2004 13:44:28 GMT
From: sholden@flexal.cs.usyd.edu.au (Sam Holden)
Subject: Re: striped name to variable
Message-Id: <slrnc7l79s.mk3.sholden@flexal.cs.usyd.edu.au>

On Mon, 12 Apr 2004 13:35:57 GMT, blnukem <bill@hotmail.com> wrote:
> Hi All
> 
> How do I strip a word out of a phrase and save the striped part as a
> variable example:
> 
> $phrase = "My name is Nick<br>";
> $phrase =~ s/Nick//is;
> 
> Now how do I set a new variable that equals the striped part "Nick"

$new_variable = 'Nick';

Or if we pretend Nick isn't a constant string:

if ($phrase =~ s/(Nick)//is) {
	$new_variable = $1;
}

-- 
Sam Holden


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

Date: Mon, 12 Apr 2004 09:51:56 -0400
From: Paul Lalli <ittyspam@yahoo.com>
Subject: Re: striped name to variable
Message-Id: <20040412094844.M27629@dishwasher.cs.rpi.edu>

On Mon, 12 Apr 2004, blnukem wrote:

> Hi All
>
> How do I strip a word out of a phrase and save the striped part as a
> variable example:
>
> $phrase = "My name is Nick<br>";
> $phrase =~ s/Nick//is;
>
> Now how do I set a new variable that equals the striped part "Nick"


Save your matches with parentheses, then access them with the $1, $2, $3,
 ... variables.

my $name;
if ($phrase =~ s/(Nick)//i){
	$name = $1;
}


run `perldoc perlre` and search for 'capture' for more info.

On an unrelated note, why are you using the /s modifier in your RegExp?
It serves no purpose here.

Paul Lalli


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

Date: Mon, 12 Apr 2004 01:23:09 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: What about this script?  HTML::Parser
Message-Id: <slrnc7kded.3l0.tadmc@magna.augustmail.com>

Danny <dannywork5@hotmail.com> wrote:

> How can I modify this so I can see the tags too.  I tried some examples, but
> could not get it to work.


Show us what you tried and we will help you fix it.


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


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

Date: Mon, 12 Apr 2004 14:14:15 GMT
From: "Danny" <dannywork5@hotmail.com>
Subject: Re: What about this script?  HTML::Parser
Message-Id: <Xuxec.6592$467.1639511@news4.srv.hcvlny.cv.net>


"Tad McClellan" <tadmc@augustmail.com> wrote in message
news:slrnc7kded.3l0.tadmc@magna.augustmail.com...
> Danny <dannywork5@hotmail.com> wrote:
>
> > How can I modify this so I can see the tags too.  I tried some examples,
but
> > could not get it to work.
>
>
> Show us what you tried and we will help you fix it.
>
>
> -- 
>     Tad McClellan                          SGML consulting
>     tadmc@augustmail.com                   Perl programming
>     Fort Worth, Texas

Hello Tad

My previous post has the script to try out.  I ran this and it works fine on
any html but I would like to extract out the tags and such. What do you
think?

Thanks




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

Date: Mon, 12 Apr 2004 09:29:49 -0400
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: Where To Go For Classroom Training in CGI?
Message-Id: <6v2dnaVR1r1aBOfdRVn-ig@adelphia.com>

Glenn Catlin wrote:

> I found a handful of local classroom training centers that offer
> PERL classes

I'd be wary of those. The proper name of the language is Perl, not PERL. It
might seem like a trivial thing, and in general I don't bother nit-picking
such things.

But think about it - how good can the class be if they can't even get the
name of the language right? Would you pay to send your developers to a
class on "C+++"?

I'm reminded of the TV commercials for a "multimedia designer" school, where
the background colors are horribly wrong for NTSC, and bleed all over the
place. Not the sort of thing I ordinarily care about - but from a training
center that claims to teach the very subject in which they're displaying
such blatant incompetence, it's unforgivable.

> Can anyone recommend a good training center in
> the U.S. for this?

Personally, I'd buy them an O'Reilly Safari subscription and tell them to
have at it. Most good programmers are adept at self-bootstrapping, and I've
yet to see a certification mill that's worth the kind of money they charge.

sherm--

-- 
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org


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

Date: 12 Apr 2004 03:08:59 -0700
From: fxn@hashref.com (Xavier Noria)
Subject: Re: Why are arrays and hashes this way?
Message-Id: <31a13074.0404120208.367c157f@posting.google.com>

Uri Guttman <uri@stemsystems.com> wrote in message news:<x7n05jhuyo.fsf@mail.sysarch.com>...

> and even without that, it makes very good sense. the problem with
> storing a real hash where a scalar is, is how do you store it? the slot
> in an SV can hold a single item (a scalar) so what would you put there
> to represent a hash? and if any of those hash elements was a hash, all
> memory hell breaks out. in c, you can only do multidim arrays of known
> element size. with perl you can have each thing at any level be any
> thing of any size. so the win is major flexibility at a cost of
> understanding and dealing with refs. not a bad tradeoff IMO.

In my opinion the reason cannot be only "because the slot is an SV". 

Why then arrays and hashes are data types that cannot be stored in
SVs? I guess there was some choice made when those data types were
defined that matters here. My question is why that initial choice was
done like that. Efficiency? No particular reason but historical
accident? Different goals than today for which those types were better
suited?

I think this is important to know. Being arrays and hashes first-class
citizens it kind of surprises to newcomers (like me when I learned
Perl5) that they cannot be nested. The class about structures should
have some comment like "You see we have all these high-level
structures so easily handled at the tips of our fingers, but because
of <<historical reasons>> they cannot be nested. We'll learn how to do
that when we see references."

-- fxn


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

Date: Mon, 12 Apr 2004 13:49:27 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Why are arrays and hashes this way?
Message-Id: <x77jwlgvbs.fsf@mail.sysarch.com>

>>>>> "XN" == Xavier Noria <fxn@hashref.com> writes:

  XN> Uri Guttman <uri@stemsystems.com> wrote in message news:<x7n05jhuyo.fsf@mail.sysarch.com>...

  >> and even without that, it makes very good sense. the problem with
  >> storing a real hash where a scalar is, is how do you store it? the slot
  >> in an SV can hold a single item (a scalar) so what would you put there
  >> to represent a hash? and if any of those hash elements was a hash, all
  >> memory hell breaks out. in c, you can only do multidim arrays of known
  >> element size. with perl you can have each thing at any level be any
  >> thing of any size. so the win is major flexibility at a cost of
  >> understanding and dealing with refs. not a bad tradeoff IMO.

  XN> In my opinion the reason cannot be only "because the slot is an SV". 

  XN> I think this is important to know. Being arrays and hashes first-class
  XN> citizens it kind of surprises to newcomers (like me when I learned
  XN> Perl5) that they cannot be nested. The class about structures should
  XN> have some comment like "You see we have all these high-level
  XN> structures so easily handled at the tips of our fingers, but because
  XN> of <<historical reasons>> they cannot be nested. We'll learn how to do
  XN> that when we see references."

then you need to learn some c. there is no easy way to truly nest stuff
without pointers in c. any tree of mixed structures must use
pointers. so now it comes to translating that to perl. how would you
assign a hash to a scalar slot? currently a hash or an array in a scalar
context (and this is mostly true in perl4) returns its size. do you make
a full copy during the assignment? how do you handle looped data? with
full copies and no references/pointers you can't have data loops. how
would you pass things around to subs, again with full copies? what does
it mean to assign an array which has arrays to another array? does it do
a flattening or a deep copy? you have many more questions like this to
answer and most of the answers suck for either efficiency reasons or
behavioral ones. trust me, larry knows what he is doing and by making
trees require refs he chose a good path. it meant very clean
compability, it made semantics clean and easy to explain. the only issue
is that it is a little harder for newbies to pick up the concepts of
refs in trees. but as with much of perl, it may be harder the first time
to learn it, but the payoff is massive time savings later for
experienced hackers. perl is meant to save development time, not be a
sop to newbies who want nested structures without having to think about
things and all the ugliness they have.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


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

Date: Mon, 12 Apr 2004 09:07:48 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Why does split operate over multiple lines in the absence of"ms" ?  And why doesn't $_ work with split?
Message-Id: <407A5C63.42AAF119@acm.org>

Paul Lalli wrote:
> 
> On Wed, 7 Apr 2004, Sara wrote:
> 
> > Also, along these same lines why isn't $_ taken as the default arg for
> > split, such that:
> >
> >    split /CAT/, $_;
> >
> > would be identical to
> >
> >    split /CAT/; # throws an error
> 
> What version of Perl are you using?  Even on 5.005, $_ *is* the default
> argument for split.  If you're getting an error doing
> split /CAT/;
> it's not because you didn't give split enough arguments.

Heck, even on Perl 1.0 $_ is the default.  :-)


John
-- 
use Perl;
program
fulfillment


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

Date: Mon, 12 Apr 2004 01:21:21 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Why doesn't this UserAgent script work?
Message-Id: <slrnc7kdb1.3l0.tadmc@magna.augustmail.com>

Tigerhillside <Tigerhillsideremove@removenetscape.net> wrote:

> I get the "Internal Server Error" response.

> (I tried comp.infosystems.www.authoring.cgi as well, I don't know
> if this is a Perl question or CGI.)


If the message you are getting does not appear in perldiag.pod,
then it is not a message from Perl.


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


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

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


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