[16381] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 3793 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jul 25 03:05:42 2000

Date: Tue, 25 Jul 2000 00:05:12 -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: <964508711-v9-i3793@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Tue, 25 Jul 2000     Volume: 9 Number: 3793

Today's topics:
    Re: Advanced Perl Programming -- Dated? <mbk59@hotmail.com>
    Re: Advanced Perl Programming -- Dated? <sb@muccpu1.muc.sdm.de>
    Re: Advanced Perl Programming -- Dated? <uri@sysarch.com>
    Re: Advanced Perl Programming -- Dated? <uri@sysarch.com>
    Re: Advanced Perl Programming -- Dated? <sb@muccpu1.muc.sdm.de>
    Re: Advice on CGI.pm (David Efflandt)
        Any free Perl-Friendly hosts? <shadeejake1NOshSPAM@aol.com.invalid>
    Re: Any free Perl-Friendly hosts? <matthew.keeneNOmaSPAM@colesmyer.com.au.invalid>
    Re: day_of_week() and age() without using Date::Calc ? <sb@muccpu1.muc.sdm.de>
    Re: HELP: longSyntax ok, but: rHsh->{myKey} UNDEFINED?? (David Combs)
    Re: hoo boy, it's another head-scratcher... <nospam@nospam.com>
    Re: how do you ? question (Jon Bell)
        newbie hashes of hashes declartion question <o1technospam@skyenet.nospam.net>
    Re: newbie hashes of hashes declartion question <lr@hpl.hp.com>
    Re: PERL -w BUG!? (was: HELP: longSyntax ok, but: rHsh- (David Combs)
    Re: PERL -w BUG!? (was: HELP: longSyntax ok, but: rHsh- <uri@sysarch.com>
    Re: Perl as a win32 scheduled task <cyrus@aareus.com>
    Re: perl as part of unix distribution (Lupe Christoph)
    Re: Perl's BigFloat/BigInt <sb@muccpu1.muc.sdm.de>
        question on lists of lists... of lists! <rwilliamson@uno.gers.com>
    Re: question on lists of lists... of lists! <uri@sysarch.com>
        Stumped a Digitalthink PERL tutor arerickson@my-deja.com
    Re: USEing a perl module <jheide@sprint.ca>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Tue, 25 Jul 2000 02:02:21 -0400
From: "Mike Krell" <mbk59@hotmail.com>
Subject: Re: Advanced Perl Programming -- Dated?
Message-Id: <397d2d25_4@news3.prserv.net>


"Uri Guttman" <uri@sysarch.com> wrote in message
news:x766puaogt.fsf@home.sysarch.com...

> where did he say typeglobs are faster than refs?

I can't quote a page number, but this is from the electronic version:

3.2.2.1 Efficient parameter passing
Aliases happen to be quite a bit faster than references, because they don't
need to do any dereferencing. Consider
$a = 10;
*b = *a ; $b++ ;  # 1. Increment $a indirectly through the typeglob
$r = \$a; $$r++;  # 2. Increment $a indirectly through the reference
Case 1 is around one and a half times faster than case 2 on my PC.

> the whole chapter on eval is poor.

In what way?  Is it inaccurate?  Incomplete?

> it is considered a medium quality book and it is fairly dated in many
> areas. it covers some internals and some useful areas. it could be
> rewritten and made into a useful book but i doubt it will happen. too
> many other decent perl books are out there.

The main appeal it has for me (besides the fact that it was already bundled
on the CD with the books that I _really_ wanted :-) is that it seems to
cover a lot of topics that I know very little about without crushing me
under an information avalanche.  This is in contrast to the Ram, which is
fantastic when I have particular problems or techniques already in mind but
is daunting as a cover-to-cover read.

   Mike






------------------------------

Date: 25 Jul 2000 06:05:57 GMT
From: Steffen Beyer <sb@muccpu1.muc.sdm.de>
Subject: Re: Advanced Perl Programming -- Dated?
Message-Id: <8ljao5$fr6$1@solti3.sdm.de>

In article <x766puaogt.fsf@home.sysarch.com>, Uri Guttman <uri@sysarch.com> wrote:

>   MK> I've just started reading Sriram Srinivasan's "Advanced Perl
>   MK> Programming" to learn about some of Perl's more, er, advanced
>   MK> features.  I like both the writing style and the scope of the
>   MK> subject matter very much, but I'm wondering how much of the
>   MK> material is inaccurate or obsolete.  For example, the author
>   MK> mentions using typeglobs instead of references in some instances
>   MK> for efficiency, but my vague impression from other sources is that
>   MK> using typeglobs is discouraged.

> using typeglobs to pass data structures vs. references is definitely a
> bad idea.

Lest special cases where you *do* actually need them.
(See my module "Data::Locations" for instance! It uses objects which
are valid filehandles at the same time. To achieve this, it has to
use typeglobs blessed into objects and "tie"d to themselves (in order
to be able to use them as filehandles as well).)

> in fact the discussion on perl6 is to eliminate typeglobs
> altogether. where did he say typeglobs are faster than refs? i have just
> browsed the typeglob chapter (way to early in the book and a whole
> chapter on them? gawd!)

On the contrary, it was the first chapter I read because I desperately
needed it. This book was my hail and salvation!

> and couldn't find that comment.

From his overall writing style I doubt the author ever made such a claim.
I can't remember him doing so anyway.
I found him giving very sensible recommendations, pondering the pros and
cons of different possibilities, as far as I can remember.
At least I was full of ideas for different solutions to my problems,
after reading his book, and his book also gave me the necessary information
to choose the most promising one among them.

>   MK> This is probably a tall order, but does anyone have an idea about
>   MK> which areas of the book should be taken with a grain of salt,
>   MK> given the current state of the language?

> for example, on page 16 (very early in the book) he covers symbolic
> references which are considered evil by all decent perl hackers. 

There are moments when you can't avoid them.

I think you are forgetting that this book is not for the average Perl
hacker, but for people who *need* (or want) to deal with the gory
details and who are supposed to know the rules and also, when to
break them!

> it doesn't cover qr// which was added to perl after it was published. so
> it described the old fast way to apply multiple regexes to a string. the
> whole chapter on eval is poor. 

> it is considered a medium quality book and it is fairly dated in many
> areas. it covers some internals and some useful areas. it could be
> rewritten and made into a useful book but i doubt it will happen. too
> many other decent perl books are out there.

There is (AFAIK) *no* other book that goes this deep into the guts
of perl!

And I wouldn't rate it "medium" (I wonder where you got that from,
as far as I can remember, it got very high ratings actually), I'd
rate it top-notch!

When you desperately need it it really gives you an understanding
that you can't find *anywhere* else! (Except by reading the raw
C code of Perl maybe)

