[24172] in Perl-Users-Digest
Perl-Users Digest, Issue: 6364 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Apr 5 09:05:40 2004
Date: Mon, 5 Apr 2004 06:05:07 -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, 5 Apr 2004 Volume: 10 Number: 6364
Today's topics:
Archive::Zip corrupts JAR's?? (rog)
Re: Archive::Zip corrupts JAR's?? <nospam@bigpond.com>
Can PERL code check is email of sender is valid? <gp@nospm.hr>
Re: Can PERL code check is email of sender is valid? (Anno Siegel)
Re: Can PERL code check is email of sender is valid? <me@privacy.net>
Re: Can PERL code check is email of sender is valid? <me@privacy.net>
Re: Can PERL code check is email of sender is valid? <mr@sandman.net>
Re: CGI::Carp and "useless quotes" <noreply@gunnar.cc>
custom perl interpreter? <mikee@mikee.ath.cx>
Re: custom perl interpreter? (Randal L. Schwartz)
Re: custom perl interpreter? <peter@semantico.com>
Re: custom perl interpreter? <tassilo.parseval@rwth-aachen.de>
Re: HTML Tag Counter <gisle@activestate.com>
Re: Possible to open a Berkeley 4.2 db file with DB_Fil <Paul.Marquess@btinternet.com>
Re: real, simple sample OOP intro text??!! <geoffacox@dontspamblueyonder.co.uk>
Re: real, simple sample OOP intro text??!! <geoffacox@dontspamblueyonder.co.uk>
Re: real, simple sample OOP intro text??!! <tassilo.parseval@rwth-aachen.de>
Re: real, simple sample OOP intro text??!! <geoffacox@dontspamblueyonder.co.uk>
Unknown function <mjpliv@eastlink.ca>
Re: Unknown function <mr@sandman.net>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 5 Apr 2004 01:22:48 -0700
From: r_foskett@hotmail.com (rog)
Subject: Archive::Zip corrupts JAR's??
Message-Id: <a5839bae.0404050022.66fbf395@posting.google.com>
Hi, I am having problems with adding new files (via winzip/winwar etc)
to JAR files that have been opened and saved using Archive::Zip - EG:
use strict;
use Archive::Zip;
my $testfile = 'ZipTest';
open (FH,">$testfile.java") || die "Error: $!\n";
print FH <<EOF;
public class ZipTest {
public static void main (String [] args) {
System.out.println("This is a test");
}
}
EOF
close FH;
unlink "$testfile.jar";
print `javac $testfile.java`;
print `jar cf ZipTest.jar $testfile.class`;
my $zip = Archive::Zip->new("$testfile.jar");
$zip->overwrite(); # this corrupts jar file somehow as Windows
# Zip tools can read the archive but cant add files to it
Any ideas would be appreciated. I'm using ActivePerl v5.8.3 with
Archive::Zip v1.82 and Java v1.4.2
Many thanks
Roger
------------------------------
Date: Mon, 05 Apr 2004 22:43:39 +1000
From: Gregory Toomey <nospam@bigpond.com>
Subject: Re: Archive::Zip corrupts JAR's??
Message-Id: <6150902.A7iIX16l9A@GMT-hosting-and-pickle-farming>
rog wrote:
> Hi, I am having problems with adding new files (via winzip/winwar etc)
> to JAR files that have been opened and saved using Archive::Zip - EG:
>
> use strict;
> use Archive::Zip;
> my $testfile = 'ZipTest';
> open (FH,">$testfile.java") || die "Error: $!\n";
> print FH <<EOF;
> public class ZipTest {
> public static void main (String [] args) {
> System.out.println("This is a test");
> }
> }
> EOF
> close FH;
> unlink "$testfile.jar";
> print `javac $testfile.java`;
> print `jar cf ZipTest.jar $testfile.class`;
> my $zip = Archive::Zip->nehttp://linuxshop.ru/linuxbegin/win-lin-soft-en
table.shtmlw("$testfile.jar");
> $zip->overwrite(); # this corrupts jar file somehow as Windows
> # Zip tools can read the archive but cant add files to it
>
> Any ideas would be appreciated. I'm using ActivePerl v5.8.3 with
> Archive::Zip v1.82 and Java v1.4.2
>
> Many thanks
> Roger
I think you have to simplify your example.
When I started using Archive::Zip, I did manage to write "zip" files that
could not be read in some circumstances. It turned out to be a bug on my
part. Now I use Archive::Zip thousnands of times per day & works fine. I've
never used the overwrite method.
gtoomey
------------------------------
Date: Mon, 5 Apr 2004 13:11:05 +0200
From: "PHP2" <gp@nospm.hr>
Subject: Can PERL code check is email of sender is valid?
Message-Id: <c4reqj$c93$1@ls219.htnet.hr>
Hello,
Can PERL code check is email of sender is valid?
If someone send email from example: wrongemail@hotmail.com PERL code must
check: can wrongemail@hotmail.com receive email (without sending test
email).. if wrongemail@hotmail.com can receive email code inform me about
that..
I need any possible ideas.. :-))
thanks,
-GP
------------------------------
Date: 5 Apr 2004 11:44:11 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Can PERL code check is email of sender is valid?
Message-Id: <c4rgqb$dtq$1@mamenchi.zrz.TU-Berlin.DE>
PHP2 <gp@nospm.hr> wrote in comp.lang.perl.misc:
> Hello,
>
> Can PERL code check is email of sender is valid?
>
> If someone send email from example: wrongemail@hotmail.com PERL code must
> check: can wrongemail@hotmail.com receive email (without sending test
> email).. if wrongemail@hotmail.com can receive email code inform me about
> that..
In general, there is no way of knowing if an address is deliverable
except by sending mail there. This has nothing to do with Perl (not
"PERL").
Anno
------------------------------
Date: Mon, 5 Apr 2004 23:55:19 +1200
From: "Tintin" <me@privacy.net>
Subject: Re: Can PERL code check is email of sender is valid?
Message-Id: <c4rhdn$2h8sdh$1@ID-172104.news.uni-berlin.de>
"PHP2" <gp@nospm.hr> wrote in message news:c4reqj$c93$1@ls219.htnet.hr...
> Hello,
>
> Can PERL code check is email of sender is valid?
A more valid question is whether *any* programming language can check the
validity of an email address.
>
> If someone send email from example: wrongemail@hotmail.com PERL code must
> check: can wrongemail@hotmail.com receive email (without sending test
> email).. if wrongemail@hotmail.com can receive email code inform me about
> that..
>
> I need any possible ideas.. :-))
Not possible in most cases. You'll need to rethink your requirements.
About the closest you'll get is what's available in Email::Valid
See http://search.cpan.org/~maurice/Email-Valid-0.15/Valid.pm
------------------------------
Date: Mon, 5 Apr 2004 23:57:46 +1200
From: "Tintin" <me@privacy.net>
Subject: Re: Can PERL code check is email of sender is valid?
Message-Id: <c4rhia$2m3d06$1@ID-172104.news.uni-berlin.de>
"Tintin" <me@privacy.net> wrote in message
news:c4rhdn$2h8sdh$1@ID-172104.news.uni-berlin.de...
>
> "PHP2" <gp@nospm.hr> wrote in message news:c4reqj$c93$1@ls219.htnet.hr...
> > Hello,
> >
> > Can PERL code check is email of sender is valid?
>
> A more valid question is whether *any* programming language can check the
> validity of an email address.
>
> >
> > If someone send email from example: wrongemail@hotmail.com PERL code
must
> > check: can wrongemail@hotmail.com receive email (without sending test
> > email).. if wrongemail@hotmail.com can receive email code inform me
about
> > that..
> >
> > I need any possible ideas.. :-))
>
> Not possible in most cases. You'll need to rethink your requirements.
>
> About the closest you'll get is what's available in Email::Valid
>
> See http://search.cpan.org/~maurice/Email-Valid-0.15/Valid.pm
Actually, I should also mention Mail::CheckUser
See http://search.cpan.org/~ilyam/Mail-CheckUser-1.21/CheckUser.pm
In particular, the following paragraph:
In many cases there is no way to detect the validity of email addresses with
network checks. For example, non-monolithic mail servers (such as Postfix
and qmail) often report that a user exists even if it is not so. This is
because in cases where the work of the server is split among many
components, the SMTP server may not know how to check for the existence of a
particular user. Systems like these will reject mail to unknown users, but
they do so after the SMTP conversation. In cases like these, the only
absolutely sure way to determine whether or not a user exists is to actually
send a mail and wait to see if a bounce messages comes back. Obviously, this
is not a workable strategy for this module. Does it mean that the network
checks in this module are useless? No. For one thing, just the DNS checks go
a long way towards weeding out mistyped domain parts. Also, there are still
many SMTP servers that will reject a bad address during the SMTP
conversation. Because of this, it's still a useful part of checking for a
valid email address. And this module was designed such that if there is
exists possibility (however small) that the email address is valid, it will
be treated as valid by this module.
------------------------------
Date: Mon, 05 Apr 2004 14:12:37 +0200
From: Sandman <mr@sandman.net>
Subject: Re: Can PERL code check is email of sender is valid?
Message-Id: <mr-CA37B2.14123705042004@news.fu-berlin.de>
In article <c4reqj$c93$1@ls219.htnet.hr>, "PHP2" <gp@nospm.hr> wrote:
> Hello,
>
> Can PERL code check is email of sender is valid?
>
> If someone send email from example: wrongemail@hotmail.com PERL code must
> check: can wrongemail@hotmail.com receive email (without sending test
> email).. if wrongemail@hotmail.com can receive email code inform me about
> that..
>
> I need any possible ideas.. :-))
perldoc perlfaq9
How do I check a valid mail address?
You can't, at least, not in real time. Bummer, eh?
Without sending mail to the address and seeing whether
there's a human on the other hand to answer you, you can-
not determine whether a mail address is valid. Even if
you apply the mail header standard, you can have problems,
because there are deliverable addresses that aren't
RFC-822 (the mail header standard) compliant, and
addresses that aren't deliverable which are compliant.
--
Sandman[.net]
------------------------------
Date: Mon, 05 Apr 2004 14:19:05 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: CGI::Carp and "useless quotes"
Message-Id: <c4rj0r$2lcqc2$1@ID-184292.news.uni-berlin.de>
Matt Garrish wrote:
> Gunnar Hjalmarsson wrote:
>> both 1.26 and 1.27 fails to print the error string when $! is
>> passed unquoted to die().
>
> Here's the culprit (in the die subroutine):
>
> realdie @_ if ineval;
>
> it seems @_ is reset if $! is not quoted (try dumping @_ to STDERR
> before and after this line ($arg is "join"ed with @_ in the
> following block, and the 'at line...' is appended, hence your
> stunted output)).
Yes, you are right. The underlying 'culprit' seems to be this line in
the _longmess() function:
my $message = Carp::longmess();
i.e. the explanation is to be found in another module... (I haven't
checked out that).
Anyway, this is what the beginning of the die() function in CGI::Carp
currently looks like:
sub die {
my ($arg) = @_;
realdie @_ if ineval;
if (!ref($arg)) {
$arg = join("", @_);
I suppose it would be a good idea to change those lines to:
sub die {
my ($arg) = @_;
my @args = @_;
realdie @args if ineval;
if (!ref($arg)) {
$arg = join("", @args);
That may make a difference when run under mod_perl as well.
What do you think? Should I pass the suggestion to Mr. Stein?
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Mon, 05 Apr 2004 12:30:31 -0000
From: Mike <mikee@mikee.ath.cx>
Subject: custom perl interpreter?
Message-Id: <1072kb7853g2c9a@corp.supernews.com>
I have a script that works fine that you give a specification
file to on the command line.
$ script.pl -f specfile
What I want to do is turn the command line around, but what
do I put as the magic in the specfile? What I'm trying to
do is this:
$ specfile
where the magic in specfile is:
#!/opt/local/bin/script.pl -f
Any ideas?
Mike
------------------------------
Date: 05 Apr 2004 05:35:40 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: custom perl interpreter?
Message-Id: <86vfke8uw3.fsf@blue.stonehenge.com>
*** post for FREE via your newsreader at post.newsfeed.com ***
>>>>> "Mike" == Mike <mikee@mikee.ath.cx> writes:
Mike> #!/opt/local/bin/script.pl -f
Mike> Any ideas?
The "interpreter" in #! must be an actual binary, not a script.
But you can turn a script into a binary (at some loss in speed)
with PAR. See PAR in the CPAN.
print "Just another Perl hacker,"
--
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!
-----= Posted via Newsfeed.Com, Uncensored Usenet News =-----
http://www.newsfeed.com - The #1 Newsgroup Service in the World!
-----== 100,000 Groups! - 19 Servers! - Unlimited Download! =-----
------------------------------
Date: Mon, 05 Apr 2004 14:03:17 +0100
From: Peter Hickman <peter@semantico.com>
Subject: Re: custom perl interpreter?
Message-Id: <40715917$0$13620$afc38c87@news.easynet.co.uk>
Mike wrote:
> I have a script that works fine that you give a specification
> file to on the command line.
>
> $ script.pl -f specfile
>
> What I want to do is turn the command line around, but what
> do I put as the magic in the specfile? What I'm trying to
> do is this:
>
> $ specfile
>
> where the magic in specfile is:
>
> #!/opt/local/bin/script.pl -f
>
> Any ideas?
>
> Mike
I think that the best you will get is
#!/usr/bin/perl /opt/local/bin/script.pl -f
and the rest of the file is the contents of specfile. At least thats the
way I got it to work for me.
------------------------------
Date: 5 Apr 2004 13:03:41 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: custom perl interpreter?
Message-Id: <c4rlfd$scb$1@nets3.rz.RWTH-Aachen.DE>
Also sprach Randal L. Schwartz:
>>>>>> "Mike" == Mike <mikee@mikee.ath.cx> writes:
>
>Mike> #!/opt/local/bin/script.pl -f
>
>Mike> Any ideas?
>
> The "interpreter" in #! must be an actual binary, not a script.
> But you can turn a script into a binary (at some loss in speed)
> with PAR. See PAR in the CPAN.
I don't know how portable this is, but for me (on Linux) this works:
#!/usr/bin/perl script.pl
Tassilo
--
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval
------------------------------
Date: 05 Apr 2004 01:08:14 -0700
From: Gisle Aas <gisle@activestate.com>
Subject: Re: HTML Tag Counter
Message-Id: <m31xn2q235.fsf@eik.i-did-not-set--mail-host-address--so-shoot-me>
hahsmirak@yahoo.com (Shah Karim) writes:
> I am looking for a simple script that will count the tags in an HTML
> document, and tally up the total number of occurences of each tag. The
> end result should be a list of all tags found and the number of times
> each tag was encountered.
>
> Does anyone know if such a program is available freely somewhere?
This is such a program.
------------------------------------------------------------->%-----
#!/usr/bin/perl -w
use strict;
use HTML::Parser;
my %count;
my $p = HTML::Parser->new(start_h => [sub { $count{$_[0]}++ }, "tagname"],
end_h => [sub { $count{"/$_[0]"}++ }, "tagname"],
);
$p->parse_file(*STDIN);
for (sort { $count{$b} <=> $count{$a} } keys %count) {
printf "%5d %s\n", $count{$_}, $_;
}
------------------------------
Date: Mon, 5 Apr 2004 10:09:00 +0100
From: "Paul Marquess" <Paul.Marquess@btinternet.com>
Subject: Re: Possible to open a Berkeley 4.2 db file with DB_File?
Message-Id: <c4r7nl$2imvcm$1@ID-211855.news.uni-berlin.de>
"187" <bigal187.invalid@adexec.com> wrote in message
news:c4klm9$2h7qo2$1@ID-196529.news.uni-berlin.de...
> Is it possible to open a Berkeley 4.2 db file with DB_File?
>
> It doesn't not seem to want to open:
>
> unless ($st = tie %db, "DB_File", 'somedbfile.db', O_RDONLY, 0640,
> $DB_HASH) {
> die "Cannot open file 'somedbfile.db': $!\n";
> }
>
> This code dies when I run it.
> (And curiously $! seems to be empty:
> Cannot open file 'somedbfile.db':
> )
>
> I did a db dump from the db file and heres the header:
>
> VERSION=3
> format=print
> database=a_test_db
> type=hash
> h_nelem=3
> db_pagesize=4096
>
> Is there any way to read this version of a berk db file in Perl? Thanks.
> (Google didn't give mcuh help either, I kept running into posts abotu
> using berk 1.* .)
DB_File can read any Berkeley DB database file, as long as it has been built
with a compatible version of the Berkeley DB library. The Berkeley DB
database format has changed a number of times, so you need to make sure
DB_File has been built with the correct one.
Run this to see what version of Berkeley DB your DB_File was built with.
perl -e 'use DB_File; print qq{Berkeley DB ver $DB_File::db_ver\n}'
If you want to interoperate with a database file created with Berkeley DB
4.2, you need to have built DB_File with Berkeley DB 4.1 or 4.2.
cheers
Paul
------------------------------
Date: Mon, 05 Apr 2004 07:34:02 GMT
From: Geoff Cox <geoffacox@dontspamblueyonder.co.uk>
Subject: Re: real, simple sample OOP intro text??!!
Message-Id: <nm2270ppu6q0bms4prmvl7smq25tji4se8@4ax.com>
On 4 Apr 2004 18:20:36 GMT, "Tassilo v. Parseval"
<tassilo.parseval@rwth-aachen.de> wrote:
>It doesn't. It only finds <h2>. </h2> is handled by the end() method.
>The part between those tags is handled by text() or again start() and
>end() in case other tags are nested inside the header.
Tassilo
have used your code and my version works now! You will see that I have
extended it to work for <p> and that too works. I am not clear why the
following line appears in the start, end and text sub. I would have
thought it would appear just once...I am not following the logic??
print OUT ("<h2>$origtext</h2> \n") if $in_heading;
Cheers
Geoff
my $in_heading;
my $p;
sub start {
my ($self, $tagname, $attr, undef, undef, $origtext) = @_;
if ($tagname eq 'option') {
&getintro($attr->{ value });
}
if ($tagname eq 'h2') {
$in_heading = 1;
return;
}
print OUT ("<h2>$origtext</h2> \n") if $in_heading;
if ($tagname eq 'p') {
$p = 1;
return;
}
print OUT ("$origtext \n") if $p;
}
sub end {
my ($self, $tagname, $origtext) = @_;
if ($tagname eq 'h2') {
$in_heading = 0;
return;
}
print OUT ("<h2>$origtext</h2> \n") if $in_heading;
if ($tagname eq 'p') {
$p = 0;
return;
}
print OUT ("$origtext \n") if $p;
}
sub text {
my ($self, $origtext) = @_;
print OUT ("<h2>$origtext</h2> \n") if $in_heading;
print OUT ("$origtext \n") if $p;
}
------------------------------
Date: Mon, 05 Apr 2004 07:38:27 GMT
From: Geoff Cox <geoffacox@dontspamblueyonder.co.uk>
Subject: Re: real, simple sample OOP intro text??!!
Message-Id: <jv2270ltri83lb8t1dio0jt13cil2mettk@4ax.com>
On Sun, 04 Apr 2004 19:47:44 GMT, Uri Guttman <uri@stemsystems.com>
wrote:
>damn, you found out that i sekritly control book prices all over the
>world. i set them high in london just so you wouldn't buy the one book
>you really need! now i will have to find some other suckers^Wreaders for
>damian's book. and i don't even get a kickback from him for any books
>sales!
Uri
wouldn't dream of suggesting you are personally responsible for this!!
if a book costs say $30 in the US and £30 here - does it really cost
£10 to get it into a shop the UK??
Cheers
Geoff
------------------------------
Date: 5 Apr 2004 09:29:09 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: real, simple sample OOP intro text??!!
Message-Id: <c4r8t5$erl$1@nets3.rz.RWTH-Aachen.DE>
Also sprach Geoff Cox:
> On 4 Apr 2004 18:20:36 GMT, "Tassilo v. Parseval"
><tassilo.parseval@rwth-aachen.de> wrote:
>
>>It doesn't. It only finds <h2>. </h2> is handled by the end() method.
>>The part between those tags is handled by text() or again start() and
>>end() in case other tags are nested inside the header.
>
> Tassilo
>
> have used your code and my version works now! You will see that I have
> extended it to work for <p> and that too works.
Glad to hear it.
> I am not clear why the following line appears in the start, end and
> text sub. I would have thought it would appear just once...I am not
> following the logic??
>
> print OUT ("<h2>$origtext</h2> \n") if $in_heading;
I don't think the above should appear like that in all three callbacks.
> Cheers
>
> Geoff
>
> my $in_heading;
> my $p;
>
> sub start {
>
> my ($self, $tagname, $attr, undef, undef, $origtext) = @_;
There is one undef too many. That means that $origtext will always be
undefined. Put 'use warnings;' in your code and perl will tell you that
you are printing an undefined value further below.
> if ($tagname eq 'option') {
> &getintro($attr->{ value });
> }
>
> if ($tagname eq 'h2') {
> $in_heading = 1;
> return;
> }
> print OUT ("<h2>$origtext</h2> \n") if $in_heading;
That's indeed not quite right. You create too many <h2>...</h2> pairs
with that. For this HTML snippet:
<h2><i>Heading</i></h2>
your parser spits out (assuming that you remove one of the above two
undefs):
<h2><i></h2><h2>Heading</h2><h2></i></h2>
This is because you wrap _everything_ inside <h2></h2> when $in_heading
is true.
If you want to include the heading tags in your output, then you have to do the
following:
sub start {
my ($self, $tagname, undef, undef, $origtext) = @_;
$in_heading = 1 if $tagname eq 'h2';
print $origtext if $in_heading;
}
sub text {
my ($self, $origtext) = @_;
print $origtext if $in_heading;
}
sub end {
my ($self, $tagname, $origtext) = @_;
print $origtext if $in_heading;
$in_heading = 0 if $tagname eq 'h2';
}
If you don't want to include them, you have to return from the
start/end functions without writing anything when a <h2> tag is
encountered.
As I wrote before: It takes a little time to get used to the way
HTML::Parser does the job. You have to be clear about how HTML::Parser
triggers the callbacks and what arguments are passed. Use a fixed font
for the following:
<tag attr="val"><tag1>some text</tag1></tag>
`--------------'`----'`-------'`-----'`----'
(1) (2) (3) (4) (5)
(1) start ($self,
'tag', # $tagname
{ attr => 'val' }, # $attr
[ 'attr' ], # $attrseq
'<tag attr="val">' # $origtext
);
(2) start ($self,
'tag1', # $tagname
{ }, # $attr
[ ], # $attrseq
'<tag1>' # $origtext
);
(3) text ($self,
'some text', # $origtext
0 # $is_cdata
;)
(4) end ($self,
'tag1', # $tagname
'</tag1>' # $origtext
);
(5) end ($self,
'tag', # $tagname
'</tag>' # $origtext
);
> if ($tagname eq 'p') {
> $p = 1;
> return;
> }
Unlike with the <h2> tags, here you do not print any <p> tags. So you
essentially just record when you are inside <p>, but you don't include
the <p> tags in your output.
Tassilo
--
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval
------------------------------
Date: Mon, 05 Apr 2004 11:32:29 GMT
From: Geoff Cox <geoffacox@dontspamblueyonder.co.uk>
Subject: Re: real, simple sample OOP intro text??!!
Message-Id: <6tg270tak404cjb790a6udktn9p1s7b2se@4ax.com>
On 5 Apr 2004 09:29:09 GMT, "Tassilo v. Parseval"
<tassilo.parseval@rwth-aachen.de> wrote:
>Also sprach Geoff Cox:
Tassilo,
many thanks for the corrections - will sort it out!
Cheers
Geoff
>> On 4 Apr 2004 18:20:36 GMT, "Tassilo v. Parseval"
>><tassilo.parseval@rwth-aachen.de> wrote:
>>
>>>It doesn't. It only finds <h2>. </h2> is handled by the end() method.
>>>The part between those tags is handled by text() or again start() and
>>>end() in case other tags are nested inside the header.
>>
>> Tassilo
>>
>> have used your code and my version works now! You will see that I have
>> extended it to work for <p> and that too works.
>
>Glad to hear it.
>
>> I am not clear why the following line appears in the start, end and
>> text sub. I would have thought it would appear just once...I am not
>> following the logic??
>>
>> print OUT ("<h2>$origtext</h2> \n") if $in_heading;
>
>I don't think the above should appear like that in all three callbacks.
>
>> Cheers
>>
>> Geoff
>>
>> my $in_heading;
>> my $p;
>>
>> sub start {
>>
>> my ($self, $tagname, $attr, undef, undef, $origtext) = @_;
>
>There is one undef too many. That means that $origtext will always be
>undefined. Put 'use warnings;' in your code and perl will tell you that
>you are printing an undefined value further below.
>
>> if ($tagname eq 'option') {
>> &getintro($attr->{ value });
>> }
>>
>> if ($tagname eq 'h2') {
>> $in_heading = 1;
>> return;
>> }
>> print OUT ("<h2>$origtext</h2> \n") if $in_heading;
>
>That's indeed not quite right. You create too many <h2>...</h2> pairs
>with that. For this HTML snippet:
>
> <h2><i>Heading</i></h2>
>
>your parser spits out (assuming that you remove one of the above two
>undefs):
>
> <h2><i></h2><h2>Heading</h2><h2></i></h2>
>
>This is because you wrap _everything_ inside <h2></h2> when $in_heading
>is true.
>
>If you want to include the heading tags in your output, then you have to do the
>following:
>
> sub start {
> my ($self, $tagname, undef, undef, $origtext) = @_;
> $in_heading = 1 if $tagname eq 'h2';
> print $origtext if $in_heading;
> }
>
> sub text {
> my ($self, $origtext) = @_;
> print $origtext if $in_heading;
> }
>
> sub end {
> my ($self, $tagname, $origtext) = @_;
> print $origtext if $in_heading;
> $in_heading = 0 if $tagname eq 'h2';
> }
>
>If you don't want to include them, you have to return from the
>start/end functions without writing anything when a <h2> tag is
>encountered.
>
>As I wrote before: It takes a little time to get used to the way
>HTML::Parser does the job. You have to be clear about how HTML::Parser
>triggers the callbacks and what arguments are passed. Use a fixed font
>for the following:
>
> <tag attr="val"><tag1>some text</tag1></tag>
> `--------------'`----'`-------'`-----'`----'
> (1) (2) (3) (4) (5)
>
>(1) start ($self,
> 'tag', # $tagname
> { attr => 'val' }, # $attr
> [ 'attr' ], # $attrseq
> '<tag attr="val">' # $origtext
> );
>
>(2) start ($self,
> 'tag1', # $tagname
> { }, # $attr
> [ ], # $attrseq
> '<tag1>' # $origtext
> );
>
>(3) text ($self,
> 'some text', # $origtext
> 0 # $is_cdata
> ;)
>
>(4) end ($self,
> 'tag1', # $tagname
> '</tag1>' # $origtext
> );
>
>(5) end ($self,
> 'tag', # $tagname
> '</tag>' # $origtext
> );
>
>> if ($tagname eq 'p') {
>> $p = 1;
>> return;
>> }
>
>Unlike with the <h2> tags, here you do not print any <p> tags. So you
>essentially just record when you are inside <p>, but you don't include
>the <p> tags in your output.
>
>Tassilo
------------------------------
Date: Mon, 05 Apr 2004 11:56:42 GMT
From: "Martin L." <mjpliv@eastlink.ca>
Subject: Unknown function
Message-Id: <_Pbcc.15824$kc2.322720@nnrp1.uunet.ca>
I a trying to debug a free script that allows me to place counters on
pages throught my domain. It operates using SSI's. There are no fatal
errors. The results should be a summary of my counter logs for each
page that has a counter the no log file names or contents appear.
There is one function #### @files = ('logs/*.log'); ##### I am not
familiar with and a look through PERLFUNC did not turn up anything.
Here is the context It is found in
####begin snippet
$opt = "$ENV{ 'QUERY_STRING' }";
$count_page = "$ENV{ 'QUERY_STRING' }";
if ( $opt eq "stats" ) {
@files = ('logs/*.log');
&get_files;
&CalculateStats }
####end snippet
At this point the script should be generating a list of counter log
files so that is what I am assuming this line does. I understand the
"*.logs" portion is a wild card for all files with the "log" extension
but the preceeding "logs/" I have not seen before. It is the name of
the log directory but it has not been assigned to a FILE_HANDLE
anywhere and the only other reference is as a comparison string in an
unrelated section of the script.
The page returned from the script would indicate that the "@files"
variable contained no data.
Thanks
Martin L.
------------------------------
Date: Mon, 05 Apr 2004 14:07:55 +0200
From: Sandman <mr@sandman.net>
Subject: Re: Unknown function
Message-Id: <mr-F26AE9.14075405042004@news.fu-berlin.de>
In article <_Pbcc.15824$kc2.322720@nnrp1.uunet.ca>,
"Martin L." <mjpliv@eastlink.ca> wrote:
> I a trying to debug a free script that allows me to place counters on
> pages throught my domain. It operates using SSI's. There are no fatal
> errors. The results should be a summary of my counter logs for each
> page that has a counter the no log file names or contents appear.
>
>
> There is one function #### @files = ('logs/*.log'); ##### I am not
> familiar with and a look through PERLFUNC did not turn up anything.
>
> Here is the context It is found in
>
> ####begin snippet
>
>
> $opt = "$ENV{ 'QUERY_STRING' }";
> $count_page = "$ENV{ 'QUERY_STRING' }";
>
> if ( $opt eq "stats" ) {
> @files = ('logs/*.log');
> &get_files;
> &CalculateStats }
>
> ####end snippet
>
> At this point the script should be generating a list of counter log
> files so that is what I am assuming this line does. I understand the
> "*.logs" portion is a wild card for all files with the "log" extension
> but the preceeding "logs/" I have not seen before. It is the name of
> the log directory but it has not been assigned to a FILE_HANDLE
> anywhere and the only other reference is as a comparison string in an
> unrelated section of the script.
>
> The page returned from the script would indicate that the "@files"
> variable contained no data.
In this snippet, @files is an array containing one entry - "logs/*.log", it's
not a function. Presumably a later function (get_files or CalculateStats
perhaps) will deal with all the items in @files.
--
Sandman[.net]
------------------------------
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 6364
***************************************