[7050] in Perl-Users-Digest
Perl-Users Digest, Issue: 675 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jun 27 21:07:20 1997
Date: Fri, 27 Jun 97 18:02:03 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Fri, 27 Jun 1997 Volume: 8 Number: 675
Today's topics:
Re: Perl/CGI Scripting Ideas <psychic@globalserve.net>
Re: read serial port perl5 help? (Nathan V. Patwardhan)
removing same entry in different arrays? :/ (Calle ]sman)
Re: removing same entry in different arrays? :/ <sfairey@adc.metrica.co.uk>
Re: RFC: Xlib.pm (Randy J. Ray)
Re: SIGSEGV on HP-UX Oraperl (Perl 5.003) <Tim.Bunce@ig.co.uk>
Trickey Regex... need thoughts (Tracy Bednar)
Re: Trickey Regex... need thoughts <sfairey@adc.metrica.co.uk>
Re: Trickey Regex... need thoughts (Craig Berry)
Why warnings for this short script? <hell@puls02.desy.de>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 27 Jun 1997 08:17:40 +0000
From: Earl Curley <psychic@globalserve.net>
Subject: Re: Perl/CGI Scripting Ideas
Message-Id: <33B37723.43EB@globalserve.net>
TechMaster Pinyan wrote:
>
> I am a budding Perl scripter, who happens to be 15, and I need ideas for
> some web site utilities... I use AccessWatch for my Hit Stats, and I made
> a program called WebSite Stats which is comprised of WebStat (finds out
> how big your website is, how much percentage the top level directories
> take up, and when they were last updated) and WebTree (makes a tree of
> your html files in each directory, and lists their file size and how many
> images are in each file). I also have a chat program, a poll program and
> a guestbook program...
>
> I am making a CGI/Perl Script Archive for my school (www.bergen.org/AAST)
> and I want more web utility scripts. I have enough ideas for interactive
> scripts, but I want more utilities.
>
> I would really like it if any of you could give me some ideas... to
> decrease bandwidth, please email me, instead of cramming this newsgroup.
>
> Thanks... :)
>
> ----------------
> | "I don't contemplate it, I just sit and think about it."
> | - Sonia Balsky
> ----------------
> Jeff "TechMaster" Pinyan | http://www.bergen.org/~jefpin
> HTML/CGI Designer and Consultant and JavaScripter
> jefpin@bergen.org | TechMasterJeff@juno.com
> Got a JavaScript/CGI/Perl question or problem? Let me know!
> webXS - the new eZine for WebProgrammers! webXS@juno.com
> Visit us @ http://www.bergen.org/~jefpin/webXS
It was a pleasure visiting Jeff's web site. Being an old man (over 50)
who became a computer junkie and self-taught programmer I must say I'm
totally impressed with his work and his age to say the least.
It's great to see our younsters delve into the inner workings of perl,
etc. and create new programs and ideas and the more young people like
Jeff who try their hand at creating those programs the easier it is for
us old folks to install some great ideas on our web sites.
Jeff, if I come across anyone in your area who needs some good quality
expertise, you can be assured I'll forward your e-mail address to them.
I'd like to encourage all others to do the same because the Jeffs of
this world are our next generation of master-minds.
Keep up the good work, Jeff. For the others, no Jeff didn't pay for
this endoresement. LOL The kid has some great stuff and who knows what
the future inspiration will do to enhance his capabilities.
--
Earl Curley
psychic@globalserve.net
=========== Web.Design.Ca Inc =============
http://www.webdesign.ca/advertising.html
Psychic Discoveries Behind The Canadian Curtain
http://www.webdesign.ca/
The I.R.I.S. Chronicles
http://www.webdesign.ca/iris.html
The 21 Emotions Exercise
http://www.webdesign.ca/register/
=======================================
------------------------------
Date: 27 Jun 1997 14:06:17 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: read serial port perl5 help?
Message-Id: <5p0hcp$qb8@fridge-nf0.shore.net>
chg@jilacg.colorado.edu wrote:
: BTW, I attempted to implement the very interesting and relevant script
: sent in by Jim Buttafuoco, but it hangs on the "use POSIX" line, on my
: Win95 system. I am a little puzzled because a search of my system
I don't think it'll work under Windows 95, because Jim's script also
reads a tty (terminal). Unless Windows 95 / NT have a mystery tty, or
use something else as /dev/tty, I don't think the script can work in
the same way.
--
Nathan V. Patwardhan
nvp@shore.net
------------------------------
Date: 27 Jun 1997 12:18:57 +0200
From: md4calle@mdstud.chalmers.se (Calle ]sman)
Subject: removing same entry in different arrays? :/
Message-Id: <w7pafkcjqlq.fsf@grosse.mdstud.chalmers.se>
I have to arrays, one with url:s and one with the matching linkwords,
e.g. a link like this:
<a href="http://www.nowhere/">click here</a>
would be stored like this:
$links[0] = "http://www.nowhere/"
$linkwords[0] = "click here"
what I want is to remove duplicates of links in @links, but when I remove
the link I want to add the corresponging linkwords to the link-entry that is
left.
e.g. if I shall parser this:
<a href="http://www.nowhere/">click here</a>
<a href="http://www.nowhere/bogus.html">amazing link</a>
<a href="http://www.nowhere/">our home</a>
it will be stored like:
$links[0] = "http://www.nowhere/"
$linkwords[0] = "click here"
$links[1] = "http://www.nowhere/bogus.html"
$linkwords[1] = "amazing link"
$links[2] = "http://www.nowhere/"
$linkwords[2] = "our home"
i want to change it to be:
$links[0] = "http://www.nowhere/"
$linkwords[0] = "click here our home"
$links[1] = "http://www.nowhere/bogus.html"
$linkwords[1] = "amazing link"
preferably I want to do this after I parsed a whole side, I would like to
avoid to do those checkings while I put in a new link.
any ideas?
all best,
/Calle
------------------------------
Date: Fri, 27 Jun 1997 15:33:14 +0100
From: Simon Fairey <sfairey@adc.metrica.co.uk>
To: Calle ]sman <md4calle@mdstud.chalmers.se>
Subject: Re: removing same entry in different arrays? :/
Message-Id: <33B3CF2A.3F54@adc.metrica.co.uk>
Calle ]sman wrote:
>
> I have to arrays, one with url:s and one with the matching linkwords,
> e.g. a link like this:
> <a href="http://www.nowhere/">click here</a>
>
> would be stored like this:
>
> $links[0] = "http://www.nowhere/"
> $linkwords[0] = "click here"
>
> what I want is to remove duplicates of links in @links, but when I remove
> the link I want to add the corresponging linkwords to the link-entry that is
> left.
> e.g. if I shall parser this:
> <a href="http://www.nowhere/">click here</a>
> <a href="http://www.nowhere/bogus.html">amazing link</a>
> <a href="http://www.nowhere/">our home</a>
>
> it will be stored like:
>
> $links[0] = "http://www.nowhere/"
> $linkwords[0] = "click here"
> $links[1] = "http://www.nowhere/bogus.html"
> $linkwords[1] = "amazing link"
> $links[2] = "http://www.nowhere/"
> $linkwords[2] = "our home"
>
> i want to change it to be:
> $links[0] = "http://www.nowhere/"
> $linkwords[0] = "click here our home"
> $links[1] = "http://www.nowhere/bogus.html"
> $linkwords[1] = "amazing link"
>
> preferably I want to do this after I parsed a whole side, I would like to
> avoid to do those checkings while I put in a new link.
>
> any ideas?
>
> all best,
>
> /Calle
How about using an associative array with the link as the key rather
than generate the two original arrays.
i.e.
Assuming you have parsed the line and have $1 (link) and $2 (linkwords)
then you could do:
$links{$1} = "$links{$1} $2";
This will let you generate the info as you go.
If you have to have the data in two arrays then you could do the
following when you have parsed a whole side which will leave you with
the %LINKS associative array.
for( $i = 0; $i <= $#linkwords; $i++ ){
$LINKS{$links[$i]} = "$LINKS{$links[$i]} $linkwords[$i]"
}
Both of the above assume you do not need to extract the data in the same
order as it was read. ( I don't do much web page processing :) ).
Simon
------------------------------
Date: 27 Jun 1997 12:58:23 -0600
From: rjray@tremere.ecte.uswc.uswest.com (Randy J. Ray)
Subject: Re: RFC: Xlib.pm
Message-Id: <uowwwnfeuuo.fsf@tremere.ecte.uswc.uswest.com>
stephen@alias-2.pr.mcs.net (Stephen McCamant) writes:
> On 24 Jun 1997 20:17:23 -0600, Randy J. Ray
> <rjray@tremere.ecte.uswc.uswest.com> wrote:
> >* Why avoid using Xlib (or any of the X link libs)? Is there a reason to not
> > write the XS code as wrappers over the known Xlib?
>
> Conceptual difficulty. Writing XS is a complicated task. Xlib has hundreds
> of calls, with lots of callbacks and structures that would require more code
> to interface with. On my old computer, all the interface code generated
> would take several minutes to compile.
Well, the original poster noted that you would not even have to *link* with
Xlib-- what is the alternative, re-writing Xlib (or at least the X protocol)
from scratch?
Randy
--
===============================================================================
Randy J. Ray -- U S WEST Technologies IAD/CSS/DPDS Phone: (303)595-2869
Denver, CO rjray@uswest.com
"It's not denial. I'm just very selective about the reality I accept." --Calvin
------------------------------
Date: Fri, 27 Jun 1997 17:15:08 GMT
From: Tim Bunce <Tim.Bunce@ig.co.uk>
Subject: Re: SIGSEGV on HP-UX Oraperl (Perl 5.003)
Message-Id: <ECG2L9.295@ig.co.uk>
In article <867265338.5215@dejanews.com>, <peter_farabaugh@bdsi.com> wrote:
> We are trying to run oraperl on a HP-UX 10 machine.
> We get random but regular SEGVs and the following messages
> Unable to create sub name "" during global destruction
> Bad Free() ignored during global destruction
>
> The messages occur on every ora_logoff whether or not it core dumps. If
> we leave out the ora_logoff it dies when the lda goes out of scope.
Read the README file and do whatit says.
Tim.
------------------------------
Date: Fri, 27 Jun 1997 15:48:08 GMT
From: spectran@netcom.com (Tracy Bednar)
Subject: Trickey Regex... need thoughts
Message-Id: <spectranECFyK8.DBn@netcom.com>
I am trying to parse some db text files. They look like this:
clientname character(60,1) Not Null
action_item text(80,80,80,1) Not Null
date date(3) Not Null
The "Not Null" is optional. I am trying to grab the numbers between
(..) especially the first number.
I've come up with
$line =~ m/(.*\()(.*\,)(.*\))(.*)/;
and
$line =~ m/(.*\()(.*,)+(.*)/
where $line = one of the above lines. Niether regex works
correctly. It grabs up to the first "(" ok, but then the problems
occur.
I thought it would be something like, grab .* to each comma,
continue this until you reach ")", which would end the (..).
Each of these grabs goes into $2, $3, $4, etc. Then I can strip the
trailing character off.
Thnx,
- T
------------------------------
Date: Fri, 27 Jun 1997 17:42:31 +0100
From: Simon Fairey <sfairey@adc.metrica.co.uk>
To: Tracy Bednar <spectran@netcom.com>
Subject: Re: Trickey Regex... need thoughts
Message-Id: <33B3ED77.7DE1@adc.metrica.co.uk>
I wrote:
>
> Try this
>
> #!/bin/perl
> open(DB_FILE, 'db_filename') or die "Unable to open file: $!.";
> while(<DB_FILE>){
> # Extract the bit inside the parentheses.
> /^[^(]*\(([^)]*)/;
Or even simpler change above line to:
/.*\((.*)\)/;
Simon 'always over complicates things' Fairey
------------------------------
Date: 27 Jun 1997 17:42:19 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Trickey Regex... need thoughts
Message-Id: <5p0u1r$flu$2@marina.cinenet.net>
Tracy Bednar (spectran@netcom.com) wrote:
: I am trying to parse some db text files. They look like this:
:
: clientname character(60,1) Not Null
: action_item text(80,80,80,1) Not Null
: date date(3) Not Null
:
: The "Not Null" is optional. I am trying to grab the numbers between
: (..) especially the first number.
How best to approach this depends very strongly on the properties of the
text being parsed. I'll assume that, as in your three examples above,
the open-paren of interest is *always* the first open-paren in the line.
: I've come up with
: $line =~ m/(.*\()(.*\,)(.*\))(.*)/;
: and
: $line =~ m/(.*\()(.*,)+(.*)/
:
: where $line = one of the above lines. Niether regex works
: correctly. It grabs up to the first "(" ok, but then the problems
: occur.
:
: I thought it would be something like, grab .* to each comma,
: continue this until you reach ")", which would end the (..).
: Each of these grabs goes into $2, $3, $4, etc. Then I can strip the
: trailing character off.
Try thinking instead in terms of describing the part you want. If my
assumption above holds, such a description might be "An open paren, a
comma-separated list of numbers, then a close-paren."
My recommendation would be to use a regex to find the list of numbers,
then do post-processing on this list to get the individual numbers out;
this is far easier and simpler to express than trying to do it all at
once. So...
$_ = 'clientname character(60,1) Not Null';
if (/\(((?:\d+,?)+)\)/) {
my @nums = split /,/, $1;
print 'Number count: ', scalar(@nums), "\n";
print 'Numbers: ', join(' ', @nums), "\n";
}
else {
die "Can't find numbers on line: $_";
}
That regex is a bit confusing. There are three levels of parens: The
outermost are the literal parens, used to locate where to find the
numbers. The middle set are used to collect the comma-separated number
string into $1. The innermost parens (which use the grouping-only (?:
syntax to avoid collecting anything) match each 'piece' of the number
string: A one-or-more digit number, possibly followed by a comma.
Hope this helps!
---------------------------------------------------------------------
| Craig Berry - cberry@cinenet.net
--*-- Home Page: http://www.cinenet.net/users/cberry/home.html
| Member of The HTML Writers Guild: http://www.hwg.org/
"Every man and every woman is a star."
------------------------------
Date: Fri, 27 Jun 1997 14:54:24 +0200
From: Otto Hell <hell@puls02.desy.de>
Subject: Why warnings for this short script?
Message-Id: <Pine.HPP.3.95.970627144155.28930C-100000@puls02.desy.de>
Why do I get warnings for the following script?
#!/usr/local/bin/oraperl -w
$ENV{'ORACLE_HOME'} =3D .....
$ENV{'TWO_TASK'} =3D .....
$lda =3D &ora_login(.....) || die "$ora_errstr\n"=
;
$csr =3D &ora_open($lda, "select * from kollegen") || die "$ora_errstr\n"=
;
while (($NN, $VN, $KNo) =3D &ora_fetch($csr)) {
$nummer{$NN} =3D $KNo;
$vorn{$NN} =3D $VN;
}
&ora_close($csr) || die "$ora_errstr\n";
$csr =3D &ora_open($lda, "select * from weg") || die "$ora_errstr\n"=
;
$Kollegen_Nummer =3D "1";
$T =3D "1";
while (($Kollegen_Nummer, $T) =3D &ora_fetch($csr)) {
### print "\$Kollegen_Nummer =3D $Kollegen_Nummer, \$T =3D $T, \n";##### t=
est test
$weg2{"$Kollegen_Nummer.$T"} =3D "X"; # Das verkettet mit . im Schl=
=FCssel
# $weg2{ $Kollegen_Nummer.$T } =3D 'X'; # Das verkettet ohne . im Schl=
=FCssel
}
&ora_logoff($lda) || die "$ora_errstr\n";
print "fertig\n";
This produces:
Possible typo: "nummer" at zdv/weg/istweg/test.pl line 10.
Possible typo: "vorn" at zdv/weg/istweg/test.pl line 11.
Possible typo: "weg2" at zdv/weg/istweg/test.pl line 23.
Use of uninitialized variable at zdv/weg/istweg/test.pl line 23.
Use of uninitialized variable at zdv/weg/istweg/test.pl line 23.
=2E....
Use of uninitialized variable at zdv/weg/istweg/test.pl line 23.
Use of uninitialized variable at zdv/weg/istweg/test.pl line 23.
Use of uninitialized variable at zdv/weg/istweg/test.pl line 23.
fertig
Mit freundlichem Gruss / Greetings / Bien a vous Otto Hell
--
<Otto.Hell@desy.de> DESY - Abteilung ZDV
tel: 49 40 8998 2317 Notkestrasse 85
fax: 49 40 8994 2317 D 22603 Hamburg
------------------------------
Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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.misc (and this Digest), send your
article to perl-users@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.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
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 V8 Issue 675
*************************************