[16593] in Perl-Users-Digest
Perl-Users Digest, Issue: 4005 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Aug 14 00:06:32 2000
Date: Sun, 13 Aug 2000 21:05:11 -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: <966225911-v9-i4005@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Sun, 13 Aug 2000 Volume: 9 Number: 4005
Today's topics:
Re: - Free ebooks and resources - <info@sevensoft.net>
Re: - Free ebooks and resources - <jeff@vpservices.com>
Re: Byte compiling ... (got lost in perldocs and CTAN) <mskNOmsSPAM@unipress.com.invalid>
Re: CGI : CheckBox and Form Question (Keith Calvert Ivey)
CHOMP not working <vrillusions@mail.com>
Re: Convert URLs to links (Keith Calvert Ivey)
Re: Get the Time (Logan Shaw)
Re: how can I optimize a tied hash for speed (Logan Shaw)
Re: London =?iso-8859-1?Q?=A330-35K?= Perl Programmers (John Hascall)
Re: Need some debuging help <vrillusions@mail.com>
Re: Need some debuging help <vrillusions@mail.com>
Re: Need some debuging help <vrillusions@mail.com>
Re: Need some debuging help (Keith Calvert Ivey)
Re: Negativity in Newsgroup -- Solution (Randal L. Schwartz)
Pattern Matching Question <davidwebb@MailAndNews.com>
Re: Printing a Thread with HTML Lists (Thorfinn)
Re: Problems creating a new module based off HTML::Pars <shawn@secludedgrove.com>
Re: Procmail vs Perl. <elephant@squirrelgroup.com>
Re: set variable to results of regex <glued2NOglSPAM@hotmail.com.invalid>
Re: set variable to results of regex <katz@underlevel.net>
Re: set variable to results of regex (Mike Stok)
tag parsing. johnvert@my-deja.com
Re: tag parsing. (fvw)
Re: tag parsing. <philipg@atl.mediaone.net>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 13 Aug 2000 22:30:45 -0400
From: "sevensoft" <info@sevensoft.net>
Subject: Re: - Free ebooks and resources -
Message-Id: <966219839.859661@pizza.crosslink.net>
Matthew M. Huntbach <mmh@dcs.qmw.ac.uk> wrote in message
news:8mtpod$l7h$4@beta.qmw.ac.uk...
> COM Service (webmaster@swap-resources.com) wrote:
>
> > I would like to know where I can find free ebooks and good resources
about
> > Java, Perl, Unix, ASP and Visual Basic.
>
> There are huge amounts of material on these things available on the web.
> Anyone with any competence would have no trouble finding them.
>
> Matthew Huntbach
>
so since you didn't post any such resources, -must- mean that you have
little if any competence..
asking on these newsgroups is a good way to start, so why not help out a
little bit
instead of trying to insult someone.
---
as for the topic www.informit.com has some good resources, however it has
quickly
become a bit more of a scam since it left www.mcp.com
mostly has older books (java1.1 coverage, etc) and want you to purchase
anything that
is remotely new..
i checked out the freeonlinebooks.com and it was alot of older coverage as
well..
keep us posted if you run across anything better :)
ken
------------------------------
Date: Sun, 13 Aug 2000 20:38:44 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: - Free ebooks and resources -
Message-Id: <399769C4.9CBB2131@vpservices.com>
sevensoft wrote:
>
> Matthew M. Huntbach <mmh@dcs.qmw.ac.uk> wrote in message
> news:8mtpod$l7h$4@beta.qmw.ac.uk...
> > COM Service (webmaster@swap-resources.com) wrote:
> >
> > > I would like to know where I can find free ebooks and good resources
> about
> > > Java, Perl, Unix, ASP and Visual Basic.
> >
> > There are huge amounts of material on these things available on the web.
> > Anyone with any competence would have no trouble finding them.
>
> so since you didn't post any such resources, -must- mean that you have
> little if any competence..
Yeah, he didn't mention that books can be found in a library either,
must mean he can't read.
> asking on these newsgroups is a good way to start
No it isn't. You start by trying to do the obvious and then come to the
newsgroup when you get stuck, anything else is rude. And posting such a
general question to six different newsgroups is especially rude.
--
Jeff
------------------------------
Date: Sun, 13 Aug 2000 18:13:55 -0700
From: 2of11 <mskNOmsSPAM@unipress.com.invalid>
Subject: Re: Byte compiling ... (got lost in perldocs and CTAN)
Message-Id: <18036c87.1ca562c5@usw-ex0105-037.remarq.com>
Alun,
What we are starting to do with our perl scripts is to run them
through a perl which was built with undump (by me), using the
'perl -u scriptname.pl' and which produces an executable of perl
itslef with the perlcode precompiled.
This has the good effect of making the code binary, and also
making it ***20*** times faster in our case. It has the bad
effect of making each binary the size of the perl, which is
close to 1 meg.
I will email our perl (with -u), just let me know.
I am looking for a perl for NT with -u built in, anyone know
where to find it?
Mark
-----------------------------------------------------------
Got questions? Get answers over the phone at Keen.com.
Up to 100 minutes free!
http://www.keen.com
------------------------------
Date: Mon, 14 Aug 2000 01:28:08 GMT
From: kcivey@cpcug.org (Keith Calvert Ivey)
Subject: Re: CGI : CheckBox and Form Question
Message-Id: <39974a86.2286465@news.newsguy.com>
Etienne Laverdiere <etienno@my-deja.com> wrote:
>Thanks for the answer. Just after my sending, I have found a more
>generic way to send a 'off' value in the checkbox value. It can sound
>strange,but here's the answer (no, it is not a PERL solution, but it is
>related):
Of course, the Perl solution works regardless of the browser,
while the "more generic" solution doesn't work if JavaScript is
unsupported, disabled, or filtered out at the firewall. What's
the advantage?
--
Keith C. Ivey <kcivey@cpcug.org>
Washington, DC
------------------------------
Date: Mon, 14 Aug 2000 03:05:22 GMT
From: Todd Eddy <vrillusions@mail.com>
Subject: CHOMP not working
Message-Id: <399761FE.DACA6557@mail.com>
--------------1E90B7231D8C82985C93E699
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Here is the source in question:
<TR>
<TD VALIGN="middle"><A
HREF="mailto:vrillusions@mail.com">Todd</A></td>
<TD VALIGN="middle">Geoto</td>
<TD VALIGN="middle">Streetsboro, OH
</td>
</TR>
<TR>
<TD VALIGN="middle"><A
HREF="mailto:mack@thehdcafe.com">Lenny</A></td>
<TD VALIGN="middle">FuzzyLogix</td>
<TD VALIGN="middle">Akron, OH
</td>
</TR>
<TR>
<TD VALIGN="middle"> </td>
<TD VALIGN="middle">GymSlayer</td>
<TD VALIGN="middle">Somewhere, IN</td>
</TR>
notice how the first two </td>'s go to a new line while the last one
doesn't. This seems like there is still a newline character in the
variable. I tried chomping both that variable and the line whole line
(before spliting) multiple times and it never changed. It worked when i
used the chop function, but then the last location is "Somewhere, I" I
have also tried taking out all of the chomp functions to see if it
looked different and it didn't. Here are all the different ways I have
tried it ($df_location is the name of that variable):
chomp $_; # chomp the line before spliting it
chomp($_); # another variation of the chomp comman I have seen
chomp $df_location; #chomping the variable after the split
chomp($df_location); # alt ver
none of those worked.
--
Todd Eddy
vrillusions@mail.com
http://www.vrillusions.com/
--------------1E90B7231D8C82985C93E699
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
Here is the source in question:
<p><TR>
<br> <TD VALIGN="middle"><A
HREF="<A HREF="mailto:vrillusions@mail.com">mailto:vrillusions@mail.com</A>">Todd</A></td>
<br> <TD VALIGN="middle">Geoto</td>
<br> <TD VALIGN="middle">Streetsboro,
OH
<br><b></td></b>
<br></TR>
<br><TR>
<br> <TD VALIGN="middle"><A
HREF="<A HREF="mailto:mack@thehdcafe.com">mailto:mack@thehdcafe.com</A>">Lenny</A></td>
<br> <TD VALIGN="middle">FuzzyLogix</td>
<br> <TD VALIGN="middle">Akron,
OH
<br><b></td></b>
<br></TR>
<br><TR>
<br> <TD VALIGN="middle">&nbsp;</td>
<br> <TD VALIGN="middle">GymSlayer</td>
<br> <TD VALIGN="middle">Somewhere,
IN<b></td></b>
<br></TR>
<p>notice how the first two </td>'s go to a new line while the last
one doesn't. This seems like there is still a newline character in
the variable. I tried chomping both that variable and the line whole
line (before spliting) multiple times and it never changed. It worked
when i used the chop function, but then the last location is "Somewhere,
I" I have also tried taking out all of the chomp functions to see
if it looked different and it didn't. Here are all the different
ways I have tried it ($df_location is the name of that variable):
<p>chomp $_; # chomp the line before spliting it
<br>chomp($_); # another variation of the chomp comman I have seen
<br>chomp $df_location; #chomping the variable after the split
<br>chomp($df_location); # alt ver
<p>none of those worked.
<p>--
<br>Todd Eddy
<br>vrillusions@mail.com
<br><A HREF="http://www.vrillusions.com/">http://www.vrillusions.com/</A>
<br> </html>
--------------1E90B7231D8C82985C93E699--
------------------------------
Date: Mon, 14 Aug 2000 02:00:16 GMT
From: kcivey@cpcug.org (Keith Calvert Ivey)
Subject: Re: Convert URLs to links
Message-Id: <39984f08.3440928@news.newsguy.com>
abigail@foad.org (Abigail) wrote:
>Try this in stead:
>
>$string =~ s<
>(?:http://(?:(?:(?:(?:(?:[a-zA-Z\d](?:(?:[a-zA-Z\d]|-)*[a-zA-Z\d])?)\.
^^
You don't want ?: there, since you need the capture for the
replacement. The regex also triggers some bugs in the /x
modifier, but they've probably been fixed since 5.005_03 (or
maybe it's a Windows thing).
And it won't do what people want with things like
http://www.foad.org/~abigail/
http://www.w3.org/Addressing/#time
(http://www.htmlhelp.com)
http://www.perl.com/pub/doc/manual/html/pod/perlre.html.
www.perl.org
But maybe people should change want they want.
--
Keith C. Ivey <kcivey@cpcug.org>
Washington, DC
------------------------------
Date: 13 Aug 2000 21:00:12 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: Get the Time
Message-Id: <8n7jrc$h2$1@provolone.cs.utexas.edu>
In article <slrn8peesp.tj3.abigail@alexandra.foad.org>,
Abigail <abigail@foad.org> wrote:
>Tom Kralidis (tom.kralidis@ccrs.nrcan.gcDOTca) wrote on MMDXXXVI
>September MCMXCIII in <URL:news:8musqo$qh13@nrn2.NRCan.gc.ca>:
>~~ When my watch breaks, I use:
>~~
>~~ perl -e 'print localtime(time) . "\n";'
>
>Too much work.
>
> perl -le'print$,.localtime'
Gosh. This:
perl -le'print"".localtime'
would be less obfuscated and just as short.
Of course, if we're looking for the shortest way to do it, I find that
the "date" program works quite well, and if you don't mind visual
clutter, then "w" also will print the time.
- Logan
------------------------------
Date: 13 Aug 2000 20:45:27 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: how can I optimize a tied hash for speed
Message-Id: <8n7ivn$do$1@provolone.cs.utexas.edu>
In article <8n6c15$61k$1@nnrp1.deja.com>,
webqueen, queen of the web <webqueen@my-deja.com> wrote:
>I just benchmarked my ap thru CGI- 10,000 element hash going through it
>one item at a time, 4 minutes on a P450! Something like:
>
>tie %h ...
>
>foreach (keys %h) {do some simple sorting and printing}
>
>untie %h;
What does "simple sorting and printing" mean? How fast does it run if
you replace your code with this?
tie %h . . .
while ( ($key, $value) = each %h )
{ 1; }
untie %h;
It's possible that the code inside the loop is doing something
suboptimal performance-wise; if so, this is really going to add up if
you do whatever it is 10,000 times.
At any rate, the answer to your performance problems may be either to
attempt to precompute whatever it is you're computing (if the hash
doesn't change often) or to use a database (if you really only need to
look at part of the hash). Or, it may be something different depending
on your problem.
As a test, I just created an NDBM_File tied hash with with 10,000
pairs of random printable data (uuencoded random bytes). Each
key and value was 18 characters long, for a total of 360000 bytes
stored in the hash (but not used on disk). Here's the code
I used to read the hash:
tie(%h, 'NDBM_File', '/tmp/foo', O_RDWR|O_CREAT, 0640);
$total_length = 0;
$count = 0;
while ( ($key, $value) = each %h )
{
$count++;
$total_length += length ($key) + length ($value);
}
untie %h;
And here's how long it took that to run:
real 0m12.929s
user 0m11.920s
sys 0m1.000s
That's a far cry from 4 minutes, and this particular machine is a Linux
system running an AMD 486 processor at (I believe) 133 MHz. So your
Pentium-class 450 MHz machine should be able to outpace it pretty
easily... :-)
- Logan
------------------------------
Date: 14 Aug 2000 01:46:41 GMT
From: john@iastate.edu (John Hascall)
Subject: Re: London =?iso-8859-1?Q?=A330-35K?= Perl Programmers Required
Message-Id: <8n7j21$gqd$1@news.iastate.edu>
David H. Adler <dha@panix.com> wrote:
>Steve Leibel <stevel@bluetuna.com> wrote:
>>Don't be silly. "Longstanding Usenet tradition" dictates that newsgroups
>>are flooded with spam, trolls, job postings, all-encompassing theories
>>of the universe put forth by lunatics and cranks, and of course live nude
>>jpegs of Britney Spears.
>I think you may be confusing Longstanding Disregard for Usenet
>Tradition, with Longstanding Usenet Tradition. :-|
>And where *are* them Britney pix, huh??? :-)
And are they Britney 4 or the newer swollen and objectified Britney 5?
John
--
John Hascall (__) Shut up, be happy.
Software Engineer, ,------(oo) The conveniences you demanded
Acropolis Project Manager, / |Moo U|\/ are now mandatory.
ISU Academic IT * ||----|| -- Jello Biafra
------------------------------
Date: Mon, 14 Aug 2000 01:45:15 GMT
From: Todd Eddy <vrillusions@mail.com>
Subject: Re: Need some debuging help
Message-Id: <39974F37.A1C6881E@mail.com>
damn, you don't have to try to insult me or anything. I am still relatively
new to perl (this is only the second script I have made from the ground up)
and completely forgot about the die command, I have a hard enough time just
trying to remeber to put the ; at the end of the commands.
btw, I did that and it didn't die, so it is opening the file
nobull@mail.com wrote:
> Todd Eddy <vrillusions@mail.com> writes:
>
> > I am working on making a script that will show the people that signed up
> > for a LAN party. I am trying to figure out why I can't get it display
> > the contents.
>
> I do not believe you. If you were _trying_ then one of the first
> things you'd have done is checked that the open() succeded and if it
> not logged why it failed. There's no evidence that you've done this.
>
> > open (DATA, "$datalocation");
>
> open (DATA, "$datalocation") or die "Failed to open $datalocation: $!";
>
> --
> \\ ( )
> . _\\__[oo
> .__/ \\ /\@
> . l___\\
> # ll l\\
> ###LL LL\\
--
Todd Eddy
vrillusions@mail.com
http://www.vrillusions.com/
------------------------------
Date: Mon, 14 Aug 2000 01:52:34 GMT
From: Todd Eddy <vrillusions@mail.com>
Subject: Re: Need some debuging help
Message-Id: <399750EF.23CEEEA4@mail.com>
Thats was the problem. I thought that @lines was some default that all the
contents go into. I tried that @lines = ... one and it worked perfectly. I
still haven't tried the second one yet because I sorta don't understand it
(mainly the '...(defined(...' part of it). And that probbaly more important to
me then the actual script then to understand what everything actually means.
Don't bother with the explanation because by the time you read this and reply,
I would have already found it on the perl site. Thank you
Colin Keith wrote:
> In article <39962D68.D29F04F1@mail.com>, vrillusions@mail.com wrote:
>
> >open (DATA, "$datalocation");
> \ /
> X
> / \
> >foreach (@lines) {
>
> I put a nice big X where I think the problem is ... :)
> I assume that the data you're wanting to print is in this file. But you
> don't actually do anything with this file handle except close it again.
> Perhaps:
>
> @lines = <DATA>;
>
> Is missing ?
> Or better still, rather than slurping it all into memory:
>
> while(defined($_ = <DATA>)){
>
> in place of the foreach() line and do this with 1 line of text in memory at
> once.
>
> Col.
>
> ---
> Colin Keith
> Systems Administrator
> Network Operations Team
> ClaraNET (UK) Ltd. NOC
--
Todd Eddy
vrillusions@mail.com
http://www.vrillusions.com/
------------------------------
Date: Mon, 14 Aug 2000 03:00:07 GMT
From: Todd Eddy <vrillusions@mail.com>
Subject: Re: Need some debuging help
Message-Id: <399760C3.ED359D0B@mail.com>
--------------F6ACB12DEB9FE540B6E557F7
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
I did that chomp in both locations and I have now realized that it doesn't
even work, at least doesn't appear to (see below):
I originally thought that you could use qq print function in a while command
(not really sure what gave me that idea), once I tried it I didn't like how
it showed up in the HTML source when rendered. the print " gives me a
little more control over how it will look on the page. This brings me to
the point above. when I view the source, this is what I get for that part:
<TR>
<TD VALIGN="middle"><A
HREF="mailto:vrillusions@mail.com">Todd</A></td>
<TD VALIGN="middle">Geoto</td>
<TD VALIGN="middle">Streetsboro, OH
</td>
</TR>
<TR>
<TD VALIGN="middle"><A
HREF="mailto:mack@thehdcafe.com">Lenny</A></td>
<TD VALIGN="middle">FuzzyLogix</td>
<TD VALIGN="middle">Akron, OH
</td>
</TR>
<TR>
<TD VALIGN="middle"> </td>
<TD VALIGN="middle">GymSlayer</td>
<TD VALIGN="middle">Somewhere, IN</td>
</TR>
notice how the first two </td>'s go to a new line while the last one
doesn't. This seems like there is still a newline character in the
variable. I tried chomping in multiple times and it never changed. It
worked when i used the chop function, but then the last location is
"Somewhere, I" I have also tried taking out all of the chomp functions to
see if it looked different and it didn't.
I am going to make a new topic asking for help on that, just thought I would
tell you here too since it kinda went with your reply.
Martien Verbruggen wrote:
> On Sun, 13 Aug 2000 05:08:44 GMT,
> Todd Eddy <vrillusions@mail.com> wrote:
>
> > open (DATA, "$datalocation");
>
> open(DATA, $datalocation) or die "Cannot open $datalocation: $!";
>
> > foreach (@lines) {
>
> What's @lines? Where did that come from? Are you for some reason
> expecting @lines to contain the lines from $datalocation? Maybe you
> meant
>
> while (<DATA>)
> {
>
> instead
>
> > # Now split up the info:
> > showname|name|showemail|email|callsign|location
> > ($df_showname, $df_name, $df_showemail, $df_email, $df_callsign,
> > $df_location) = split(/\|/, $_);
> >
> > chomp $df_location;
>
> You could have done that chomp before the split. Would have made
> slightly more sense.
>
> You should probably check that that split read everything you need, with
> something like:
>
> die "Invalid line: $." unless $df_location;
>
> > if ($df_showname == 0) { $df_name = " "; }
>
> $df_name = '' unless $df_showname;
>
> > if ($df_showemail == 1) { $df_name = "<A
> > HREF=\"mailto:".$df_email."\">".$df_name."<\/A>"; }
>
> $df_name = qq(<A HREF="mailto:$df_email">$df_name</a>);
>
> > print "<TR>\n";
> > print " <TD VALIGN=\"middle\">$df_name</td>\n";
> > print " <TD VALIGN=\"middle\">$df_callsign</td>\n";
> > print " <TD VALIGN=\"middle\">$df_location</td>\n";
> > print "</TR>\n";
>
> You should learn to use here-docs.
>
> # perldoc perldata
>
> or you should use qq or double quotes, and not worry about the line
> ends.
>
> > }
> > close DATA;
> >
> >
> > print qq~
>
> So... You do know about qq and stuff like that? Why didn't you use it
> above? Worse than bad style is inconsistent style.
>
> > I checked it through perl and I had no errors, I checked all the
> > variables and they are what they're supposed to be.
>
> Which variables did you check? In the code that was posted, none of the
> variables, except for the file ame, ever would have been filled, unless
> you did that somewhere else. None of the lines in that file would have
> been read, unless you did that somewhere else.
>
> And you probably should start using -w and strict as well, unless you
> already are.
>
> Martien
> --
> Martien Verbruggen |
> Interactive Media Division | I took an IQ test and the results
> Commercial Dynamics Pty. Ltd. | were negative.
> NSW, Australia |
--
Todd Eddy
vrillusions@mail.com
http://www.vrillusions.com/
--------------F6ACB12DEB9FE540B6E557F7
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
I did that chomp in both locations and I have now realized that it doesn't
even work, at least doesn't appear to (see below):
<p>I originally thought that you could use qq print function in a while
command (not really sure what gave me that idea), once I tried it I didn't
like how it showed up in the HTML source when rendered. the print
" gives me a little more control over how it will look on the page.
This brings me to the point above. when I view the source, this is
what I get for that part:
<p><TR>
<br> <TD VALIGN="middle"><A
HREF="<A HREF="mailto:vrillusions@mail.com">mailto:vrillusions@mail.com</A>">Todd</A></td>
<br> <TD VALIGN="middle">Geoto</td>
<br> <TD VALIGN="middle">Streetsboro,
OH
<br><b></td></b>
<br></TR>
<br><TR>
<br> <TD VALIGN="middle"><A
HREF="<A HREF="mailto:mack@thehdcafe.com">mailto:mack@thehdcafe.com</A>">Lenny</A></td>
<br> <TD VALIGN="middle">FuzzyLogix</td>
<br> <TD VALIGN="middle">Akron,
OH
<br><b></td></b>
<br></TR>
<br><TR>
<br> <TD VALIGN="middle">&nbsp;</td>
<br> <TD VALIGN="middle">GymSlayer</td>
<br> <TD VALIGN="middle">Somewhere,
IN<b></td></b>
<br></TR>
<p>notice how the first two </td>'s go to a new line while the last
one doesn't. This seems like there is still a newline character in
the variable. I tried chomping in multiple times and it never changed.
It worked when i used the chop function, but then the last location is
"Somewhere, I" I have also tried taking out all of the chomp functions
to see if it looked different and it didn't.
<p>I am going to make a new topic asking for help on that, just thought
I would tell you here too since it kinda went with your reply.
<p>Martien Verbruggen wrote:
<blockquote TYPE=CITE>On Sun, 13 Aug 2000 05:08:44 GMT,
<br> Todd Eddy <vrillusions@mail.com>
wrote:
<p>> open (DATA, "$datalocation");
<p>open(DATA, $datalocation) or die "Cannot open $datalocation: $!";
<p>> foreach (@lines) {
<p>What's @lines? Where did that come from? Are you for some reason
<br>expecting @lines to contain the lines from $datalocation? Maybe you
<br>meant
<p>while (<DATA>)
<br>{
<p>instead
<p>> # Now split up the info:
<br>> showname|name|showemail|email|callsign|location
<br>> ($df_showname, $df_name, $df_showemail, $df_email, $df_callsign,
<br>> $df_location) = split(/\|/, $_);
<br>>
<br>> chomp $df_location;
<p>You could have done that chomp before the split. Would have made
<br>slightly more sense.
<p>You should probably check that that split read everything you need,
with
<br>something like:
<p>die "Invalid line: $." unless $df_location;
<p>> if ($df_showname == 0) { $df_name = " "; }
<p>$df_name = '' unless $df_showname;
<p>> if ($df_showemail == 1) { $df_name = "<A
<br>> HREF=\"<a href="mailto:" .$df_email."\">mailto:".$df_email."\</a>">".$df_name."<\/A>";
}
<p>$df_name = qq(<A HREF="<a href="mailto:$df_email">mailto:$df_email</a>">$df_name</a>);
<p>> print "<TR>\n";
<br>> print " <TD VALIGN=\"middle\">$df_name</td>\n";
<br>> print " <TD VALIGN=\"middle\">$df_callsign</td>\n";
<br>> print " <TD VALIGN=\"middle\">$df_location</td>\n";
<br>> print "</TR>\n";
<p>You should learn to use here-docs.
<p># perldoc perldata
<p>or you should use qq or double quotes, and not worry about the line
<br>ends.
<p>> }
<br>> close DATA;
<br>>
<br>>
<br>> print qq~
<p>So... You do know about qq and stuff like that? Why didn't you use it
<br>above? Worse than bad style is inconsistent style.
<p>> I checked it through perl and I had no errors, I checked all the
<br>> variables and they are what they're supposed to be.
<p>Which variables did you check? In the code that was posted, none of
the
<br>variables, except for the file ame, ever would have been filled, unless
<br>you did that somewhere else. None of the lines in that file would have
<br>been read, unless you did that somewhere else.
<p>And you probably should start using -w and strict as well, unless you
<br>already are.
<p>Martien
<br>--
<br>Martien Verbruggen
|
<br>Interactive Media Division | I took an
IQ test and the results
<br>Commercial Dynamics Pty. Ltd. | were negative.
<br>NSW, Australia
|</blockquote>
<p>--
<br>Todd Eddy
<br>vrillusions@mail.com
<br><A HREF="http://www.vrillusions.com/">http://www.vrillusions.com/</A>
<br> </html>
--------------F6ACB12DEB9FE540B6E557F7--
------------------------------
Date: Mon, 14 Aug 2000 02:56:23 GMT
From: kcivey@cpcug.org (Keith Calvert Ivey)
Subject: Re: Need some debuging help
Message-Id: <399a5d67.7120404@news.newsguy.com>
newsgroups@ckeith.clara.net (Colin Keith) wrote:
>Or better still, rather than slurping it all into memory:
>
> while(defined($_ = <DATA>)){
Or better still,
while (<DATA>) {
which magically does the same thing with less clutter. Also,
it's probably better to avoid using DATA as a name for an
ordinary file handle, since it has a special use (see perldata).
--
Keith C. Ivey <kcivey@cpcug.org>
Washington, DC
------------------------------
Date: 13 Aug 2000 18:05:58 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Negativity in Newsgroup -- Solution
Message-Id: <m1punc6495.fsf@halfdome.holdit.com>
>>>>> "Drew" == Drew Simonis <care227@attglobal.net> writes:
Drew> Methinks the Schwartz is growing weary.
Yeah, I wrote the final paragraph, then went back and added item 3.
Gotta have a reviewer from now on, I guess. :)
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
Date: Sun, 13 Aug 2000 23:43:56 -0400
From: David Webb <davidwebb@MailAndNews.com>
Subject: Pattern Matching Question
Message-Id: <39B2C6E6@MailAndNews.com>
Hi All,
I am trying to extract all the links and their titles from a web page. As
you
know, it is not guaranteed that all the data would be on same line.
I was trying this
while ($main =~ /<a href="(.*)">(.*)</a>/igm) {
print "$1, $2";
}
The problem is, if there are 10 links, it picks the data from first link to
the end of 10th link, all in $1. What mistake I am doing? Please guide.
Since I am a beginner so if you can suggest better code to extract all the
links and their title, I'll appreciate it.
------------------------------
Date: 14 Aug 2000 03:02:05 GMT
From: thorfinn@netizen.com.au (Thorfinn)
Subject: Re: Printing a Thread with HTML Lists
Message-Id: <slrn8peo9c.fro.thorfinn@netizen.com.au>
In comp.lang.perl.misc, on Sun, 13 Aug 2000 16:21:04 -0700
Gabe <grichards@flashcom.net> wrote:
> I feel like an idiot. I've been working on this for way too long. How can I
> print a threaded conversation using unordered HTML lists (<ul>). I can't
> come up with an algorithm that does it properly. Everything I try gets it
> skewed one way or another. When to print the <ul>'s is easy, I can't figure
> out how to print the right number of </ul>'s at the right places. Here's
> the code I'm using.
Let me do a bunch of re-ordering and commenting. This isn't really a
Perl question, but I'll answer anyway. :) It's mostly a recursion
problem... you need to work through the recursive steps better.
# Inhale the threading information.
# NB: I'm assuming this bit is correct.
> my (%msgs, %children);
> while (my @row = $getmsgs->fetchrow_array) {
> my ($id, $pid, $subject, $name) = @row;
> $msgs{$id}{parent} = $pid;
> $msgs{$id}{subject} = $subject;
> $msgs{$id}{name} = $name;
> push(@{$children{$pid}}, $id);
> }
# Recursive -
# print the message subject list item.
# If the message has children, start a new
# ul and recurse on all the children.
> sub Thread {
> my $id = shift;
# Always print the line with id, so move it outside the check.
$content{'main'} .= qq{<li>$msgs{$id}{subject}\n};
> if (exists $children{$id}) {
> $content{'main'} .= qq{<ul>\n};
> foreach (@{$children{$id}}) {
> Thread($_);
> }
# Here's the line you were missing.
$content{'main'} .= qq{</ul>\n};
> }
# XXX delete this bit
# not needed, since we always do this.
> else {
> $content{'main'} .= qq{<li>$msgs{$id}{subject}\n};
> }
> }
> $content{'main'} .= qq{
> <h2>Message Board</h2>
> <h3>Messages</h3>
> <ul>\n
> };
# This is the root message id - might be better
# named as $root_message_id.
> my $pid = 0;
> foreach (@{$children{$pid}}) {
> Thread($_);
> }
> $content{'main'} .= '</ul>';
Later,
Thorf
--
David Goh <thorfinn@netizen.com.au> --- http://netizen.com.au/
Internet and Open Source Development, Consulting and Training.
Netizen Pty Ltd, GPO Box 2265U, Melbourne VIC 3000, Australia.
Tel: +61 3 9614 0949 Mob: +61 411 692 516 Fax: +61 3 9614 0948
------------------------------
Date: Mon, 14 Aug 2000 01:23:23 GMT
From: "Shawn W. Devlin" <shawn@secludedgrove.com>
Subject: Re: Problems creating a new module based off HTML::Parser
Message-Id: <399749E3.74F4F011@secludedgrove.com>
Keith Calvert Ivey wrote:
[snip]
> >my $mw = MarketWatch::new();
>
> That should be
>
> my $mw = MarketWatch->new();
>
> The way you're calling it, new() doesn't get the class name --
> it doesn't get any arguments at all.
Thanks. That's what I get for coding into the wee hours for too many
days in a row.
--
Shawn W. Devlin
Unicorn Software
Custom Software Development
C++, Delphi, Perl, HTML, XML, Director
v:(613) 623-6159
f:(613) 622-7933
------------------------------
Date: Mon, 14 Aug 2000 01:07:53 GMT
From: jason <elephant@squirrelgroup.com>
Subject: Re: Procmail vs Perl.
Message-Id: <MPG.1401e3d01d0a02c99896ae@localhost>
Abigail wrote ..
>jason (elephant@squirrelgroup.com) wrote on MMDXXXIX September MCMXCIII
>in <URL:news:MPG.1401c6cc2a636da19896ad@localhost>:
>?? Tony L. Svanstrom wrote ..
>?? >Sam <sam@email-scan.com> wrote:
>?? >
>?? >> In article <1efbf1y.171gvyotw70ytN%tony@svanstrom.com>,
>?? >> tony@svanstrom.com (Tony L. Svanstrom) writes:
>?? >>
>?? >> > A simple question: Why would I want to learn how to use procmail when I
>?? >> > already know Perl, wouldn't it be easier, as well as potentially a lot
>?? >> > more powerful, to simply use Perl for the mailfiltering?
>??
>?? I don't seem to have your original post here - so excuse this thread
>?? breaker
>??
>?? your question was asked and answered by Simon Cozens in the latest TPJ
>?? .. he created Mail::Audit which is on CPAN .. well worth a look
>
>
>I looked, I read its limitations, I decided to stay with procmail.
me too .. but my mail filtering requirements are very simple (and I've
never really had a problem with the procmail syntax)
>I do have a Perl program to modify the .procmailrc for me though.
I'll bet you do
--
jason -- elephant@squirrelgroup.com --
------------------------------
Date: Sun, 13 Aug 2000 18:08:13 -0700
From: glued2 <glued2NOglSPAM@hotmail.com.invalid>
Subject: Re: set variable to results of regex
Message-Id: <006298f0.e85f5c7a@usw-ex0104-028.remarq.com>
Capturing parens? What is the syntax for that (instead of
printing the string as in my example)?
I'm assuming the second step would be something like:
$RESULTS = $1;
Also, for my information, why does the other approach ($&) incur
a performance hit... what is it actually doing?
I appreciate everyone's help!
-------------------------------
http://www.GluedToTheScreen.com
-----------------------------------------------------------
Got questions? Get answers over the phone at Keen.com.
Up to 100 minutes free!
http://www.keen.com
------------------------------
Date: 13 Aug 2000 21:45:45 -0400
From: Jordan Katz <katz@underlevel.net>
Subject: Re: set variable to results of regex
Message-Id: <m3aeeg4nue.fsf@underlevel.underlevel.net>
glued2 <glued2NOglSPAM@hotmail.com.invalid> writes:
> Capturing parens? What is the syntax for that (instead of
> printing the string as in my example)?
>
> I'm assuming the second step would be something like:
> $RESULTS = $1;
>
> Also, for my information, why does the other approach ($&) incur
> a performance hit... what is it actually doing?
>
> I appreciate everyone's help!
If I understood your question correctly, whatever string is matched in
the first set parens in your regular expression is put into $1, second
set in $2, and so on. Here's an example:
$regexp = "\t(.*)\t";
# Take whatever's matched in (.*) and put it
# into $result. I'm assuming $result also contains
# your data.
$result =~ s/$regexp/$1/;
--
Jordan Katz <katz@underlevel.net>
------------------------------
Date: Mon, 14 Aug 2000 01:39:24 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: set variable to results of regex
Message-Id: <g5Il5.51179$0l6.104191@typhoon.austin.rr.com>
In article <006298f0.e85f5c7a@usw-ex0104-028.remarq.com>,
glued2 <glued2NOglSPAM@hotmail.com.invalid> wrote:
>Capturing parens? What is the syntax for that (instead of
>printing the string as in my example)?
>
>I'm assuming the second step would be something like:
>$RESULTS = $1;
As the original code fragment said:
while (<SF>){
print if /$STARTPATTERN/ .. /$ENDPATTERN/ ;
}
You could store the content of the records you print by doing something like
$match = '';
while (<SF>) {
$match .= $_ if /$STARTPATTERN/ .. /$ENDPATTERN/ ;
}
An example of capturing parens might be
$s = "In The Cage / Cinema Show / Afterglow\n";
if ($s =~ m: / (.+) / :) {
$matched = $1;
...
}
>Also, for my information, why does the other approach ($&) incur
>a performance hit... what is it actually doing?
The output of
perldoc perlfaq6
includes:
Why does using $&, $`, or $' slow my program down?
Because once Perl sees that you need one of these
variables anywhere in the program, it has to provide them
on each and every pattern match. The same mechanism that
handles these provides for the use of $1, $2, etc., so you
pay the same price for each regex that contains capturing
parentheses. But if you never use $&, etc., in your
script, then regexes without capturing parentheses won't
be penalized. So avoid $&, $', and $` if you can, but if
you can't, once you've used them at all, use them at will
because you've already paid the price. Remember that some
algorithms really appreciate them. As of the 5.005
release. the $& variable is no longer "expensive" the way
the other two are.
Hope this helps,
Mike
--
mike@stok.co.uk | The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/ |
GPG PGP Key 1024D/059913DA | Fingerprint 0570 71CD 6790 7C28 3D60
stok@colltech.com (CT - work) | 75D2 9EC4 C1C0 0599 13DA
------------------------------
Date: Mon, 14 Aug 2000 01:20:25 GMT
From: johnvert@my-deja.com
Subject: tag parsing.
Message-Id: <8n7hgn$v2g$1@nnrp1.deja.com>
Hi,
I'm trying to parse a file that looks like this:
<T>\n
hello world\n
</T>\n
A way to retrieve the text between <T> and </T> would be:
$t=s/\<T\>(.*)\<\/T\>/$1/;
However, if each of these lines is split across each element of an
array, as in:
@tlines=split(/\n/, $t);
The regexp above will not work since parts of what I'm trying to
retrieve is in different elements of 'tlines'. So my question is: how
would I parse such an array?
Thanks,
-- john
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Mon, 14 Aug 2000 02:03:14 GMT
From: fvw+usenet@var.cx (fvw)
Subject: Re: tag parsing.
Message-Id: <966218936JEY.fvw@var.cx>
<8n7hgn$v2g$1@nnrp1.deja.com> (johnvert@my-deja.com):
>However, if each of these lines is split across each element of an
>array, as in:
>
>@tlines=split(/\n/, $t);
>
>The regexp above will not work since parts of what I'm trying to
>retrieve is in different elements of 'tlines'. So my question is: how
>would I parse such an array?
Try join()ing the array first (see perldoc -f join).
--
Frank v Waveren
fvw@var.cx
ICQ# 10074100
------------------------------
Date: Mon, 14 Aug 2000 02:14:10 GMT
From: "Philip Garrett" <philipg@atl.mediaone.net>
Subject: Re: tag parsing.
Message-Id: <SBIl5.17452$rd1.3870066@typhoon-news1.southeast.rr.com>
<johnvert@my-deja.com> wrote in message news:8n7hgn$v2g$1@nnrp1.deja.com...
>
> However, if each of these lines is split across each element of an
> array, as in:
>
> @tlines=split(/\n/, $t);
>
> The regexp above will not work since parts of what I'm trying to
> retrieve is in different elements of 'tlines'. So my question is: how
> would I parse such an array?
($data) = join( "", @tlines) =~ /\<T\>(.*)\<\/T\>/;
That works for this small example, but if you want to do a lot of parsing
like this, you might want to check out the perldoc pages for HTML::Parser
and HTML::TokeParser.
HTH,
Philip
------------------------------
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 4005
**************************************