I think it will still be worth reading for a long time to come!
Perl 6 (without typeglobs) is not around the corner after all.
And even though "qr//" is missing, the book gives a whole lot
of gory details and, most precious, an understanding of the
internal workings of perl.

Regards,
-- 
    Steffen Beyer <sb@engelschall.com>
    http://www.engelschall.com/u/sb/whoami/ (Who am I)
    http://www.engelschall.com/u/sb/gallery/ (Fotos Brasil, USA, ...)
    http://www.engelschall.com/u/sb/download/ (Free Perl and C Software)


------------------------------

Date: Tue, 25 Jul 2000 06:20:28 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Advanced Perl Programming -- Dated?
Message-Id: <x7lmyq91ec.fsf@home.sysarch.com>

>>>>> "MK" == Mike Krell <mbk59@hotmail.com> writes:

  MK> I can't quote a page number, but this is from the electronic version:

  MK> 3.2.2.1 Efficient parameter passing
  MK> Aliases happen to be quite a bit faster than references, because
  MK> they don't need to do any dereferencing. Consider
  MK> $a = 10;
  MK> *b = *a ; $b++ ;  # 1. Increment $a indirectly through the typeglob
  MK> $r = \$a; $$r++;  # 2. Increment $a indirectly through the reference
  MK> Case 1 is around one and a half times faster than case 2 on my PC.

irrelevent. typeglobs are not meant to pass around data structures. they
are meant to access the symbol table. aliasing like that is bug prone
and confusing. 

  >> the whole chapter on eval is poor.

  MK> In what way?  Is it inaccurate?  Incomplete?

foolish. like i said, the regex speedup trick is obsolete. talking about
eval so much encourages it when it should be discouraged. eval block is
a totally different operator than eval string and he doesn't show
that. in fact he has a table where he shows both to be the same in some
cases. that is massively wrong. eval block doesn't invoke the compiler
while eval string does.

  MK> The main appeal it has for me (besides the fact that it was
  MK> already bundled on the CD with the books that I _really_ wanted
  MK> :-) is that it seems to cover a lot of topics that I know very
  MK> little about without crushing me under an information avalanche.
  MK> This is in contrast to the Ram, which is fantastic when I have
  MK> particular problems or techniques already in mind but is daunting
  MK> as a cover-to-cover read.

APP has its minor good points but it is not a must have book. i liked it
some when it came out but my opinion of it has gone down over time as it
has become dated and my book reviewing skills have gone up. it is poorly
organized and it covers dangerous topics without enough warnings and in
a poorly organized way. it has some minor part like making modules and
some guts and it had the earliest coverage perl/tk thing out there. but
all of that is done better elsewhere.

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com


------------------------------

Date: Tue, 25 Jul 2000 06:37:32 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Advanced Perl Programming -- Dated?
Message-Id: <x7ittu90lu.fsf@home.sysarch.com>

>>>>> "SB" == Steffen Beyer <sb@muccpu1.muc.sdm.de> writes:

  SB> In article <x766puaogt.fsf@home.sysarch.com>, Uri Guttman
  SB> <uri@sysarch.com> wrote:

  >> using typeglobs to pass data structures vs. references is definitely a
  >> bad idea.

  SB> Lest special cases where you *do* actually need them.
  SB> (See my module "Data::Locations" for instance! It uses objects which
  SB> are valid filehandles at the same time. To achieve this, it has to
  SB> use typeglobs blessed into objects and "tie"d to themselves (in order
  SB> to be able to use them as filehandles as well).)

but you know you needed them. the average hacker will read that and
start passing typeglobs around instead of references.

  SB> On the contrary, it was the first chapter I read because I
  SB> desperately needed it. This book was my hail and salvation!

read object oriented perl. it covers typeglob objects and tying very
well. it does refer back to APP for a tutorial on typeglobs though. i
was using them in perl4 to do similar structure passing and learned them
then. when perl5 came out i promptly dropped that practice.

  >> for example, on page 16 (very early in the book) he covers symbolic
  >> references which are considered evil by all decent perl hackers. 

  SB> There are moments when you can't avoid them.

