[11430] in Perl-Users-Digest
Perl-Users Digest, Issue: 5030 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Mar 2 03:57:21 1999
Date: Tue, 2 Mar 99 00:00:21 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Tue, 2 Mar 1999 Volume: 8 Number: 5030
Today's topics:
Re: 'x' operator to pre-extend a string (Steven Alexander)
Re: 'x' operator to pre-extend a string (Ilya Zakharevich)
Re: *** FAQ: ANSWERS TO YOUR QUESTIONS! READ FIRST! Pos <uri@home.sysarch.com>
Re: *** FAQ: ANSWERS TO YOUR QUESTIONS! READ FIRST! Pos (Ronald J Kimball)
Re: *** FAQ: ANSWERS TO YOUR QUESTIONS! READ FIRST! Pos (Ronald J Kimball)
Re: *** FAQ: ANSWERS TO YOUR QUESTIONS! READ FIRST! Pos (Ronald J Kimball)
Re: Accounts Management with Web interface <bill@fccj.org>
browser detection in CGI script <cnorris@hotmail.com>
CGI.pm question <scijr@nus.edu.sg>
Re: Determine web directory size (Larry Rosler)
Re: Dynamic Variables <ebohlman@netcom.com>
Execute the Command Line <maw@markaw.demon.co.uk>
Re: file comfirmation (I R A Aggie)
File locking ? <seccoza@mweb.co.za>
File::Path and tainted directory names. <ccyr@home.com>
Hashes in Files (AKBishop)
Help, Perl script question mr_potato_head@my-dejanews.com
Re: Help, Perl script question <Mathias-Henry.Weber@de.heidelberg.com>
Re: HTML::TreeBuilder - any other options? (Bill Moseley)
Re: HTML::TreeBuilder - any other options? <jdf@pobox.com>
Odd Experience <wally@sub-zero.mit.edu>
Re: regexp <giudice@ix.netcom.com>
Urgent Help Please!? --> Multiline Reading of data fil (theo jones)
Re: URGENT help required!! (Rich)
what is actually path to compile perl in cgi-bin <adayuen@hotmail.com>
Re: Why can't my .pl find my SCRIPT ?? <ebohlman@netcom.com>
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 1 Mar 1999 21:23:26 -0800
From: stevena@user2.teleport.com (Steven Alexander)
Subject: Re: 'x' operator to pre-extend a string
Message-Id: <7bfske$6b3$1@user2.teleport.com>
In article <7bc5bk$6dg$1@mathserv.mps.ohio-state.edu>,
Ilya Zakharevich <ilya@math.ohio-state.edu> wrote:
>You are waisting a lot of memory here due to Perl's shortcomings. The
>space-efficient way to do it (saves 50% of space) is
Wouldn't that be "perl's shortcomings"?
--
Steven Alexander
stevena@teleport.com
perl -le 'print map{pack 'C',$_}'
-e 'map{$_?64+((0<=>$_)+(($_**2)-1)**2)%17:()}-2..2;'
------------------------------
Date: 2 Mar 1999 07:47:46 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: 'x' operator to pre-extend a string
Message-Id: <7bg532$qkl$1@mathserv.mps.ohio-state.edu>
[A complimentary Cc of this posting was sent to Steven Alexander
<stevena@user2.teleport.com>],
who wrote in article <7bfske$6b3$1@user2.teleport.com>:
> In article <7bc5bk$6dg$1@mathserv.mps.ohio-state.edu>,
> Ilya Zakharevich <ilya@math.ohio-state.edu> wrote:
> >You are waisting a lot of memory here due to Perl's shortcomings. The
> >space-efficient way to do it (saves 50% of space) is
>
> Wouldn't that be "perl's shortcomings"?
Hard to tell. These are not exactly misimplementations. More
probably misdecisions, or miscorollaries of decisions.
Ilya
------------------------------
Date: 01 Mar 1999 23:02:24 -0500
From: Uri Guttman <uri@home.sysarch.com>
Subject: Re: *** FAQ: ANSWERS TO YOUR QUESTIONS! READ FIRST! Posted Twice Weekly ***
Message-Id: <x7r9r8edyn.fsf@home.sysarch.com>
>>>>> "AF" == Andrew Fry <andrewf@beausys.demon.co.uk> writes:
AF> in this newsgroup. And, as Uri's replies have shown, being sarcastic,
AF> condescending, patronizing and abusive occasionally go along with the
AF> reply.
not really. i have helped a couple of newbies out the last day or so
without sarcasm and they were effusive in thanking me and others for
that help. wonder how that came about? they asked a question about a
specific issue/code problem or whatever. it wasn't an FAQ, they said
they had read various docs and couldn't get further. they both got
multiple quality responses and i doubt they know more perl than you. the
sarcasm gets sent to the ones who don't even try to do it themselves.
AF> And despite what some of you think, this newsgroup isnt just for the
AF> elite to discuss "interesting" Perl issues.
and you keep bringing up this stupid point. no one has ever said
that. my comment above is a case in point. neither question i answered
ws particularly "interesting" as i understod the issues very clearly and
they were basic perl. but the question was couched in a respectful and
inquiring way. no gimme, but rather i tried this or i don't understand
the docs here.
quality questions get quality answers. FAQs are told to rtfm as they
should. that is what an FAQ list is for! the mini FAQ that is posted by
gnat is a great checklist of resources and fundamental perl issues that
should always be read followed by newbies. it is not a case of their
having to read every book and document in all of perl before thay post,
rather they have had to try to solve the problem themselves first,
searched/read the relevent docs and books and then post a question with
useful information. no missing code, no gimmes, no FAQs.
uri
--
Uri Guttman ----------------- SYStems ARCHitecture and Software Engineering
Perl Hacker for Hire ---------------------- Perl, Internet, UNIX Consulting
uri@sysarch.com ------------------------------------ http://www.sysarch.com
The Best Search Engine on the Net ------------- http://www.northernlight.com
------------------------------
Date: Tue, 2 Mar 1999 01:54:38 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: *** FAQ: ANSWERS TO YOUR QUESTIONS! READ FIRST! Posted Twice Weekly ***
Message-Id: <1do0m6s.g8r8wmyns2tkN@bay1-524.quincy.ziplink.net>
Andrew Fry <andrewf@beausys.demon.co.uk> wrote:
> All I am saying is that
> there is no need to remind us newbies, ad nauseam, that we should read
> the FAQs, man pages, online articles, books. RTFM is used far too often
> in this newsgroup.
All we are saying is that there's no need for "you newbies" to keep
asking, ad nauseum, questions that are answered in the FAQs, man pages,
online articles, books. RTFM is not followed nearly often enough in
this newsgroup.
It's not a perfect world, is it?
--
_ / ' _ / - aka - rjk@linguist.dartmouth.edu
( /)//)//)(//)/( Ronald J Kimball chipmunk@m-net.arbornet.org
/ http://www.ziplink.net/~rjk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: Tue, 2 Mar 1999 01:54:39 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: *** FAQ: ANSWERS TO YOUR QUESTIONS! READ FIRST! Posted Twice Weekly ***
Message-Id: <1do0m9y.bnbos6hnsh34N@bay1-524.quincy.ziplink.net>
Andrew Fry <andrewf@beausys.demon.co.uk> wrote:
> All I am saying is that, as a newbie, I find it unhelpful,
> irritating and patronizing to be told time-after-time-after-time ....
> read the FAQ! read the man pages! read the on-line articles! read
> the books!
How many times have you been told to read the FAQ, the man pages, the
online articles, and the books?
Let's see...
Out of roughly 35 posts to clpm, you have asked 6 questions, with the
following results:
1. two non-RTFM answers
2. two non-RTFM answers
3. one non-RTFM answer [after finding the answer on your own]
4. three non-RTFM answers
5. two non-RTFM answers
6. one non-RTFM answer
three RTFM answers [after the non-RTFM answer]
You have posted 19 times ranting about being told to RTFM.
You have posted one answer to someone else's question. Your answer
directed the user to read the documentation.
Summary:
You have been told to RTFM three times. You have received eleven
responses which did not mention RTFM. You have ranted nineteen times
about being told to RTFM. You have posted one response which told
someone to RTFM.
> Personally, I dont yet know my way around the documentation,
> but I do know that it doesnt answer everything. I'm gradually
> reading more and more. As I have said before, the reply of RTFM
> could, with some justification, be given to 95% of all questions.
Then what are you complaining about?
> I object to the implication that this newsgroup is primarily for
> the experts to discuss "interesting" issues.
That's fine. Aside from you, no one has made that implication.
This newsgroup is primarly for *everyone* to discuss "interesting"
issues. Basic netiquette defines "interesting" as "issues which are not
clearly answered in the FAQ or man pages".
> Finally, Uri ... calm down and stop the stupid remarks, illogical
> extrapolations and abuse.
Finally, Andrew ... calm down and stop the stupid remarks, illogical
extrapolations and abuse.
--
_ / ' _ / - aka - rjk@linguist.dartmouth.edu
( /)//)//)(//)/( Ronald J Kimball chipmunk@m-net.arbornet.org
/ http://www.ziplink.net/~rjk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: Tue, 2 Mar 1999 01:54:41 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: *** FAQ: ANSWERS TO YOUR QUESTIONS! READ FIRST! Posted Twice Weekly ***
Message-Id: <1do0noy.1jdrl0wtjhzv8N@bay1-524.quincy.ziplink.net>
Andrew Fry <andrewf@beausys.demon.co.uk> wrote:
> Not so. It is just that to suggest that newbies should read...
> * the FAQs
Same for all newsgroups with FAQs.
> * the man pages
Same for all newsgroups with related documentation.
> * on-line articles at the main Perl sites
Newbies are *encouraged* to read the on-line articles. Doing so is not
a requirement for posting.
> * the main Perl books
Newbies are *encouraged* to read the main Perl books. Doing so is not a
requirement for posting.
> ...before posting a question is both patronising and unhelpful
> (when done too frequently).
Unhelpful how? Do you suggest that reading the FAQ and documentation is
bad advice?
What is too frequently? Is it too frequently when the same question is
asked and answered four times in a single month?
--
_ / ' _ / - aka - rjk@linguist.dartmouth.edu
( /)//)//)(//)/( Ronald J Kimball chipmunk@m-net.arbornet.org
/ http://www.ziplink.net/~rjk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: Mon, 01 Mar 1999 22:34:08 -0500
From: "Bill Jones" <bill@fccj.org>
Subject: Re: Accounts Management with Web interface
Message-Id: <36db5b8e.0@usenet.fccj.cc.fl.us>
In article <7b84jq$ifk$2@client2.news.psi.net>, abigail@fnx.com (Abigail)
wrote:
> jnoviell@my-dejanews.com (jnoviell@my-dejanews.com) wrote on MMV
> September MCMXCIII in <URL:news:7b74cj$v8g$1@nnrp1.dejanews.com>:
> $$ Greetings,
> $$
> $$ I have a web CGI script that creates UNIX user accounts (in a temp. file).
> $$
> $$ Is there anyway I can update the try passwd file with the one I've just
> $$ created?
> $$
> $$ The passwd file has to remain "root" controlled.
> $$
> $$ In otherwords, can I virtually become "root" in my CGI script to do root
> $$ related tasks?
>
>
> If you have to ask how to do it, you shouldn't be doing it.
> This is dangerous stuff we're talking about.
>
>
>
> Abigail
> --
> perl -MTime::JulianDay
-lwe'@r=reverse(M=>(0)x99=>CM=>(0)x399=>D=>(0)x99=>CD=>(
>
0)x299=>C=>(0)x9=>XC=>(0)x39=>L=>(0)x9=>XL=>(0)x29=>X=>IX=>0=>0=>0=>V=>IV=>0
=>0
>
=>I=>$r=-2449231+gm_julian_day+time);do{until($r<$#r){$_.=$r[$#r];$r-=$#r}fo
r(;
> !$r[--$#r];){}}while$r;$,="\x20";print+$_=>September=>MCMXCIII=>()'
PMFJI: I agree with Abigail.
And suid scripts are very bad indeed.
Plus, as an added bonus, it is REAL easy
to watch the HTTP port transactions, as
they go across as clear text.
Since this has been discussed at
length in the past, I would
recommend researching this via
http://www.dejanews.com you will
find a boat load of 'passwd-related'
discussions under comp.lang.perl.*
Also, to try to prevent another
drawn out discussion on this topic,
try this instead of what you
are attempting:
#!perl
use Net::Telnet;
# Correct each 'prompts' text as needed below:
$obj = new Net::Telnet (Timeout => 10,
Prompt => '/astro\% $/');
$obj->open("astro.fccj.org");
$obj->login('bill', 'oldpswd');
# Example passwd session prompts:
# Enter login password:
# New password:
# Re-enter new password:
# [8:56pm] 100 [/drv3/home/staff/bill/perl]:astro%
$ok = $obj->cmd(String => '/bin/passwd',
Prompt => '/Enter login password/',
Timeout => 10);
$ok = $obj->cmd(String => 'oldpswd',
Prompt => '/New password:/',
Timeout => 10);
$ok = $obj->cmd(String => 'newpswd',
Prompt => '/Re-enter new password:/',
Timeout => 10);
$ok = $obj->cmd(String => 'newpswd',
Prompt => '/astro\% $/',
Timeout => 10);
exit;
# End of script...
I had previously published a 'WebPass' script
( see http://reference.perl.com/query.cgi?security )
which I am currently updating to use the above
skeleton script instead of the Expect
( see http://expect.nist.gov ) development system
(which is somewhat similar to perl.)
While the above has no error correcting, and
it is still VERY possible to 'watch' telnet
ports as well, it is harder in the sense
that the telnet should be to the localhost;
plus you should run any such scripts under
an HTTPS (secure port 443) Web Server;
to make things harder on prying eyes.
HTH,
-Sneex- :]
Jacksonville Perl Mongers
http://jacksonville.pm.org
jax@jacksonville.pm.org
------------------------------
Date: 2 Mar 1999 05:15:52 GMT
From: "Craig" <cnorris@hotmail.com>
Subject: browser detection in CGI script
Message-Id: <01be646c$0af31160$163b56d1@puter>
I'm writing a CGI application in Perl. Being VERY new to the language, I'm
having troubles doing browser detection. I have the environment variable
with the browser version in it, but I can't seem to parse it to get the
requisite page to come up. Does anyone know of a code snippet that already
does this? Or could someone just help me with the expression?
Thanks a lot in advance!
Craig
------------------------------
Date: Tue, 2 Mar 1999 14:46:07 +0800
From: Jeremy <scijr@nus.edu.sg>
Subject: CGI.pm question
Message-Id: <36DB8914.762E89AE@nus.edu.sg>
hi,
i'm using CGI.pm module. In a perl script, i tried to display a text1 +
button1 and when button1 presses will show text2 + button2 . But when
button2 pressed....a text which is suppossedly to appear did not. Can
anyone help ?
Thanks a lot.
------------------------------
Date: Mon, 1 Mar 1999 19:49:43 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Determine web directory size
Message-Id: <MPG.1144ffab770f5c1e9896bd@nntp.hpl.hp.com>
[Posted and a courtesy copy mailed.]
In article <36DB4913.D7A4FAF@sympatico.ca>, on Mon, 01 Mar 1999 21:12:35
-0500 dimitrio@sympatico.ca says...
> Try this: (excuse my wordiness, I'm only learning..)
Welcome to the group. One of the first things you should learn is to
test your code before posting it -- even if you don't think you need to.
> #!D:/perl/bin/perl -w
> my ($d, @f, $tsz);
>
> $d = "D:/perl/bin";
> opendir (DIR, $d) || die "Could not open dir $!";
> @f = readdir DIR;
>
> $tsz=0;
> for (@f) {
> $tsz += -s;
> }
> print $tsz;
> closedir DIR;
This code works iff the directory you are reading happens to be the
current directory. This is because the readdir function returns only
the names, which are relative to the current directory. To work in
general, you must supply an absolute filename:
$tsz += -s "$d/$_";
> Dimitri Ostapenko,
> Not another perl hacker (yet)
>
> Dmitry Diskin wrote:
>
> > Hi,
> >
> > Is there any simple solution for count the total size of files in
> > particular directory of web server?
> >
> > Dmitry.
It is more appropriate to put the question you are answering ahead of
your answer, not after it.
And it is totally inappropriate to include this garbage in your
response:
> begin:vcard
> n:Ostapenko;Dimitri
...
Use a signature of not more than four lines, preceded by the standard
cut-string "-- \n".
--
Larry Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Tue, 2 Mar 1999 03:39:08 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: Dynamic Variables
Message-Id: <ebohlmanF7y7H8.M1p@netcom.com>
Dan R. Smorey Jr. <smory@ptdprolog.net> wrote:
: I have no idea if this is an easy question or not, I'm pretty new to
: Perl, about 2 months new. I'd like to know how to use dynamic
: variables. It'd be easier if I just show the code than try to
: explain...
: $prod1_nw = "25";
: $prod2_nw = "35";
: $prod3_nw = "45";
: $prod4_nw = "55";
: # I'd like to print the prod(x)_nw's out with a for loop like this...
: for $i (1 .. 4)
: {
: $prod_var = "$prod${i}_nw";
: print "Product - $i - $prod_var\n";
: }
No, you want to use an array.
@prod_nw=(25,35,45,55);
for $i (1..4) {
print "Product - $i - $prod_nw[$i-1]\n" #remember that arrays start at 0
------------------------------
Date: Tue, 2 Mar 1999 08:00:09 -0000
From: "MAW" <maw@markaw.demon.co.uk>
Subject: Execute the Command Line
Message-Id: <920361420.15397.0.nnrp-07.c2deffc1@news.demon.co.uk>
Hi There,
Like many other people, it would appear I am also new to Perl - Only three
days! However, I am trying to write a script on WIN32 initially - later
Linux which will execute a command line and then show me the results.
Basically, I am trying to execute a "netstat -a" every 20 seconds for a
totla period of 2 minutes. I believe I am correct in saying that to do this
I need to get hold of the Win32::Shell module. However, I have been to the
CPAN site and it is not there. Can anyone help me or direct me to where I
can find this? Also, what do I do when it comes to taking this over to
Linux - obviously the Win32::Shell module is not going to work there.
Thank you in advance.
-MAW-
------------------------------
Date: 1 Mar 1999 21:12:33 GMT
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: file comfirmation
Message-Id: <slrn7dm0qr.8g3.fl_aggie@enso.coaps.fsu.edu>
On Tue, 02 Mar 1999 01:10:22 +0800, Cplee <cplee@bigfoot.com> wrote:
+ Howto use perl to confirm exist file
+ please help
You mean like this?
if (-e $file) {
print "$file exists\n";
}else{
print "$file does not exist\n";
}
James
------------------------------
Date: Tue, 2 Mar 1999 09:07:14 +0200
From: "Ian Coetzee" <seccoza@mweb.co.za>
Subject: File locking ?
Message-Id: <36db8f81.0@news1.mweb.co.za>
Hi
I have a big problem I am trying to figure out how to use flock() , the
information I got tells me that flock() might not work on a networking
environment , so what is the use then ? Does anybody know how to implement
file locking on a "flat file" which is to be used on the internet (as in a
classified adds program). Can any body please help me ,
As I am new to Perl (but a seasoned Delphi and pascal developer) i would
like any answers to be as descriptive as possable.
Thx's
Ian Coetzee
seccoza@mweb.co.za
------------------------------
Date: Tue, 02 Mar 1999 07:36:08 GMT
From: Colin Cyr <ccyr@home.com>
Subject: File::Path and tainted directory names.
Message-Id: <36DB9539.7337CA7B@home.com>
Well folks this has be baffled!
The following code tells me there is an insecure dependancy in
File::Path when it attempts the unlink command on an SUID/SGID script.
The part that baffles me is it works properly in the same script except
I'm calling mkpath instead of rmtree.
---Script---
use File::Path;
sub test {
my $dir = shift;
if ($dir =~ /^([-\w.]+)$/) {
return unless -d $1;
rmtree ($1);
return $1;
}
}
print 'Removed: ', &test;
----
All help appreciated.
------------------------------
Date: 2 Mar 1999 07:17:46 GMT
From: akbishop@aol.com (AKBishop)
Subject: Hashes in Files
Message-Id: <19990302021746.11949.00003552@ng-cg1.aol.com>
How would I go about saving a hash to a file and then loading it later. I can
save the hash to the file by:
# %keys is defined earlier
open(inv_keys, "> inv_keys.dat") || die "Couldn't open output file!\n";
print inv_keys %keys;
close (inv_keys);
That seems to work, but I can't get them to load back into a hash properly.
Any ideas?
Thanks,
AKBishop@aol.com
------------------------------
Date: Tue, 02 Mar 1999 06:43:35 GMT
From: mr_potato_head@my-dejanews.com
Subject: Help, Perl script question
Message-Id: <7bg1am$3em$1@nnrp1.dejanews.com>
Hi, I would like to write a perl script that can run in a cron, telnet to
another machine, login, print commands to the screen, wait for xxx time or
wait for a trigger to continue, and capture the results to a file. Simple
huh. My biggest problem is I don't know how to print a command to the screen
so that the device on the other side will respond by sending back the results
and most importantly, WAIT for xxx amount of time before continuing or WAIT
for a specific trigger. I basically want to write a perl script to simulate
a communications program like crosstalk or procomm plus. I need to do all of
this on my unix station. Any help would be appreciated. Thanks in
advance...
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Tue, 02 Mar 1999 08:30:01 +0100
From: "Mathias-H. Weber" <Mathias-Henry.Weber@de.heidelberg.com>
Subject: Re: Help, Perl script question
Message-Id: <36DB9379.881521DF@de.heidelberg.com>
mr_potato_head@my-dejanews.com wrote:
>
> Hi, I would like to write a perl script that can run in a cron, telnet to
> another machine, login, print commands to the screen, wait for xxx time or
> wait for a trigger to continue, and capture the results to a file. Simple
> huh. My biggest problem is I don't know how to print a command to the screen
> so that the device on the other side will respond by sending back the results
> and most importantly, WAIT for xxx amount of time before continuing or WAIT
> for a specific trigger. I basically want to write a perl script to simulate
> a communications program like crosstalk or procomm plus. I need to do all of
> this on my unix station. Any help would be appreciated. Thanks in
> advance...
Have a look at the Expect module. It covers most of your central
problems.
You will find it in the CPAN.
Mathias
------------------------------
Date: Mon, 1 Mar 1999 21:10:42 -0800
From: moseley@best.com (Bill Moseley)
Subject: Re: HTML::TreeBuilder - any other options?
Message-Id: <MPG.114512b1b0db4f139896c7@206.184.139.132>
I just installed HTML::TreeBuilder, but I'm not having the luck I had
expected.
I was wishing for something that would validate a HTML snippet since the
HTML snippet will be placed within an existing HTML document, and
inserted bad HTML could screw up the entire page display.
The idea was to use HTML::TreeBuilder to validate the HTML snippet when
added via a CGI form and then, if TreeBuilder reported an error, explain
that the HTML is not valid and must be corrected.
In the example below, I was wishing that HTML::TreeBuilder would tell me
that I've misspelled the ending </TABEL> and that I'm missing '>' on the
<TD>.
#! perl -w
use strict;
my $html = '<TABLE>
<TR>
<TD
Hello
</TD>
</TR>
</TABEL>';
use HTML::TreeBuilder;
my $h = new HTML::TreeBuilder;
print "\nHTML::TreeBuilder version: $HTML::TreeBuilder::VERSION\n\n";
$h->ignore_text( 1 ); # just validate
$h->warn( 1 ); # Call warn() on syntax errors
$h->parse( $html );
print $h->as_HTML;
perl html
Ambiguous call resolved as CORE::warn(), qualify as such or use & at
D:\PERL5\site\lib/HTML/TreeBuilder.pm line 160.
HTML::TreeBuilder version: 2.03
<HTML><BODY><P><TABLE> <TR> <TD Hello </TR> </TABLE></BODY></HTML>
Well, no warning message about the bad HTML, but it did 'correct' it. I
could just replace the bad HTML with the output from TreeBuilder, but
then I lose the original formatting.
Any suggestions on a way to validate a piece of HTML short of using LWP
to pass the HTML to one of the on-line HTML validation services?
Also, It seems odd that I'm receiving the 'Ambiguous call resolved as
CORE::warn()...' warning. I shouldn't have to go in to TreeBuilder.pm
and change the module, should I?
sub warning
{
my $self = shift;
warn "HTML::Parse: $_[0]\n" if $self->{'_warn'};
}
to:
sub warning
{
my $self = shift;
CORE::warn "HTML::Parse: $_[0]\n" if $self->{'_warn'};
}
Thanks very much,
------------------------------
Date: 02 Mar 1999 02:10:19 -0500
From: Jonathan Feinberg <jdf@pobox.com>
To: moseley@best.com (Bill Moseley)
Subject: Re: HTML::TreeBuilder - any other options?
Message-Id: <m37lt0icys.fsf@joshua.panix.com>
moseley@best.com (Bill Moseley) writes:
> Ambiguous call resolved as CORE::warn(), qualify as such or use & at
> D:\PERL5\site\lib/HTML/TreeBuilder.pm line 160.
> HTML::TreeBuilder version: 2.03
That's an old version. Version 2.06 has the CORE::warn() construct.
Upgrade.
This program works fine for me:
#!/usr/bin/perl -w
use strict;
require HTML::TreeBuilder;
sub HTML_WARN {
chomp(my $msg = shift);
print "$msg\n";
}
my $good_html = '<html><head></head><body>hello</body></html>';
my $bad_html = '<html><head></head><boldly>hello</html>';
my $h = new HTML::TreeBuilder;
$h->warn(1); # turn on warning on errors
print "Parsing \$good_html.\n";
{
local $SIG{__WARN__} = \&HTML_WARN;
$h->parse($good_html);
}
print "Parsing \$bad_html.\n";
{
local $SIG{__WARN__} = \&HTML_WARN;
$h->parse($bad_html);
}
print "Done.\n"
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
http://pobox.com/~jdf
------------------------------
Date: Tue, 02 Mar 1999 01:42:54 -0500
From: Wally <wally@sub-zero.mit.edu>
Subject: Odd Experience
Message-Id: <36DB886E.5C82F20F@sub-zero.mit.edu>
Hello all. Had an odd experience tonight at an Open House for MIT's EECS
internship program.
I was talking with a cat from Company X. I said that I had been writing
a lot of Perl lately, and was "falling unashamedly in love with the
language".
His response: "That's unfortunate. You and your Perl code will become
one, inextricably linked. <laughter>"
Perl is *not* write-only, I tell myself. But it LOOKS that way! :)
Cheers,
Wally
------------------------------
Date: Mon, 1 Mar 1999 22:30:37 -0800
From: "My News" <giudice@ix.netcom.com>
Subject: Re: regexp
Message-Id: <7bg0r7$pal@dfw-ixnews4.ix.netcom.com>
Try this:
$_ =3D 'http://www.whatever.com/what/index.html#what';
($_)=3D/.*\/(.*\.)/;s/\./\.txt/;
Some excellent examples on regex and parsing can be found on =
http://www.cclabs.missouri.edu/things/instruction/perl/perlcourse.html=20
hg
Mark P. wrote in message <36d9d38e.620074800@news.ionet.net>...
>Okay, I got the first part with the following, however, I am still not
>able to get the last part of the url to go away. Oh well, I just guess
>I'll make do with this.
>
>$file =3D "$ENV{'HTTP_REFERER'}";
>$file =3D~ s/.*[\\\/:]//i;
>$file =3D~ s/.html/.txt/ig;
>$file =3D~ s/.shtml/.txt/ig;
>$file =3D~ s/.htm/.txt/ig;
>
> Probably not as elegent a solution as most of you would
>create, but it does work.<G>
>
>
------------------------------
Date: Tue, 02 Mar 1999 06:36:19 GMT
From: theoj@transport.com (theo jones)
Subject: Urgent Help Please!? --> Multiline Reading of data files...
Message-Id: <36db86b3.117749912@news.transport.com>
I"m trying to munge a whole lotat data files of this nature:
bioFilename{first_m.html}
bioFirst{FirstName}
bioMiddle{M. }
bioLast{LastName}
bioContent{La La La La La, Yadda Yadda Yadda La La La La La, Yadda
Yadda YaddaLa La La La La, Yadda Yadda YaddaLa La La La La, Yadda
Yadda YaddaLa La La La La, Yadda Yadda YaddaLa La La La La, Yadda
Yadda YaddaLa La La La La, Yadda Yadda YaddaLa La La La La, Yadda
Yadda YaddaLa La La La La, Yadda Yadda Yadda}
I am experiencing extreme frustration however with the PERL script I
was given to modify for this new set of data files.
Here is the script, it does fine until it reaches the last field-value
pair (which is multiline and contains html code sometimes), then will
only read until it hits a \n character I am guessing:
open(LISTFILE,"<alpha-list.idx");
open(RESULT, ">bioTable.txt");
open(ERRFILE, ">errorFile.txt");
####################################
# read from LISTFILE the ID numbers
# Use them to generate filenames
# for the bio data
####################################
@IDlist = ();
while ($nextFile = <LISTFILE>) {
$nextFile =~ s/{([^\d]*)(\d*)}\d*\n/\2/; #get bio ID
### check to see if we have a duplicate in the bio list
foreach $visitedID(@IDlist) {
if ($visitedID == $nextFile) {
$repeat = 1; last;
}
}
### if a duplicate, then skip,
##otherwise, put UID in list and continue
if ($repeat == 1) {
$repeat = 0;
next;
} else {
push(@IDlist,$nextFile);
}
$biofile = "bio" . $nextFile . ".dat"; #format
file-name w/ ID number
if (!open(BIOFILE, $biofile)) {
print (ERRFILE "Can't find file named: " . $biofile .
"\n");
}
## else {
#############################################
# for each field, parse the line and get out
# the relevant data. If an expected field is
# missing, then report the missing field to
# the error file and skip to next ID number
# and bio file.
#############################################
### bioFirst ###
else {
$line = <BIOFILE>;
@tokens = split(/{/, $line);
$fieldname = $tokens[0];
if ($fieldname eq "bioFilename") {
$tokens[1]=~ s/(.*)}\n/\1/;
printf (RESULT "\t".$tokens[1]);
}
else {
print(ERRFILE "Error with ".$biofile.":
problem at 'bioFilename'\n");
next;
}
### bioFilename ###
$line = <BIOFILE>;
@tokens = split(/{/, $line);
$fieldname = $tokens[0];
if ($fieldname eq "bioFirst") {
$tokens[1]=~ s/(.*)}\n/\1/;
printf (RESULT "\t".$tokens[1]);
}
else {
print(ERRFILE "Error with ".$biofile.":
problem at 'bioFirst'\n");
next;
}
### bioMiddle ###
$line = <BIOFILE>;
@tokens = split(/{/, $line);
$fieldname = $tokens[0];
if ($fieldname eq "bioMiddle") {
$tokens[1]=~ s/(.*)}\n/\1/;
printf (RESULT "\t". $tokens[1]);
}
else {
print(ERRFILE "Error with ".$biofile.":
problem at 'bioMiddle'\n");
next;
}
### bioLast ###
$line = <BIOFILE>;
@tokens = split(/{/, $line);
$fieldname = $tokens[0];
if ($fieldname eq "bioLast") {
$tokens[1]=~ s/(.*)}\n/\1/;
printf (RESULT "\t".$tokens[1]);
}
else {
print(ERRFILE "Error with ".$biofile.":
problem at 'bioLast'\n");
next;
}
### bioContent ###
$line = <BIOFILE>;
@tokens = split(/{/, $line);
$fieldname = $tokens[0];
if ($fieldname eq "bioContent") {
$tokens[1]=~ s/(.*)}/\1/g;
if ($tokens[1] ne "}") { $exp = $tokens[1]; }
}
$exp =~ s/\t//g;
print (RESULT "\t".$exp);
}
print (RESULT "\n\n");
}
close(LISTFILE);
close(BIOFILE);
close(ERRFILE);
close(RESULT);
------------------------------
Date: Tue, 02 Mar 1999 03:52:55 GMT
From: richm@ucesucks.rochester.rr.com (Rich)
Subject: Re: URGENT help required!!
Message-Id: <slrn7dmo9n.rsr.richm@ll.aa2ys.ampr.org>
On Mon, 1 Mar 1999 13:15:42 -0000, Richard Partridge <r.partridge@dewynters.com> wrote:
>
>I want my perl script to open a data file on a seperate webserver...
>so I thought I could use something like
>
>(filehandle,">> http://www.somewhere.com/cgi-bin/datafile.txt");
>
>Is this legal perl as it doesn't seem to be working for me.....
>
Well, the first thing to do is learn the difference between a URL
and a file name...
- Rich
--
Rich Mulvey
http://mulvey.dyndns.com
Amateur Radio: aa2ys@wb2wxq.#wny.ny.usa
------------------------------
Date: Tue, 2 Mar 1999 15:12:20 +0800
From: "Ada" <adayuen@hotmail.com>
Subject: what is actually path to compile perl in cgi-bin
Message-Id: <7bg2fl$7k6@news1.cityu.edu.hk>
i've written a test.pl and a html to compile it in Win NT
but the output is the test.pl coding itself
i think the coding is not interperted
where to place the code that the .pl program can be executed also
what is the http path ?
------------------------------
Date: Tue, 2 Mar 1999 03:35:12 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: Why can't my .pl find my SCRIPT ??
Message-Id: <ebohlmanF7y7Ao.Lrr@netcom.com>
Michael Fuerst <mfuerst@advancenet.net> wrote:
: # attempt to pull out <SCRIPT .... </SCRIPT>
: # This next line prints and puts only an ascii 10 and an ascii 32 into
: $1
: # (PROBLEM 1: I would think that this would put everything between
: <SCRIPT> and </SCRIPT> into $1)
: print $page =~ m'^\s*<SCRIPT.*>(.*)</SCRIPT>'smg;
The '.*' after 'SCRIPT' is greedy and matches everything up to the last
'>' before '</SCRIPT>', leaving only a newline and a space for the parens
to capture. You need to make it non-greedy: .*?
: <SCRIPT LANGUAGE="JavaScript">
^ ^ Here's where you want the match to end
^
^ Here's where the '.*' starts matching
: <!--
: var ON = 1;
: var OFF = 0;
: var TRUE = 1;
: var FALSE = 0;
: var NOANS = "DKNA";
: ChooseOneSet("<B>Heading for ChooseOneSet</B>", 2,"vcs", "cs1",
: "Item1",
: "alkjf a;lkjf aojf a;jkf a;skjf a f ;akdjf fjajf
: a;ljdf al; a;sjf a;skjf asjdf a;sjkdf ;asjdf ;akjsdf
: ;ajsdf ;aksjdf ;alksjdf ;fajsd f "+
: "as;lkjfakjflkdj;ksdfjjf ;ljdf ;lajsf ;ajf sl f");
: ChooseOne("varchooseone","cs1","First choose one");
: BRANCH("v.vcs1=='aa return'","cmt2");
: UserInfo("<H1>Heading H1</H1>","<H2>Heading H2</H2>");
: CheckBox("cb1","This is a first checkbox");
: oneNodePerPage=1;
: CheckBox("cb2","This is a second checkbox");
: Comment("cmtname","This is a comment",10,40);
: Comment("cmt2","Comment2<BR>This comment2.",10,50);
: // end hide -->
^ But here's where it really ends
: </SCRIPT>
------------------------------
Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>
Administrivia:
Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing.
]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body. Majordomo will then send you instructions on how to confirm your
]subscription. This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.
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 5030
**************************************