[19340] in Perl-Users-Digest
Perl-Users Digest, Issue: 1535 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Aug 15 18:15:52 2001
Date: Wed, 15 Aug 2001 15:15:19 -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: <997913719-v10-i1535@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Wed, 15 Aug 2001 Volume: 10 Number: 1535
Today's topics:
Re: Not inserting duplicate elements into an array (Yves Orton)
perl XML::Simple results and empty hash value..... (lloyd knight)
Re: perl XML::Simple results and empty hash value..... <ilya@martynov.org>
Re: perldoc is like Greek to a beginner?? (Abigail)
PPM / DBD-XBase problem on ActiveState Perl <leary@foad.NOSPAM.org>
Re: PPM / DBD-XBase problem on ActiveState Perl <djberge@uswest.com>
Re: PPM / DBD-XBase problem on ActiveState Perl <leary@foad.NOSPAM.org>
print HTML lines - Newbie question (leo white)
Re: print HTML lines - Newbie question <ilya@martynov.org>
Re: print HTML lines - Newbie question <jurgenex@hotmail.com>
Re: print HTML lines - Newbie question <ilya@martynov.org>
Re: print HTML lines - Newbie question <dglason@home.com>
Re: print HTML lines - Newbie question (leo white)
Redefinition warnings on use of CGI::Carp?? <miscellaneousemail@yahoo.com>
Re: Test coverage without Devel::Coverage <ned@bike-nomad.com>
Using my delete() alongside Perl's delete()?? <miscellaneousemail@yahoo.com>
Re: Using my delete() alongside Perl's delete()?? <ilya@martynov.org>
Re: Using my delete() alongside Perl's delete()?? (Tad McClellan)
Re: Why is there so much white space in perl documentat <pne-news-20010815@newton.digitalspace.net>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 15 Aug 2001 12:37:56 -0700
From: demerphq@hotmail.com (Yves Orton)
Subject: Re: Not inserting duplicate elements into an array
Message-Id: <74f348f7.0108151137.65e8c2c3@posting.google.com>
"Godzilla!" <godzilla@stomp.stomp.tokyo> wrote in message news:<3B7A80F1.4F6FD00C@stomp.stomp.tokyo>...
> Jasper McCrea wrote:
>
> > Godzilla! wrote
>
> (snipped)
>
> > Try running this, and then swapping the names of Array_Old and
> > Array_New.
> > S'funny the way the 'unique' array output at the end isn't the same
> > length as you have below?
>
> Why would I deliberately break my code?
You dont have to 'deliberately break' your code. It was broken from
the beginning.
Using your algorithm tell me what happens if I set the two arrays as
following:
@Array_Old=('Lizard is not a PerlMonger',
'Lizard is a PerlMangler',
'Lizard has not upgraded to Perl5',
'Lizard has not a clue of what a hash is');
@Array_New=qw(Lizard PerlMonger PerlMangler Perl5 hash);
Ok lizard, since you aren't actually going to check (as you dont check
your own code, I will be suprised if you check mine) I will give you
the output (from your original script with the above data):
Content-type: text/plain
Old Array:
Lizard is not a PerlMonger
Lizard is a PerlMangler
Lizard has not upgraded to Perl5
Lizard has no clue what a hash is
Updated Old Array:
Lizard is not a PerlMonger
Lizard is a PerlMangler
Lizard has not upgraded to Perl5
Lizard has no clue what a hash is
Hmm, now is that correct? Surely this should just be a merge of the
two arrays? So if you ever learn what a hash is then maybe you might
find that the following is correct:
Keys of Hash:
Lizard has no clue what a hash is
Lizard has not upgraded to Perl5
Lizard is a PerlMangler
Lizard is not a PerlMonger
Updated Keys of Hash:
Lizard
Lizard has no clue what a hash is
Lizard has not upgraded to Perl5
Lizard is a PerlMangler
Lizard is not a PerlMonger
Perl5
PerlMangler
PerlMonger
hash
> I understand why you would.
I doubt, after reading your last submissions, that you understand
much.
>
>
> > Index may be very fast, but it's a crazy solution for this. I'm sure
> > Godzilla! was just testing us.
Its not just crazy. It DOESNT work! Jasper I'm a little disappointed
that you didn't notice the flaw in her code.... :-)
> Chances are very good my code is the quickest and
> the most efficient code posted in response. This
> is most often the case.
Hahahahahahaha....
Mumphgh... heh ehe heheh..
Notice that the geko's routine slows down almost geometrically with
the number of elements in the array?, whereas the hash barely cares.
Using her code neither works, nor is it effecient. (356 seconds to
remove 2 thirds of a list of 500 elements... Whooooh!
Yves
---- Begin Benchmark code for Lizards Foolish Code ----
#!perl
use strict;
use warnings;
use Benchmark 'cmpthese';
my @Array_New;
sub lizard {
my @Array_Old;
for (@Array_New)
{
my $list_old = "@Array_Old";
if (index ($list_old, $_) == -1)
{ push (@Array_Old, $_); } #Lizard read up on 'modifiers' already
}
}
sub hash {
my %Hash;
$Hash{$_}++ foreach (@Array_New);
}
sub prep_Array_New{
my $num_unique=shift;
@Array_New=();
my $site='url000000';
my $page='page000000';
for (0..$num_unique) {
my $url="http://".($site++).".com/".($page++).".html";
#warn $url;
push @Array_New,$url,$url,$url;
}
}
my %test=('002' => 100_000,
'005' => 100_000,
'010' => 100_000,
'020' => 50_000,
'050' => 10_000,
'100' => 1_000,
'200' => 1_000,
'500' => 100);
for (sort keys %test) {
print "\nPerforming duplicate removal on $_ elements\n";
prep_Array_New($_);
cmpthese($test{$_},{"lizard_$_" => \&lizard,
"hash_$_" => \&hash});
}
---- End Benchmark code for Lizards Foolish Code ----
---- Begin Benchmark Output ----
Performing duplicate removal on 002 elements
Benchmark: timing 100000 iterations of hash_002, lizard_002...
hash_002: 2 wallclock secs ( 2.02 usr + 0.00 sys = 2.02 CPU) @
49603.17/s (n=100000)
lizard_002: 3 wallclock secs ( 4.44 usr + 0.00 sys = 4.44 CPU) @
22537.75/s (n=100000)
Rate lizard_002 hash_002
lizard_002 22538/s -- -55%
hash_002 49603/s 120% --
Performing duplicate removal on 005 elements
Benchmark: timing 100000 iterations of hash_005, lizard_005...
hash_005: 4 wallclock secs ( 3.53 usr + 0.00 sys = 3.53 CPU) @
28312.57/s (n=100000)
lizard_005: 11 wallclock secs (10.61 usr + 0.00 sys = 10.61 CPU) @
9425.96/s (n=100000)
Rate lizard_005 hash_005
lizard_005 9426/s -- -67%
hash_005 28313/s 200% --
Performing duplicate removal on 010 elements
Benchmark: timing 100000 iterations of hash_010, lizard_010...
hash_010: 7 wallclock secs ( 6.02 usr + 0.00 sys = 6.02 CPU) @
16622.34/s (n=100000)
lizard_010: 26 wallclock secs (25.72 usr + 0.00 sys = 25.72 CPU) @
3888.18/s (n=100000)
Rate lizard_010 hash_010
lizard_010 3888/s -- -77%
hash_010 16622/s 328% --
Performing duplicate removal on 020 elements
Benchmark: timing 50000 iterations of hash_020, lizard_020...
hash_020: 6 wallclock secs ( 5.69 usr + 0.00 sys = 5.69 CPU) @
8791.98/s (n=50000)
lizard_020: 37 wallclock secs (36.55 usr + 0.00 sys = 36.55 CPU) @
1368.10/s (n=50000)
Rate lizard_020 hash_020
lizard_020 1368/s -- -84%
hash_020 8792/s 543% --
Performing duplicate removal on 050 elements
Benchmark: timing 10000 iterations of hash_050, lizard_050...
hash_050: 3 wallclock secs ( 2.69 usr + 0.00 sys = 2.69 CPU) @
3721.62/s (n=10000)
lizard_050: 34 wallclock secs (34.50 usr + 0.00 sys = 34.50 CPU) @
289.86/s (n=10000)
Rate lizard_050 hash_050
lizard_050 290/s -- -92%
hash_050 3722/s 1184% --
Performing duplicate removal on 100 elements
Benchmark: timing 1000 iterations of hash_100, lizard_100...
hash_100: 1 wallclock secs ( 0.53 usr + 0.00 sys = 0.53 CPU) @
1883.24/s (n=1000)
lizard_100: 13 wallclock secs (13.06 usr + 0.00 sys = 13.06 CPU) @
76.56/s (n=1000)
Rate lizard_100 hash_100
lizard_100 76.6/s -- -96%
hash_100 1883/s 2360% --
Performing duplicate removal on 200 elements
Benchmark: timing 1000 iterations of hash_200, lizard_200...
hash_200: 1 wallclock secs ( 1.06 usr + 0.00 sys = 1.06 CPU) @
940.73/s (n=1000)
lizard_200: 48 wallclock secs (48.05 usr + 0.00 sys = 48.05 CPU) @
20.81/s (n=1000)
Rate lizard_200 hash_200
lizard_200 20.8/s -- -98%
hash_200 941/s 4420% --
Performing duplicate removal on 500 elements
Benchmark: timing 100 iterations of hash_500, lizard_500...
hash_500: 0 wallclock secs ( 0.28 usr + 0.00 sys = 0.28 CPU) @
355.87/s (n=100)
(warning: too few iterations for a reliable count)
lizard_500: 31 wallclock secs (30.61 usr + 0.00 sys = 30.61 CPU) @
3.27/s (n=100)
Rate lizard_500 hash_500
lizard_500 3.27/s -- -99%
hash_500 356/s 10793% --
---- Begin Benchmark Output ----
------------------------------
Date: 15 Aug 2001 11:12:16 -0700
From: lloyd_knight@adc.com (lloyd knight)
Subject: perl XML::Simple results and empty hash value.....
Message-Id: <61889d25.0108151012.43540bb2@posting.google.com>
i am using XLMin() to generate a hash of results.
when i try to display an empty value i get
HASH(0x*****) as the string value, when i know
it should be blank. Dumper() on the results of XMLin()
shows field=>{}.
$hofXML=XMLin(URL address);
$dt=$hofXML->{'sap:Body'}->{'frc:Z_MATERIAL_INFORMATION.Response'}-> \
{'MATERIAL_DETAILS'}->{'item'}->{"VALID_DATE"};
a print of $dt results in:
HASH(0x12345)
if a date is present the print works.
how do i get/test for the blank field without getting HASH(0x12345)?
------------------------------
Date: 15 Aug 2001 22:36:20 +0400
From: Ilya Martynov <ilya@martynov.org>
Subject: Re: perl XML::Simple results and empty hash value.....
Message-Id: <87pu9x41cr.fsf@abra.ru>
lk> i am using XLMin() to generate a hash of results.
lk> when i try to display an empty value i get
lk> HASH(0x*****) as the string value, when i know
lk> it should be blank. Dumper() on the results of XMLin()
lk> shows field=>{}.
lk> $hofXML=XMLin(URL address);
lk> $dt=$hofXML->{'sap:Body'}->{'frc:Z_MATERIAL_INFORMATION.Response'}-> \
lk> {'MATERIAL_DETAILS'}->{'item'}->{"VALID_DATE"};
lk> a print of $dt results in:
lk> HASH(0x12345)
lk> if a date is present the print works.
lk> how do i get/test for the blank field without getting HASH(0x12345)?
This is from perldoc XML::Simple (description of its parameters):
suppressempty => 1 | '' | undef (in)
This option controls what `XMLin()' should do with
empty elements (no attributes and no content). The
default behaviour is to represent them as empty
hashes. Setting this option to a true value (eg: 1)
will cause empty elements to be skipped altogether.
Setting the option to 'undef' or the empty string will
cause empty elements to be represented as the unde-
fined value or the empty string respectively. The
latter two alternatives are a little easier to test
for in your code than a hash with no keys.
Since you haven't set suppressempty param you get empty hash reference
for empty elements.
--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
| Ilya Martynov (http://martynov.org/) |
| GnuPG 1024D/323BDEE6 D7F7 561E 4C1D 8A15 8E80 E4AE BE1A 53EB 323B DEE6 |
| AGAVA Software Company (http://www.agava.com/) |
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
------------------------------
Date: 15 Aug 2001 21:50:15 GMT
From: abigail@foad.org (Abigail)
Subject: Re: perldoc is like Greek to a beginner??
Message-Id: <slrn9nlrlb.9sn.abigail@alexandra.xs4all.nl>
Anno Siegel (anno4000@lublin.zrz.tu-berlin.de) wrote on MMCMVI September
MCMXCIII in <URL:news:9le3g8$scc$1@mamenchi.zrz.TU-Berlin.DE>:
"" According to Bernie Cosell <bernie@fantasyfarm.com>:
"" > tadmc@augustmail.com (Tad McClellan) wrote:
"" >
"" > } >(Come to
"" > } >think of it, I am sure i have seen something somewhere (maybe a faq)
"" > } >that says that perl syntax in general is not propperly speaking
"" > } >regular either.)
"" > }
"" > }
"" > } Most programming languages are "Context Free Grammars" the
"" > } next step up in Chomsky's hierarchy from "Regular Grammars".
"" >
"" > Actually, I think that very very few programming languages manage to be
"" > context-free. That's just too restrictive for normal/effective use, and so
"" > while most languages use CF expressions and many CF programming constructs,
"" > there'll almost always inevitably be *some* little corner of the language
"" > that ends up having to be context sensitive.
Could you give examples from some well known languages, like C, Java
and ADA that proves they are not truely context free?
Note that if you can write a BNF for a language, or a Parse::RecDescent
grammar that doesn't use dirty tricks like rewriting the string it is
parsing it's context free.
Also, Aho, Hopcroft and Ullman claim that almost every computer language
is context free, so it would be interesting to see you prove them wrong.
"" There must be a tradeoff for a language designer between compiler-
"" and user-friendliness. The lower a language is in the Chomsky hierarchy
"" the easier it is to parse, and hence to compile, but that severely
"" limits expressiveness. So a wimpy designer keeps the core of his
"" language context-free (and would make it regular if he could), and
"" allows only a few context-sensitive constructs. Perl's designer seems
"" to have thrown all caution to the winds :)
Just because Larry did doesn't mean every programmer wants the
language (s)he uses to be context sensitive. Many people prefer
their language to be context free - that's one of the main reasons
Perl is disliked in large groups of people.
Abigail
--
sub J::FETCH{Just }$_.='print+"@{[map';sub J::TIESCALAR{bless\my$J,J}
sub A::FETCH{Another}$_.='{tie my($x),$';sub A::TIESCALAR{bless\my$A,A}
sub P::FETCH{Perl }$_.='_;$x}qw/J A P';sub P::TIESCALAR{bless\my$P,P}
sub H::FETCH{Hacker }$_.=' H/]}\n"';eval;sub H::TIESCALAR{bless\my$H,H}
------------------------------
Date: Wed, 15 Aug 2001 15:23:40 -0500
From: "Leary" <leary@foad.NOSPAM.org>
Subject: PPM / DBD-XBase problem on ActiveState Perl
Message-Id: <uWAe7.2732$7K5.41574@e3500-atl2.usenetserver.com>
I installed the DBD-XBase module from ActiveState, I added "use DBI;"
to the beginning of my script. When I run the script I get this;
Can't locate DBI.pm in @INC (@INC contains: C:/Perl/lib C:/Perl/site/lib .)
at C:\Perl\hsesum5.11.pl line 5.
BEGIN failed--compilation aborted at C:\Perl\hsesum5.11.pl line 5.
The only thing I see that looks odd to me is when I use the "set" command
from within PPM I get this;
Packages will be built under: C:\DOCUME~1\tim\LOCALS~1\Temp
Should that be c:\Perl (my Perl dir)?
------------------------------
Date: Wed, 15 Aug 2001 15:45:34 -0500
From: Mr Sunblade <djberge@uswest.com>
Subject: Re: PPM / DBD-XBase problem on ActiveState Perl
Message-Id: <3B7ADF6E.2D719D66@uswest.com>
Leary wrote:
> I installed the DBD-XBase module from ActiveState, I added "use DBI;"
> to the beginning of my script. When I run the script I get this;
>
> Can't locate DBI.pm in @INC (@INC contains: C:/Perl/lib C:/Perl/site/lib .)
> at C:\Perl\hsesum5.11.pl line 5.
> BEGIN failed--compilation aborted at C:\Perl\hsesum5.11.pl line 5.
>
> The only thing I see that looks odd to me is when I use the "set" command
> from within PPM I get this;
>
> Packages will be built under: C:\DOCUME~1\tim\LOCALS~1\Temp
>
> Should that be c:\Perl (my Perl dir)?
Did you first install the DBI module via ppm? If you installed it manually,
or with
another version of AS Perl, then it might have ended up somewhere else.
The build location doesn't matter.
Regards,
Mr. Sunblade
--
"Evil will always triumph because Good is *dumb*."
-- Dark Helmet, 'Spaceballs: The Movie'
------------------------------
Date: Wed, 15 Aug 2001 15:46:34 -0500
From: "Leary" <leary@foad.NOSPAM.org>
Subject: Re: PPM / DBD-XBase problem on ActiveState Perl
Message-Id: <PaBe7.3028$0M1.42792@e3500-atl1.usenetserver.com>
"Leary" <leary@foad.NOSPAM.org> wrote in message
> I installed the DBD-XBase module from ActiveState, I added "use DBI;"
> to the beginning of my script. When I run the script I get this;
>
> Can't locate DBI.pm in @INC (@INC contains: C:/Perl/lib C:/Perl/site/lib
.)
> at C:\Perl\hsesum5.11.pl line 5.
> BEGIN failed--compilation aborted at C:\Perl\hsesum5.11.pl line 5.
>
> The only thing I see that looks odd to me is when I use the "set" command
> from within PPM I get this;
>
> Packages will be built under: C:\DOCUME~1\tim\LOCALS~1\Temp
>
> Should that be c:\Perl (my Perl dir)?
Why is it that you can dig for hours, and the moment you post asking for
help, you figure it out??? I installed the DBI module and now that error
isn't happening. There is a multitude of new errors, which I will diligently
try to solve on my own :)
------------------------------
Date: 15 Aug 2001 11:40:49 -0700
From: leowhite@btinternet.com (leo white)
Subject: print HTML lines - Newbie question
Message-Id: <3e5e52b3.0108151040.14b19f2f@posting.google.com>
Hi
A real Newbie question here -
I need to include several large chunks of HTMl along with javascript
and PHP lines into a new PHP file being produced by a perl CGI script.
I no nothing about perl but have picked up that the PRINT function is
used to write a line to a file. problem is that I need to include 200
+ lines of HTML and the ';' found in the javascript & PHP statements
causes the perl script to error.
Is there a way to PRINT blocks of HTML rather than line by line? and
avoid errors on encountering the ;?
Thanks in advance,
leo White
------------------------------
Date: 15 Aug 2001 22:44:26 +0400
From: Ilya Martynov <ilya@martynov.org>
Subject: Re: print HTML lines - Newbie question
Message-Id: <87hev940z9.fsf@abra.ru>
lw> Hi
lw> A real Newbie question here -
lw> I need to include several large chunks of HTMl along with javascript
lw> and PHP lines into a new PHP file being produced by a perl CGI script.
lw> I no nothing about perl but have picked up that the PRINT function is
lw> used to write a line to a file. problem is that I need to include 200
lw> + lines of HTML and the ';' found in the javascript & PHP statements
lw> causes the perl script to error.
lw> Is there a way to PRINT blocks of HTML rather than line by line? and
lw> avoid errors on encountering the ;?
Best aproach is put all your HTML code in separate template and use
one of templating modules (for example HTML::Template) to substitute
values in it.
--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
| Ilya Martynov (http://martynov.org/) |
| GnuPG 1024D/323BDEE6 D7F7 561E 4C1D 8A15 8E80 E4AE BE1A 53EB 323B DEE6 |
| AGAVA Software Company (http://www.agava.com/) |
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
------------------------------
Date: Wed, 15 Aug 2001 12:30:54 -0700
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: print HTML lines - Newbie question
Message-Id: <3b7acdde$1@news.microsoft.com>
"Ilya Martynov" <ilya@martynov.org> wrote in message
news:87hev940z9.fsf@abra.ru...
> lw> I need to include several large chunks of HTMl along with javascript
> lw> and PHP lines into a new PHP file being produced by a perl CGI script.
> lw> I no nothing about perl but have picked up that the PRINT function is
> lw> used to write a line to a file. problem is that I need to include 200
> lw> + lines of HTML and the ';' found in the javascript & PHP statements
> lw> causes the perl script to error.
>
> lw> Is there a way to PRINT blocks of HTML rather than line by line? and
> lw> avoid errors on encountering the ;?
>
> Best aproach is put all your HTML code in separate template and use
> one of templating modules (for example HTML::Template) to substitute
> values in it.
I wonder if HTML::Template supports PHP, too.
As to the OP: You may want to look into "here" documents, a feature Perl
inherited from Shell programming.
jue
------------------------------
Date: 15 Aug 2001 23:42:07 +0400
From: Ilya Martynov <ilya@martynov.org>
Subject: Re: print HTML lines - Newbie question
Message-Id: <87r8ud2jqo.fsf@abra.ru>
JE> I wonder if HTML::Template supports PHP, too.
JE> As to the OP: You may want to look into "here" documents, a feature Perl
JE> inherited from Shell programming.
HTML::Template templates are just *text* templates. I thought PHP+HTML
is a text?
--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
| Ilya Martynov (http://martynov.org/) |
| GnuPG 1024D/323BDEE6 D7F7 561E 4C1D 8A15 8E80 E4AE BE1A 53EB 323B DEE6 |
| AGAVA Software Company (http://www.agava.com/) |
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
------------------------------
Date: Wed, 15 Aug 2001 20:44:59 GMT
From: Dave Glason <dglason@home.com>
Subject: Re: print HTML lines - Newbie question
Message-Id: <3B7ADF44.7DD16779@home.com>
Yes you can do something like
{
print <<BLOCK
INSERT TEXT HERE
BLOCK
}
This should also avoid problems caused by ' " ` and other "special"
characters. If you need to print these characters in a regular print
statement you can escape them by using a \ in front (e.g. \').
check www.perldoc.org or www.perl.com for more info
/Dave
leo white wrote:
> Hi
>
> A real Newbie question here -
> I need to include several large chunks of HTMl along with javascript
> and PHP lines into a new PHP file being produced by a perl CGI script.
> I no nothing about perl but have picked up that the PRINT function is
> used to write a line to a file. problem is that I need to include 200
> + lines of HTML and the ';' found in the javascript & PHP statements
> causes the perl script to error.
>
> Is there a way to PRINT blocks of HTML rather than line by line? and
> avoid errors on encountering the ;?
>
> Thanks in advance,
> leo White
------------------------------
Date: 15 Aug 2001 15:01:00 -0700
From: leowhite@btinternet.com (leo white)
Subject: Re: print HTML lines - Newbie question
Message-Id: <3e5e52b3.0108151400.56f8ec38@posting.google.com>
Thanks Ilya
Am I right in thinking that such a module has to be installed on the
server?
I am hosting with easyspace.com and I dont have access permission to
install stuff other than in my cgi bin - is there a way to use
templates with such a setup or any tutorials that may help?
Thanks again
leo
------------------------------
Date: Wed, 15 Aug 2001 21:59:08 GMT
From: Carlos C. Gonzalez <miscellaneousemail@yahoo.com>
Subject: Redefinition warnings on use of CGI::Carp??
Message-Id: <MPG.15e49e419ecd639898975b@news.edmonton.telusplanet.net>
Hi everyone,
I have noticed that whenever I run any of my programs from the command
line I always get the following warnings...
[Wed Aug 15 15:45:58 2001] (eval 1): Subroutine confess redefined at
(eval 1) line 1.
[Wed Aug 15 15:45:58 2001] (eval 1): Subroutine croak redefined at (eval
1) line 2.
[Wed Aug 15 15:45:58 2001] (eval 1): Subroutine carp redefined at (eval
1) line 3.
The code below (from perlboot) does that.
#!/usr/bin/perl -w
use CGI::Carp qw(carpout fatalsToBrowser);
use diagnostics;
use strict;
sub Cow::speak {
print "a Cow goes moooo!\n";
}
sub Horse::speak {
print "a Horse goes neigh!\n";
}
sub Sheep::speak {
print "a Sheep goes baaaah!\n"
}
my @pasture = qw(Cow Cow Horse Sheep Sheep);
my $animal;
foreach $animal (@pasture) {
$animal->speak;
}
Now I know that it has something to do with the CGI::Carp pacakage and I
know that somehow these standard Perl functions (?) are redefined to be
something else. Are these warnings just for my info in case I come to
think that I am calling the Perl functions when I am actually calling the
Carp versions? How do I prevent these warnings (aside from not using
#!/usr/bin/perl -w)? Should I enclose the use CGI::Carp qw(carpout
fatalsToBrowser); directive with some kind of no warnings pragma (I think
that's what they are called?)?. Is that a good idea?
What does eval() have to do with any of this as found in the warnings?
Thanks.
---
Carlos
www.internetsuccess.ca
*NOTE*: Internet Success is NOT yet fully operational so although you are
welcomed to visit and take a look, trying to subscribe will only be a
frustration for you as your data will not be saved at this time.
------------------------------
Date: Wed, 15 Aug 2001 12:24:51 +2328
From: Ned Konz <ned@bike-nomad.com>
Subject: Re: Test coverage without Devel::Coverage
Message-Id: <tnlj1hj7n02bc0@corp.supernews.com>
Michael Carman wrote:
> I've played with Devel::Coverage a bit and it works fine, despite it's
> alpha status. It's chief weakness is the level of detail it provides.
> It only tells you whether or not you've reached a given line in your
> source. If that's all the more granularity you need, then this module
> should work fine for you.
>
>> Does anybody of you know how I can do it without using the
>> Devel::Coverage module?
What about Devel::SmallProf?
Or do it yourself. It's quite easy to hook to the debugger. This simple
little script outputs a count before each line of your program:
#! /usr/bin/perl -w
# Perl coverage testing tool.
# Ned Konz 3/10/2000
# ned@bike-nomad.com
# $Revision: 1.2 $
# usage: run one script:
# coverage script [ arg ... ] > listing.txt
# or run multiple tests from a file of tests, one test per line.
# coverage @file > listing.txt
# output: annotated listing on STDOUT.
use strict;
my %coverage;
my %functions;
my $currentFile;
my $currentFunction;
my $tmpfile = `mktemp /tmp/coverageXXXXXX`;
$ENV{PERLDB_OPTS} = "NonStop AutoTrace LineInfo=$tmpfile";
$| = 1;
sub runOneTest {
my $test = shift;
my $incPath = join ( ' ', map {"-I$_"} @INC );
system("perl $incPath -d $test") == 0 or die "can't open debugger:
$!\n";
open( DBOUT, $tmpfile ) or die "can't open $tmpfile: $!\n";
while (<DBOUT>) {
if (/^(.*)\(([^:]+):(\d+)\):(.*)$/) {
$currentFunction = $1;
$currentFile = $2;
my $lineNumber = $3;
my $otherStuff = $4;
if ( !exists( $coverage{$currentFile} ) ) {
$coverage{$currentFile} = [];
}
# if ($currentFunction !~ /CODE\(/)
{
$functions{$currentFunction} = $currentFile;
}
if ($otherStuff) {
$coverage{$currentFile}->[$lineNumber]++;
}
}
elsif (/^(\d+):/) {
$coverage{$currentFile}->[$1]++;
}
}
unlink $tmpfile;
}
sub printHeader {
my $header = shift;
$header = "$header " if length($header) % 2;
my $dashLength = ( 78 - length($header) ) / 2;
$dashLength = 2 if $dashLength < 2;
print '=' x $dashLength . " $header " . '=' x $dashLength . "\n";
}
sub printSummary {
printHeader("FILE COVERAGE");
foreach my $file ( sort( keys(%coverage) ) ) {
next if !-r $file;
next if ( $file =~ qr{^/usr/.*/perl} ); # skip system paths.
printHeader($file);
open( FILE, $file ) or die "can't open $file: $!\n";
my $nullPrefix = ' ' x 6;
for ( my $lineNumber = 1 ; <FILE> ; $lineNumber++ ) {
my $prefix =
( defined( $coverage{$file}->[$lineNumber] )
&& $coverage{$file}->[$lineNumber] > 0 ) ?
sprintf( "%5d ", $coverage{$file}->[$lineNumber] ) :
$nullPrefix;
$prefix = $nullPrefix if ( /^\s*
(?: [#].*
| sub\s+\w+\s*
| [{};]*
| package\s+[\w:]+\s*;\s*
) $/x );
print $prefix, $_;
}
close(FILE);
}
}
# main program.
if ( $ARGV[0] =~ /^@(.*)/ ) {
open( TESTS, $1 );
foreach my $test (<TESTS>) {
chomp($test);
print STDERR "Running $test\n";
printHeader("Running $test");
runOneTest($test);
}
}
else {
runOneTest("@ARGV");
}
printSummary();
# vim: ts=4 sw=4
------------------------------
Date: Wed, 15 Aug 2001 19:28:12 GMT
From: Carlos C. Gonzalez <miscellaneousemail@yahoo.com>
Subject: Using my delete() alongside Perl's delete()??
Message-Id: <MPG.15e47b47a144925398975a@news.edmonton.telusplanet.net>
Hi everyone,
Hope I am not asking too many questions but I love picking your all's
brains. I try to make sure my questions are interesting, practical, and
not something that I should be able to easily answer myself by looking at
some simple documentation. I you all ever think I am asking too many
questions please let me know.
Here is another one I would appreciate your input on....
I have this function....
sub delete
{
my ($hashref, $key) = @_;
delete $hashref->{$key};
}
and I like the name very much. It goes in line with several subs I am
creating to imitate dBase like commands that many non-programmers know.
Only thing is that in the case of this one sub I am apparently coming
into conflict with the Perl predefined sub of delete().
Is there a way to use my version of delete() with Perl's in the same
code? Can they co-exist? I tried calling mine with main::delete(\%h,
$key) but that didn't quite work.
I read through parts of http://www.perldoc.com/perl5.6/lib/overload.html
but it would take me a week to figure that one out. I looked up stuff on
Google and www.perldoc.com and did not get a whole of direction.
Any suggestions or links that might clarify things for me?
---
Carlos
www.internetsuccess.ca
*NOTE*: Internet Success is NOT yet fully operational so although you are
welcomed to visit and take a look, trying to subscribe will only be a
frustration for you as your data will not be saved at this time.
------------------------------
Date: 15 Aug 2001 23:45:36 +0400
From: Ilya Martynov <ilya@martynov.org>
Subject: Re: Using my delete() alongside Perl's delete()??
Message-Id: <87n1512jkv.fsf@abra.ru>
CCG> [..skip..]
CCG> Here is another one I would appreciate your input on....
CCG> I have this function....
CCG> sub delete
CCG> {
CCG> my ($hashref, $key) = @_;
CCG> delete $hashref->{$key};
CCG> }
CCG> and I like the name very much. It goes in line with several subs I am
CCG> creating to imitate dBase like commands that many non-programmers know.
CCG> Only thing is that in the case of this one sub I am apparently coming
CCG> into conflict with the Perl predefined sub of delete().
CCG> Is there a way to use my version of delete() with Perl's in the same
CCG> code? Can they co-exist? I tried calling mine with main::delete(\%h,
CCG> $key) but that didn't quite work.
CCG> [..skip..]
CCG> Any suggestions or links that might clarify things for me?
Untested:
sub delete
{
my ($hashref, $key) = @_;
CORE::delete $hashref->{$key};
}
I belive it will do a trick.
--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
| Ilya Martynov (http://martynov.org/) |
| GnuPG 1024D/323BDEE6 D7F7 561E 4C1D 8A15 8E80 E4AE BE1A 53EB 323B DEE6 |
| AGAVA Software Company (http://www.agava.com/) |
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
------------------------------
Date: Wed, 15 Aug 2001 15:17:26 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Using my delete() alongside Perl's delete()??
Message-Id: <slrn9nlim6.2hs.tadmc@tadmc26.august.net>
Carlos C. Gonzalez <miscellaneousemail@yahoo.com> wrote:
>I have this function....
>
>sub delete
>{
> my ($hashref, $key) = @_;
> delete $hashref->{$key};
>}
>
>and I like the name very much. It goes in line with several subs I am
>creating to imitate dBase like commands that many non-programmers know.
>Only thing is that in the case of this one sub I am apparently coming
>into conflict with the Perl predefined sub of delete().
>
>Is there a way to use my version of delete() with Perl's in the same
>code?
Call perl's:
delete(...)
call yours:
&delete(...)
Functions called with the ampersand syntax are _always_ user
defined functions. See perlsub.pod for yet another difference
with using the ampersand in the call (won't matter if you've
given up on prototypes).
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 15 Aug 2001 21:19:04 +0200
From: Philip Newton <pne-news-20010815@newton.digitalspace.net>
Subject: Re: Why is there so much white space in perl documentation??
Message-Id: <heilntkksd3etggnc3bqga8kd425n943jp@4ax.com>
On Wed, 15 Aug 2001 06:59:15 GMT, Carlos C. Gonzalez
<miscellaneousemail@yahoo.com> wrote:
> I have been toying with VIM lately but whew! What a different way of
> doing things. Where did all the menus and nice clean, mouseable
> interfaces go?
It's called "gvim" and should be available at the same place where you
got your vim.
Cheers,
Philip
--
Philip Newton <nospam.newton@gmx.li>
That really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.
------------------------------
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.
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 1535
***************************************