i never said never use them either. but showing them early and
indiscriminately is not a good thing. do you see how often newbies ask
about symrefs here when they really need data structures? read mjd'
articles on varvar for more. like his article on the 7 reasons to use
local, there are only a limited number of reasons to use symbolic
refs. that is why strict makes them illegal. they have their important
uses, but they are rare and almost always involve munging the symbol
table. 

  SB> I think you are forgetting that this book is not for the average Perl
  SB> hacker, but for people who *need* (or want) to deal with the gory
  SB> details and who are supposed to know the rules and also, when to
  SB> break them!

i agree but it could be written much better in many places. maybe a new
edition would be worth it but i doubt o'reilly will do it.

  SB> There is (AFAIK) *no* other book that goes this deep into the guts
  SB> of perl!

true, but again it could be done better. there are book proposals in the
works for XS and perl guts. i hope the get published before perl6 gets
released. :-)

  SB> And I wouldn't rate it "medium" (I wonder where you got that from,
  SB> as far as I can remember, it got very high ratings actually), I'd
  SB> rate it top-notch!

i did rate it higher when i got it. i have downgraded it over time
some. it is dated in several important areas and i think it doesn't
explain the dangers of typeglobs and evals enough. not separating eval
string from eval block is poor. they are intertwined in the same chapter
and have as much in common as one and four arg select.

  SB> I think it will still be worth reading for a long time to come!
  SB> Perl 6 (without typeglobs) is not around the corner after all.
  SB> And even though "qr//" is missing, the book gives a whole lot
  SB> of gory details and, most precious, an understanding of the
  SB> internal workings of perl.

those parts are useful and i did learn from them. but it could be much
much better. having read many other perl books i have a different eye
now than when i first read it. looking at it now i see how it could be
improved a great deal. 

maybe i am biased by OOP as it covers many of the same subjects like
tying, persistance, and OO design in a much better and clearer
style. and comparing any author to damian is a losing proposition. :-)

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com


------------------------------

Date: 25 Jul 2000 06:50:44 GMT
From: Steffen Beyer <sb@muccpu1.muc.sdm.de>
Subject: Re: Advanced Perl Programming -- Dated?
Message-Id: <8ljdc4$git$1@solti3.sdm.de>

In article <x7ittu90lu.fsf@home.sysarch.com>, Uri Guttman <uri@sysarch.com> wrote:

>   >> using typeglobs to pass data structures vs. references is definitely a
>   >> bad idea.

>   SB> Lest special cases where you *do* actually need them.

> but you know you needed them. the average hacker will read that and
> start passing typeglobs around instead of references.

But then again, the book isn't aimed at Joe Average Hacker, is it? :-)

>   SB> On the contrary, it was the first chapter I read because I
>   SB> desperately needed it. This book was my hail and salvation!

> read object oriented perl. it covers typeglob objects and tying very
> well. [...]

Ok, I think I'll have to! :-)

>   SB> There are moments when you can't avoid them.

> i never said never use them either. but showing them early and
> indiscriminately is not a good thing. do you see how often newbies ask
> about symrefs here when they really need data structures? read mjd'
> articles on varvar for more. like his article on the 7 reasons to use
> local, there are only a limited number of reasons to use symbolic
> refs. that is why strict makes them illegal. they have their important
> uses, but they are rare and almost always involve munging the symbol
> table. 

That was exactly what I had in mind. :-)

>   SB> I think you are forgetting that this book is not for the average Perl
>   SB> hacker, but for people who *need* (or want) to deal with the gory
>   SB> details and who are supposed to know the rules and also, when to
>   SB> break them!

> i agree but it could be written much better in many places. maybe a new
> edition would be worth it but i doubt o'reilly will do it.

A pity, I think we definitely need books like this!

>   SB> There is (AFAIK) *no* other book that goes this deep into the guts
>   SB> of perl!

> true, but again it could be done better. there are book proposals in the
> works for XS and perl guts. i hope the get published before perl6 gets
> released. :-)

Me too! :-)

Especially since they will be superfluous if Perl 6 really succeeds
in eliminating the XS mess.

>   SB> And I wouldn't rate it "medium" (I wonder where you got that from,
>   SB> as far as I can remember, it got very high ratings actually), I'd
>   SB> rate it top-notch!

> i did rate it higher when i got it. i have downgraded it over time
> some. it is dated in several important areas and i think it doesn't
> explain the dangers of typeglobs and evals enough. not separating eval

I think the dangers are pretty obvious; as far as typeglobs are concerned
because these are really Perl internal data structures and you know it
when you read it, and eval should be clear from the excellent man pages
coming with Perl anyway. Or the Camel book.

> string from eval block is poor.

He really didn't? I overlooked that because I knew it anyway.
I think the problems you mentioned all go away when one presupposes
that the reader must be familiar (and really familiar) with the
man pages and the Camel, at least, don't they?

> they are intertwined in the same chapter
> and have as much in common as one and four arg select.

True of course.

>   SB> I think it will still be worth reading for a long time to come!
>   SB> Perl 6 (without typeglobs) is not around the corner after all.
>   SB> And even though "qr//" is missing, the book gives a whole lot
>   SB> of gory details and, most precious, an understanding of the
>   SB> internal workings of perl.

> those parts are useful and i did learn from them. but it could be much
> much better. having read many other perl books i have a different eye
> now than when i first read it. looking at it now i see how it could be
> improved a great deal. 

Maybe, you have a larger base for comparisons than I do.
But I still am deeply grateful to this book and its author because
it really satisfied a deep and long-time need in me!
(No, not *that* one of course! ;-) Honi soit qui mal y pense.)

> maybe i am biased by OOP as it covers many of the same subjects like
> tying, persistance, and OO design in a much better and clearer
> style. and comparing any author to damian is a losing proposition. :-)

Sounds like I definitely need to read this book! :-)

Best regards,
-- 
    Steffen Beyer <sb@engelschall.com>
    http://www.engelschall.com/u/sb/whoami/ (Who am I)
    http://www.engelschall.com/u/sb/gallery/ (Fotos Brasil, USA, ...)
    http://www.engelschall.com/u/sb/download/ (Free Perl and C Software)


------------------------------

Date: Tue, 25 Jul 2000 04:06:14 +0000 (UTC)
From: efflandt@xnet.com (David Efflandt)
Subject: Re: Advice on CGI.pm
Message-Id: <slrn8nq4gb.btr.efflandt@efflandt.xnet.com>

On Mon, 24 Jul 2000 18:42:40 -0500, Josh <josh@projectperl.com> wrote:
>    Hello. I have written administrative CGI scripts with CGI.pm and have
>always found it difficult to implement pages that have several command
>buttons that take the user to different functions of the administrative
>script(i.e. a menu). I usually run into problems such as it re-executing
>previous code and generally not following the correct path. I am looking for
>someone to give advice on how it would be possible to work these type of
>flaws out and if possible some examples of how. Thank you.

Just give different submit buttons different names.  The value doesn't
matter, just if it has a value (true), it was the button pressed.  You can
either break it into subroutines, or just test which button names are true
with if statements for sections that are not common to every response.

if (param) {
    if (param('preview')) {
        print header,start_html('Preview');
        # process things
    }
    if (param('submit')) {
        print header,start_html('Thanks');
        * save things
    }
    # do other things
} else {
    print header,start_html('Form');
    # create blank form
}

Or skip the 'else' if you want to replicate the filled in form at the end.

-- 
David Efflandt  efflandt@xnet.com  http://www.de-srv.com/
http://www.autox.chicago.il.us/  http://www.berniesfloral.net/
http://hammer.prohosting.com/~cgi-wiz/  http://cgi-help.virtualave.net/



------------------------------

Date: Mon, 24 Jul 2000 22:33:58 -0700
From: shadeejake <shadeejake1NOshSPAM@aol.com.invalid>
Subject: Any free Perl-Friendly hosts?
Message-Id: <0245003e.cdac6b14@usw-ex0105-037.remarq.com>

I'm a beginning web designer and I have a rather large site in
the works.  But, i've searched far and near to find a free host
that is Perl-friendly.. anyone have any suggestions or know
where to point me?  I'm under financial restaints (aka I don't
get paid enough at my present job) to serve my own site at
home.  I just need some place for the meantime.

Thanks in advance,
                        Jake
 ShadeeJake1@aol.com



-----------------------------------------------------------

Got questions?  Get answers over the phone at Keen.com.
Up to 100 minutes free!
http://www.keen.com



------------------------------

Date: Mon, 24 Jul 2000 23:45:27 -0700
From: Matthew Keene <matthew.keeneNOmaSPAM@colesmyer.com.au.invalid>
Subject: Re: Any free Perl-Friendly hosts?
Message-Id: <11a31b03.e490dd21@usw-ex0105-034.remarq.com>

Try http://free.prohosting.com.  Unfortunately they've recently
started forcing banners onto pages, but what do you want for
nothing ?


-----------------------------------------------------------

Got questions?  Get answers over the phone at Keen.com.
Up to 100 minutes free!
http://www.keen.com



------------------------------

Date: 25 Jul 2000 06:11:03 GMT
From: Steffen Beyer <sb@muccpu1.muc.sdm.de>
Subject: Re: day_of_week() and age() without using Date::Calc ?
Message-Id: <8ljb1n$fr6$2@solti3.sdm.de>

In article <8lj1d0$pmp$1@nnrp1.deja.com>, madsere@my-deja.com wrote:

> I am frantically looking for two functions:

> 1) One that can return the day-of-week for a given date
> 2) one that can return the age for a given date (birthday)

> Yeah I know - Date::Calc can do it.

> Unfortunately my web hosting service doesn't have it installed and is
> not very quick in installing new modules - to say the least.

> Anybody have a function or algorithm for this lying around?

First of all, one can also install modules locally (see "man perlmodinstall").
Second, a plain Perl version of Date::Calc exists, called Date::Pcalc.
To be found on CPAN where Date::Calc lies.
Third, you can probably do with Perl's builtin function "localtime" alone.
(See "man perlfunc" and the FAQ)
Fourth, every Perl installation contains some Date and Time modules,
like Time::Local (I think).

Good luck!
-- 
    Steffen Beyer <sb@engelschall.com>
    http://www.engelschall.com/u/sb/whoami/ (Who am I)
    http://www.engelschall.com/u/sb/gallery/ (Fotos Brasil, USA, ...)
    http://www.engelschall.com/u/sb/download/ (Free Perl and C Software)


------------------------------

Date: 25 Jul 2000 05:18:27 GMT
From: dkcombs@netcom.com (David Combs)
Subject: Re: HELP: longSyntax ok, but: rHsh->{myKey} UNDEFINED??
Message-Id: <8lj7v3$e2o$2@slb0.atl.mindspring.net>

Thanks everyone.

Of course that was a hash KEY -- obvious -- but
not to me until several people pointed it out.

Question: IS there a way to "declare" hash keys so that
you DO get a compile-time error for "literal" keys?

Maybe pseudo-hashes do that? 

David



------------------------------

Date: 25 Jul 2000 05:13:52 GMT
From: The WebDragon <nospam@nospam.com>
Subject: Re: hoo boy, it's another head-scratcher...
Message-Id: <8lj7mg$o9d$0@216.155.32.41>

In article <8likg0$clf$0@216.155.32.41>, The WebDragon 
<nospam@nospam.com> wrote:

[snip]
 | Basically they changed the format of the files recently so that all the 
 | data is fetched from a SQL database via .asp instead of simply being in 
 | a java-scripted html file (  thus the html files they have now are HUGE 
 | in comparison .. the DeathMatch maps list .htm went from around 80K 
 | total to around 368K total ! =:o  )
 | 
 | I figured out on my own how to grab the new files, and hacked together a 
 | method using HTML::Parser 3.07 to extract the important text from the 
 | pages.. sort of :) 
  
no more 'sort of' .. I nailed it ! :D yeehaw!

[snip]

 | basically I need to devise a new method of parsing this data into the 
 | same sort of flat-file I had before .. so, I want to loop through these 
 | files, and throw out the headx/col_titlex data, and then parse through 
 | the rest, and sort into one single sorted output file of the format:
 | 
 | $section=$file=$title=$size=$review=$rating\n
 | 
 | again, like before. 
 | 
[snip]

did that too! <grin>

 | I'm considering the possibility of trapping the <tr></tr> tagpairs (like 
 | I'm doing with the a href="")to grab the three lines between them and 
 | using THOSE to signal for the \n's and using all \t's inbetween the 
 | relevant data (in order to make parsing the datasets MUCH easier), but I 
 | haven't wrapped my brain around that part yet. :) 

finally doped that all out -- wasn't too hard after all once I solved 
the problem with the variables losing themselves and why.. I must say 
I'm very glad y'all made me sweat thru perldsc and perllol on my own .. 
learned quite a bit that STUCK, so updating this script was a LOT 
simpler than I'd have thought only a few months ago <grin>  

here's the final script all gussied up to produce the new format for me 
:) (now all I gotta do is change the CGI slightly so that it doesn't 
tack on .zip or .html anymore to certain data, but that's easy :)

-=-final script-=-

#!perl -w
## FileGrab 0.3, 7/25/2000
## by Scott R. Godin, Laughing Dragon Services
## http://www.webdragon.net/

use strict;
use File::Spec;
use LWP::UserAgent;
use HTML::Parser 3.07;

my $input_dir = 
  File::Spec->catfile( File::Spec->curdir(), 'input_files', '');
my $baseURL = "http://www.planetunreal.com/nalicity/listmaps.asp";

# for reference purposes, entire deathmatch url is: 
# http://www.planetunreal.com/nalicity/listmaps.asp?type=6&listall=2

# map output fileslist to paired section titles and database types 
my %files_list = (
    'ut_dm_maps.htm' => [ 'utdm', '6' ],
    'ut_assault_maps.htm' => [ 'utassault', '7' ],
    'ut_domination_maps.htm' => [ 'utdomination', '8' ],
    'ut_capturetheflag_maps.htm' => [ 'utctf', '9' ],
    'ut_other_maps.htm' => [ 'utother', '10' ]
);

for (keys %files_list) {
    my $ua = new LWP::UserAgent;
    my $request = new HTTP::Request  
        'GET' => $baseURL . "?type=$files_list{$_}->[1]\&listall=2";
    my $response = $ua->request($request);
    die "$baseURL $_ failed request: ",$response->error_as_HTML 
        unless $response->is_success;

    print "Successful request of $_\n";

    open OUT, ">$input_dir$_"  or die  "Aieeeeee! $!";
        print OUT $response->content;
    close OUT;
};

my (%inside, @filedata);
# now we make sure we declare these vars OUTside the loop, (*)
sub tag {
    my($tag, $num, $info) = @_;
    $inside{$tag} += $num;
    # not for all tags 
    push @filedata, "$info->{'href'}\=" 
        if (($tag eq 'a') and ($num eq '+1'));  
    push @filedata, "\n" 
        if (($tag eq 'tr') and ($num eq '-1'));
}
sub text {
    return if $inside{script} || $inside{style};
    chomp(my $txt = $_[0]);
    $txt =~ s/^\s+$//;
    return if $txt eq "";
    if ($txt eq 'N/A') {
        push @filedata, "-1\=-1\=";
        return;
    }
    push @filedata, "$txt\=";
}

# ok let's start by paring down all the unnecessary filesize
# and JUST leave ourselves with the important data
foreach (sort(keys %files_list)) {
    # (*)but emtpy them each time THROUGH the loop. 
    @filedata = ();
    %inside = ();
    my $infile = $input_dir . $_;
    my $outfile = $infile . "l";

    HTML::Parser->new(
       'api_version' => '3',
       'handlers'    => [ 'start' => [ \&tag, "tagname, '+1', attr" ],
                          'end'   => [ \&tag, "tagname, '-1'" ],
                          'text'  => [ \&text, "text" ], ],
       'marked_sections' => '1', 
    )->parse_file($infile) || die "Can't open input file: $!\n";;
    
    for (0 .. scalar(@filedata)) {
           my $x = shift @filedata;
        last if ($x eq "\n");
        print "\=Processing $x\n" if $_ == '2';
    }

    open OUT, ">$outfile" 
      or die  "output file $outfile won't open! : $!" ;
        print OUT @filedata;
    close OUT;
};
    
my @data_List;
for (sort(keys %files_list)) {
    my $infile = $input_dir . $_ . "l";
    open GRAB, "<$infile" or die "Cannot open file $infile : $!";
        my $section = $files_list{$_}->[0];
        while(<GRAB>) {
            push @data_List, "$section\=$_" ;
        }
     close GRAB;
    print "Successful open and parse of $infile -- removing...\n";
    unlink $infile; #added this for some minor cleanup :-)
};

my $flatfile = $input_dir . 'maps_list.txt';
open OUT, ">$flatfile" 
  or die "DOH! can't create the maps list $flatfile : $!";
    print OUT @data_List;
close OUT;

print "maps_list.txt created successfully...\n";
print scalar (@data_List), " Total maps";

__END__

-=-

any suggestions on beautifying or enhancing the code are of course 
welcome.

-- 
send mail to mactech (at) webdragon (dot) net instead of the above address. 
this is to prevent spamming. e-mail reply-to's have been altered 
to prevent scan software from extracting my address for the purpose 
of spamming me, which I hate with a passion bordering on obsession.  


------------------------------

Date: Tue, 25 Jul 2000 05:42:29 GMT
From: jtbell@presby.edu (Jon Bell)
Subject: Re: how do you ? question
Message-Id: <Fy8nut.Lw9@presby.edu>

In article <4rspnscru6fq5berfpvp8ee33causcai6v@4ax.com>,
Chris  <exit72@excite.com> wrote:
>
>Please don't bother replying if your help is limited to suggestions of
>what perldoc I should read.

Does that mean you've already read the appropriate perldoc but don't
understand it?  In that case, tell us what you don't understand about it
and someone will be happy to clarify it for you.

If, on the other hand, it means you don't want to look at the appropriate
perldoc if you're pointed there, then you'd better put on your asbestos
suit...  :-/

-- 
Jon Bell <jtbell@presby.edu>                        Presbyterian College
Dept. of Physics and Computer Science        Clinton, South Carolina USA
[ Questions about newsgroups?  Visit http://www.geocities.com/nnqweb/  ]
[                or ask in news:news.newusers.questions                ]


------------------------------

Date: Mon, 24 Jul 2000 23:59:35 -0500
From: "Jim Kauzlarich" <o1technospam@skyenet.nospam.net>
Subject: newbie hashes of hashes declartion question
Message-Id: <Y19f5.337$1N5.572@newsfeed.slurp.net>

I've been fooling around with hashes of hases, and copied the following code
out of page 270 of "Programming Perl".  I've always hated copying in code
out of a book or magazine because I make too many mistakes, but this is
short and  I really don't think I did it wrong this time.

( I just like to 'hard code' variables like this when I'm learning them
because it helps me to visulize them.  )

#! /usr/bin/perl -w
use strict;
my %HoH;

%HoH = {
    flintstones => {
        lead    =>    "fred",
        pal     =>    "barney",
    },
    jetsons => {
        lead    =>    "george",
        wife    =>    "jane",
        "his boy"     =>    "elroy",
    },
    simpsones    => {
        lead    =>    "home",
        wife    =>    "marge",
        kid     =>    "bart",
    },
};

print "$HoH{flintstones}{lead}\n";

When I try to run this code I get the following err:
Odd number of elements in hash list at cartoon.cgi line 5.
Use of uninitialized value at cartoon.cgi line 22.

I've tried to do a search of Deja News, but the crush of hits I get from the
search "hashes of hashes" is daunting indeed.  What is the proper way to
phrase such a declaration?  (I've actually gotten partway down the...
(tree?)
$HoH{flintstones}{kid} = "bambam";
and
$HoH{simpsons} = { qw/lead homer wife marge kid bart/ };
work.





------------------------------

Date: Mon, 24 Jul 2000 23:16:42 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: newbie hashes of hashes declartion question
Message-Id: <MPG.13e6d0a9cd98ccd898abe4@nntp.hpl.hp.com>

In article <Y19f5.337$1N5.572@newsfeed.slurp.net>, 
o1technospam@skyenet.nospam.net says...

 ...

> #! /usr/bin/perl -w
> use strict;
> my %HoH;
> 
> %HoH = {
         ^
         (
>     flintstones => {
>         lead    =>    "fred",
>         pal     =>    "barney",
>     },

 ...

> };
  ^
  )

> print "$HoH{flintstones}{lead}\n";
> 
> When I try to run this code I get the following err:
> Odd number of elements in hash list at cartoon.cgi line 5.

That is your clue thanks to your use of '-w').  You are initializing 
your hash with a reference to an anonymous hash, but you want to 
initialize it with a list.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


------------------------------

Date: 25 Jul 2000 05:13:09 GMT
From: dkcombs@netcom.com (David Combs)
Subject: Re: PERL -w BUG!? (was: HELP: longSyntax ok, but: rHsh->{myKey} UNDEFINED??):
Message-Id: <8lj7l5$e2o$1@slb0.atl.mindspring.net>

In article <x7g0oz9x7d.fsf@home.sysarch.com>,
Uri Guttman  <uri@sysarch.com> wrote:
>>>>>> "DC" == David Combs <dkcombs@netcom.com> writes:
>
>  DC> The SERIOUS BUG (?) is that I use -w, and perl DIDN'T
>  DC>    COMPLAIN about the undefined misspelled-curline (lower-case "l").
>
>it is not a perl bug, but yours.
>
>  DC>   255:   if (! defined($recordHashRef->{curLine})) {
>  DC>   266:   print(STDERR $indentStr, "[$i]: FAILS!!!: ",
>dQuoteIt($recordHashRef->{curline}), "\n");
>
>those 2 are hash keys and perl doesn't know or check their spelling. how
>could it? and -w doesn't deal with variable declarations, use strict
>does. 

Oh, how stupid!  Thank you.



>
>changing from stupid studly caps to underlines and all lower case will
>make your life much easier. 

At least for hash keys!   :-(


>and improving your formatting and code structure will help too. i found
>your stuff to be highly unreadable and therefore much harder to debug so

Partly due to all those print-debug stmts I had.  
Have not yet gotten accustomed to the debugger.  


THANKS for pointing out that it was a hash key -- of course,
no way for compiler to know of the misspelling -- although
I suppose had I made it an OO-Object gotten via accessors,
that might have caught such errors?

David



------------------------------

Date: Tue, 25 Jul 2000 06:00:16 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: PERL -w BUG!? (was: HELP: longSyntax ok, but: rHsh->{myKey} UNDEFINED??):
Message-Id: <x7snsy92by.fsf@home.sysarch.com>

>>>>> "DC" == David Combs <dkcombs@netcom.com> writes:

  >> changing from stupid studly caps to underlines and all lower case will
  >> make your life much easier. 

  DC> At least for hash keys!   :-(

it makes vars more readable too. use underscores. that is why they were
invented.

  DC> Partly due to all those print-debug stmts I had.  
  DC> Have not yet gotten accustomed to the debugger.  

print debugging is fine. i use almost all the time. the key is knowing
how much and where to print. printing as much as you do hides the real
important information. and all your prints look the same so you can't
tell what is going on.

  DC> THANKS for pointing out that it was a hash key -- of course,
  DC> no way for compiler to know of the misspelling -- although
  DC> I suppose had I made it an OO-Object gotten via accessors,
  DC> that might have caught such errors?

no, the compiler still wouldn't. that is still a runtime error unless
you use fields.pm or another class that does some compile time checking
of accessors.

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com


------------------------------

Date: Mon, 24 Jul 2000 22:27:16 -0600
From: "Cyrus W." <cyrus@aareus.com>
Subject: Re: Perl as a win32 scheduled task
Message-Id: <397D1724.D6B78B5E@aareus.com>

You could set a registry key from your perl program, then remove the key
right before it exits.  Check, on entry to your script, if the key exists, if
it does, exit.

You will need a perl module for the registry calls, I don't recall which one.

Cyrus W.

jdallega@my-deja.com wrote:

> Hi expert(s),
>
> I am running perlwin32, I have scheduled (on the Windows task
> scheduler), one of my Perl programs to run every 5 minutes.
>
> Sometimes the program takes more than 5 minutes to execute and the
> scheduler starts the next call to the same program.
>
> How can I make sure that the first call is executed completely before
> the next one starts?
>
> Is there any code I can include in my program that says 'if i am
> running already, dont run me now'?
>
> Thanks
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.



------------------------------

Date: 25 Jul 2000 00:22:46 +0200
From: lupe@alanya.lupe-christoph.de (Lupe Christoph)
Subject: Re: perl as part of unix distribution
Message-Id: <8lifjm$sfb$1@alanya.lupe-christoph.de>

dgallardo@my-deja.com writes:

>Solaris 8 ships with perl?  We're using Solaris 7, which does not...

/usr/bin/perl=../perl5/5.00503/bin/perl5.00503 l none SUNWpl5u
-- 
| lupe@lupe-christoph.de       |        http://free.prohosting.com/~lupe |
| "jryy vg ybbxf yvxr gur l2x oht qvqa'g erne vg'f htyl urnq." "lrc. gur |
| qbbzfnlref unir orra cebira jebat lrg ntnva."  ....  "qvq lbh frr gung |
| gbb?" "ubhfgba. jr unir n ceboyrz."           User Friendly 2000-01-01 |


------------------------------

Date: 25 Jul 2000 06:17:24 GMT
From: Steffen Beyer <sb@muccpu1.muc.sdm.de>
Subject: Re: Perl's BigFloat/BigInt
Message-Id: <8ljbdk$fr6$3@solti3.sdm.de>

In article <Pine.LNX.3.96.1000725124548.16951A-100000@vile.cs.mu.OZ.AU>, Raymond WAN <rwan@cs.mu.oz.au> wrote:

>         Hello!  I'm having a problem with large numbers in a Perl script
> that I'm writing.  I think I've solved it, but I was hoping I could post a
> snip of my code to see if anyone can spot a problem.  My knowledge of Perl
> is still small and my knowledge of how Perl casts from one datatype to
> another is even less... 

>         $a1 and $a2 are integers.

>         $b = $a1 / 1000;  # Value can be < 1 [but > 0] or very large
>         $c = $a2 / 1000;  # Same range as $b
>         $d = $b * $c;     # Can be very, very large (over 4 billion)

>         I'm using Math::BigFloat and the solution given from the lines
> above looks correct.  [$d has to be printed out as a string] But when I do
> this: 

>         $d = ($a1 / 1000) * ($a2 / 1000);

>         it doesn't seem to work so I've created $b and $c in hopes that
> the BigFloat division will be used.  Does anyone know why this is so?
> Also, does anyone know how to perform an "explicit cast" in Perl so that I
> can be sure it is working?  Sorry if this offends anyone :), but I've
> programmed so long in C that I think like C a bit too much ;).

> 	BTW, if I am using both BigFloat and BigInt and I do some
> mathematical operation such as multiply, which multiply is used?  Suppose
> z = x * y and x and y are non-integers then if BigInt's multiply is used,
> then I'm going to lose information.

>         Thank you in advance!

> Raymond Wan
> rwan@csse.unimelb.edu.au


Have you considered using some "big int" math only instead?
If your largest value is a few billion, and the smallest is
something like 10E-10, just multiply all numbers with 10E+10,
add some tens of digits to the size of your (now integer)
numbers, and perform your calculations, and in the end shift
the decimal point back to where it belongs. Would that be
feasible for your problem? Could simplify some of the
problems and worries you mentioned, me thinks.

Just my $0.02...

Regards,
-- 
    Steffen Beyer <sb@engelschall.com>
    http://www.engelschall.com/u/sb/whoami/ (Who am I)
    http://www.engelschall.com/u/sb/gallery/ (Fotos Brasil, USA, ...)
    http://www.engelschall.com/u/sb/download/ (Free Perl and C Software)


------------------------------

Date: Tue, 25 Jul 2000 04:55:48 GMT
From: "Rusty Williamson" <rwilliamson@uno.gers.com>
Subject: question on lists of lists... of lists!
Message-Id: <o59f5.318$wn.11510@typhoon.san.rr.com>

Hello,

The following is working well for me...

$netTot{"$date"} = {
     "average"   => $data1,
     "med"       => $data2,
     "max"       => $data3,
     "min"       => $data4
};

 ... but, now I need to put this structure with a list.  I've been looking
but the above is as far as my books take it.  How could I take this one
level further?   In other words, now structure above must be repeated for
each $month.  The following syntax doesn't seem to work but will illustrate
the point:

$netTot{"$month"}{"$date"}={
     "average"   => $data1,
     "med"       => $data2,
     "max"       => $data3,
     "min"       => $data4
};

The above looks right to me but doesn't seem to work (I wish I knew PERL
better!).  Does anyone know the proper syntax for what I'm trying to do (and
if you want to same me an addition post... how would I reference it :-) )?

Thanks again!

------------------------------------------------------------
Rusty Williamson
Systems Programmer
GERS Retail Systems
http://www.gers.com/
The Object Workshop
http://home.san.rr.com/williamson/
Home Page
http://www.znet.com/~rusty/
------------------------------------------------------------





------------------------------

Date: Tue, 25 Jul 2000 06:04:52 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: question on lists of lists... of lists!
Message-Id: <x7puo2924a.fsf@home.sysarch.com>

>>>>> "RW" == Rusty Williamson <rwilliamson@uno.gers.com> writes:

  RW> Hello,
  RW> The following is working well for me...

  RW> $netTot{"$date"} = {

lose the quotes there, they are not needed.
  RW>      "average"   => $data1,
  RW>      "med"       => $data2,
  RW>      "max"       => $data3,
  RW>      "min"       => $data4

add a trailing comma there. it is not required but it maked it easier to
add more lines of data.

  RW> };

that is not a list of lists. it is a hash of a hash (singular since the
only top level key is $date. your subject is wrong.

  RW> $netTot{"$month"}{"$date"}={
  RW>      "average"   => $data1,
  RW>      "med"       => $data2,
  RW>      "max"       => $data3,
  RW>      "min"       => $data4
  RW> };


	$netTot{ $month } = {
			$date	=> {
				"average"   => $data1,
				"med"       => $data2,
				"max"       => $data3,
				"min"       => $data4,
			},
	} ;

there are many other ways to do that.

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com


------------------------------

Date: Tue, 25 Jul 2000 06:28:45 GMT
From: arerickson@my-deja.com
Subject: Stumped a Digitalthink PERL tutor
Message-Id: <8ljc2r$kp$1@nnrp1.deja.com>

There should be a very simple answer to this but my PERL tutor couldn't
provide one.

I have PERL set up on win98, programs work in WIN when you click on them at
lightening speed.....IN DOS, when I am in the perl\bin directory and try to
run PERL, it says:

PROGRAM CANNOT RUN IN DOS MODE.

Any solutions? I've tried most everything...

please respond arerickson@yahoo.com


Sent via Deja.com http://www.deja.com/
Before you buy.


------------------------------

Date: Mon, 24 Jul 2000 22:26:46 -0700
From: "Glen Heide" <jheide@sprint.ca>
Subject: Re: USEing a perl module
Message-Id: <dA9f5.240$fV5.7552@newscontent-01.sprint.ca>

ok, ok... so I need to be more specific.

What I meant to say was that the server does not have the module
"installed", and I want to "use" this module.  It's got all the
functionality I need, but from what you say, I *have* to get them to
"install" it before I can "use" it?

if this is the case, is there any other way to use it's functionality... I
really want to use the MIME library...

or here's an idea I thought of and do you think this will work?

I make an email using MIME::Lite on my own computer, put the output into a
text file, then simply copy the contents of the output to the sendmail by
using simple Print commands.  Will that work at least?


--
    Yours Truly,
        Glen Heide


"Tad McClellan" <tadmc@metronet.com> wrote in message
news:slrn8npvhp.af0.tadmc@magna.metronet.com...
> On Tue, 25 Jul 2000 13:57:57 +1200, Peter Sundstrom
<peter.sundstrom@eds.com> wrote:
> >
> >Glen Heide wrote in message ...
> >>What are the steps to making a perl file use a perl module?
> >>
> >>On the server I use (paid server), they don't have the MIME::Lite
module,
>                                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>
> >>I have to install it myself... though I've been having no luck so far.
>
> >If you have set the path correctly in the "use lib", then everything will
be
> >fine (assuming of course, that the rest of your code has no bugs).
>  ^^^^
>  ^^^^
>
>
> Eh?
>
> The module is not installed.
>
> "use lib" isn't going to install the module.
>
>
> --
>     Tad McClellan                          SGML Consulting
>     tadmc@metronet.com                     Perl programming
>     Fort Worth, Texas




------------------------------

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V9 Issue 3793
**************************************


home help back first fref pref prev next nref lref last post