[15598] in Perl-Users-Digest
Perl-Users Digest, Issue: 3011 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu May 11 00:05:42 2000
Date: Wed, 10 May 2000 21:05:10 -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: <958017909-v9-i3011@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Wed, 10 May 2000 Volume: 9 Number: 3011
Today's topics:
? How to query secured web-site <songtao@cisco.com>
Re: Also error installing libxml-enno-1.02.tar.gz (Eric Bohlman)
baby steps with complex hashes of hashes of hashes of a <nospam@devnull.com>
Re: baby steps with complex hashes of hashes of hashes <uri@sysarch.com>
Re: blat and mail server <wyzelli@yahoo.com>
Re: C-shell vs perl <baughj@rpi.edu>
Re: C-shell vs perl <bwalton@rochester.rr.com>
Re: Clear and then Reuse a package name space richard_chen@my-deja.com
Re: COBOL subroutines in Perl? <dan@tuatha.sidhe.org>
Re: comparing a folder full of files to a comma,separat <uri@sysarch.com>
Re: comparing a folder full of files to a comma,separat <nospam@devnull.com>
Re: fork does not work properly on NT! (Clinton A. Pierce)
Getting the text of a subroutine? <slu_2@altavista.net>
Re: Help Needed - Perl Matching Operator <phill@modulus.com.au>
How to inspect "my" variables in perldebug? <yuwen@microtek.com.cn>
MUCH better DATA file formatting :) (THANK YOU) <nospam@devnull.com>
Re: Net::Telnet question <nnickee@nnickee.com>
Re: Net::Telnet question (Eric Bohlman)
Re: Object Question <slu_2@altavista.net>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 10 May 2000 23:23:48 -0400
From: Songtao Chen <songtao@cisco.com>
Subject: ? How to query secured web-site
Message-Id: <391A27C4.324D9D1A@cisco.com>
Hi,
Can anyone tell me how to query secured web-site (GET)
using LWP package, assuming I have the right ID/password
for the site ?
Thanks,
Songtao
------------------------------
Date: 11 May 2000 01:23:14 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: Also error installing libxml-enno-1.02.tar.gz
Message-Id: <8fd222$4k1$3@nntp9.atl.mindspring.net>
Thomas Åhlen (thomas2@dalnet.se) wrote:
: This isn't making me any happier either.
: "XML::Parser::ContentModel" at CmpDOM.pm line 179.
: dubious
The problem is that version 2.28 of XML::Parser changed some interfaces
dealing with DTDs and wound up breaking a good deal of Enno's code, which
Enno is unfortunately just too busy to fix at the moment. He suggests
dropping back to version 2.27 of XML::Parser until he gets a chance to
catch up.
------------------------------
Date: 11 May 2000 01:09:47 GMT
From: The WebDragon <nospam@devnull.com>
Subject: baby steps with complex hashes of hashes of hashes of arrays
Message-Id: <8fd18r$b3$0@216.155.32.159>
(was that topic succinct enough Uri? :D )
ok, you're makin me do this the hard way, so I *really am learning it or
at least trying to*
this *works* :
#!perl -w
use strict;
use diagnostics -verbose;
#this might be backwards =:o I dunno yet. :(
#it's just not used yet
my %masterkeys = (
'Assault' => 'AS',
'CaptureTheFlag' => 'CTF',
'DeathMatch' => 'DM',
'Domination' => 'DOM',
'UTOther' => 'OTHER',
);
# good first attempt at creating it by hand, but I still dunno how to
extract the
# data FROM the maps_list.txt file to get it in here in the first place!
my %complextable = (
'Assault' => {
'as-test' => [ 'AS-Test', '500', 'as-test', '5' ],
'as-something' => [ 'AS-SomeThing', '1234', '-1', '-1' ],
'as-newmap' => [ 'AS-NewMap', '786', 'as-newmap', '9.5' ]
},
'CaptureTheFlag' => {
'ctf-test0r' => [ 'CTF-Test0r', '236', 'ctf-test0r', '7.5' ],
'ctf-someotherthing][' => [ 'CTF-SomeOtherThing][', '2867',
'-1', '-1' ],
'ctf-othermap]|[' => [ 'CTF-OtherMap]|[', '1436',
'ctf-othermap]|[', '5.5' ]
}
);
foreach my $GameType (keys %complextable) {
print "GameType is $GameType\n";
foreach my $mapName (sort (keys %{ $complextable{$GameType}})) {
my($Title, $size, $review, $rating) = @{
$complextable{$GameType}{$mapName}};
print "MapName: $mapName.zip, Title: $Title, FileSize: $size, ";
if ($rating != -1) { print "Review: $review.html, Rating:
$rating\n"}
else {print "Review: N/A, Rating: N/A\n"}
}
print "==\n"
}
program output :
GameType is Assault
MapName: as-newmap.zip, Title: AS-NewMap, FileSize: 786, Review:
as-newmap.html, Rating: 9.5
MapName: as-something.zip, Title: AS-SomeThing, FileSize: 1234, Review:
N/A, Rating: N/A
MapName: as-test.zip, Title: AS-Test, FileSize: 500, Review:
as-test.html, Rating: 5
==
GameType is CaptureTheFlag
MapName: ctf-othermap]|[.zip, Title: CTF-OtherMap]|[, FileSize: 1436,
Review: ctf-othermap]|[.html, Rating: 5.5
MapName: ctf-someotherthing][.zip, Title: CTF-SomeOtherThing][,
FileSize: 2867, Review: N/A, Rating: N/A
MapName: ctf-test0r.zip, Title: CTF-Test0r, FileSize: 236, Review:
ctf-test0r.html, Rating: 7.5
==
as you can see i CAN do it 'backwards' .. but this is not what I need
really.. that maps_list.txt file is over 1400 lines long :D
it's rare I would ever have to sort by $GameType (keys %complextable),
but I specifically set things up so that I could sort by $mapName (keys
%{ $complextable{$GameType}}) because they will have to be sorted
alphabetically when output.
now it's VERY simple to output these "by line" so that you can wind up
with
<tr>
<td align="left"><a href="$filename.zip">$Title</a></td>
<td align="right">$size</td>
<td align="center"><a href="$review.html" target="_new">$rating</a></td>
</tr>
<tr>
<td align="left"><a href="$filename.zip">$Title</a></td>
<td align="right">$size</td>
<td align="center"><a href="$review.html" target="_new">$rating</a></td>
</tr>
<tr>
<td align="left"><a href="$filename.zip">$Title</a></td>
<td align="right">$size</td>
<td align="center"><a href="$review.html" target="_new">$rating</a></td>
</tr>
HOWEVER, I know for CERTAIN that that sort of crap table takes FOREVER
and a day to render by the browser.
what I'd REALLY like to be able to do is this:
<tr>
<td align="left">
<a href="$filename1.zip">$Title1</a><br>
<a href="$filename2.zip">$Title2</a><br>
<a href="$filename3.zip">$Title3</a><br>
</td>
<td align="right">
$size1<br>
$size2<br>
$size3<br>
</td>
<td align="center">
<a href="$review1.html" target="_new">$rating1</a>
<a href="$review2.html" target="_new">$rating2</a>
<a href="$review3.html" target="_new">$rating3</a>
</td>
</tr>
having only THREE cells in the table will make re-draw MUCH faster.
the problem comes in how to parse the %complextable in that manner...
I'm thinking of running thru the %complextable once, pushing the values
to be displayed into new %hashes for each column, and then plowing
through each as necessary.
this IS a complex problem.. I'm not as familiar with the sorting and
datstructures as I should be, to re-order this mess into the format I
want, but I DO have the fact that I have a CLEAR idea of what I want, as
a guide.
I wish I wasn't such a newbie to perl.. I really want to get this thing
done so I can move onto some other ideas I have. :\
I'd be grateful for any assistance... pointers to books or manpages are
nice, and I'm learning a lot and quickly, and I have a lot of that
already, but to put it mildly... HELP! :D
(I used to want to kick my high school teachers when I came to them with
a question about something I'd read in the book, and they'd say "it's in
the book" .. I'd be like, "if I could understand the damn book, I
wouldn't be asking YOU, dammit! YOU'RE the teacher! TEACH!" ) this is
merely anecdotal, and not intended as a slap.. I really really
appreciate people pointing me in the right direction, and any examples
you can supply.. I'm just way outta my league and know it. :|
The way I learn best and fastest is from WORKING examples that work with
my data. THEN I can usually go back and figure out WHY it works and how
to apply it to other things.. (as some of you have already noted ;)
*shrug* my brain works differently than most. :)
(maybe that's why I like perl so much :D hee!)
--
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: Thu, 11 May 2000 03:10:30 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: baby steps with complex hashes of hashes of hashes of arrays
Message-Id: <x7wvl1srx8.fsf@home.sysarch.com>
>>>>> "TW" == The WebDragon <nospam@devnull.com> writes:
TW> (was that topic succinct enough Uri? :D )
i never complained about your subjects, just your var names. :)
and your subjects are descriptive and plentiful!
TW> ok, you're makin me do this the hard way, so I *really am learning it or
TW> at least trying to*
i love to see newbies sweat!
TW> this *works* :
good!
TW> #!perl -w
TW> use strict;
TW> use diagnostics -verbose;
remove that during production. the diagnostics module really slows
things down
TW> # good first attempt at creating it by hand, but I still dunno how to
TW> extract the
TW> # data FROM the maps_list.txt file to get it in here in the first place!
my last post in some other trhead has the answer for that. actually it
works for the single level and you have a 2 level hash of hashes here. i
still don't get your input format and structure but i haven't put much
time into that. it looks very simple.
TW> foreach my $GameType (keys %complextable) {
TW> print "GameType is $GameType\n";
TW> foreach my $mapName (sort (keys %{ $complextable{$GameType}})) {
good. that is the inner hash loop idiom. learn it well.
TW> my($Title, $size, $review, $rating) = @{
TW> $complextable{$GameType}{$mapName}};
good, a complex array dereference. you are doing well. i assume your
mailer did the bad wrapping. be careful if that is the real format of
your code.
TW> as you can see i CAN do it 'backwards' .. but this is not what I need
TW> really.. that maps_list.txt file is over 1400 lines long :D
just go backwards. start with the same logical loops and work your way
in. you first need the gametype parsed out and then loop over the inner
data. here is some example code without the parsing stuff (pseudo code):
#we have $game_type we loop over the lines
$game_hash = {}
while ( <GAME_LINE> ) {
parse line ;
$game_hash->{'title'} = $title ;
....
}
$main_hash{ $game_type } = $game_hash ;
so you have a 2 level hahs of hashes here.
TW> now it's VERY simple to output these "by line" so that you can wind up
TW> with
TW> what I'd REALLY like to be able to do is this:
if you can generate the output above, you can generate html tables. the
key to tables is to use lists and do the work later. you can also do
some conversion on the fly and map does well there.
TW> <td align="center">
TW> <a href="$review1.html" target="_new">$rating1</a>
TW> <a href="$review2.html" target="_new">$rating2</a>
TW> <a href="$review3.html" target="_new">$rating3</a>
TW> </td>
TW> having only THREE cells in the table will make re-draw MUCH faster.
you have 3 hrefs in each of the outer cells. is that right?
TW> I'd be grateful for any assistance... pointers to books or manpages are
TW> nice, and I'm learning a lot and quickly, and I have a lot of that
TW> already, but to put it mildly... HELP! :D
you actually might want to hire someone depending on your time and
budget constraints.
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: Thu, 11 May 2000 11:16:53 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: blat and mail server
Message-Id: <iioS4.17$dS.1204@vic.nntp.telstra.net>
John Colton <colton@socrates.berkeley.edu> wrote in message
news:3919d026.517323664@agate.berkeley.edu...
>
> I'm running Windows 98 (my web page is being served by Apache), but I
> do not have a mail server installed. Is a separate mail server program
> needed? Or does blat (as I supposed) handle all aspects of sending the
> mail?
>
Totally OT for this NG but..
Blat needs a mail server to talk to somewhere. Read the docs.
Wyzelli
------------------------------
Date: Wed, 10 May 2000 22:37:16 -0400
From: justin baugh <baughj@rpi.edu>
Subject: Re: C-shell vs perl
Message-Id: <391A1CDC.8612D57E@rpi.edu>
> I'm a comparative rookie using perl. I have a C-shell script that runs
> a query against the Informix database, calls a perl script to process
> the results (with 1 "if" followed by 25 "elsif's" for each rec),
> truncates a table, then calls another C-shell script to dbload the
> processed data into the table.
>
> Wanting control to be in 1 script, I added system([commands]) calls to
> the perl script to eliminate the original C-shell script. However when
> it runs, it never finishes the dbload correctly. It gives an erroneous
> error msg saying the "fixed length" rec is out of range, when its not.
> It actually loads 12,321 out of 12,531 records and stops on the same rec
> each run. Am I doing something wrong? Is there some kind of perl memory
> limitation that would cause this? Any help will be appreciated.
You should be using DBI. And also, how the heck are we supposed to
know what is wrong if you don't show us the code?
"Short Guide to DBI": http://www.perl.com/pub/1999/10/DBI.html
~j
--
==================================================
Justin Baugh (baughj@nocannedmeat.rpi.edu)
PGP: http://www.rpi.edu/~baughj/keys.txt
"Evil is easy, and has infinite forms." - Pascal
------------------------------
Date: Thu, 11 May 2000 03:02:02 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: C-shell vs perl
Message-Id: <391A21B3.65DA4739@rochester.rr.com>
fg19537@my-deja.com wrote:
...
> the perl script to eliminate the original C-shell script. However when
> it runs, it never finishes the dbload correctly. It gives an erroneous
> error msg saying the "fixed length" rec is out of range, when its not.
> It actually loads 12,321 out of 12,531 records and stops on the same rec
> each run. Am I doing something wrong? Is there some kind of perl memory
> limitation that would cause this? Any help will be appreciated.
...
It is pretty unlikely that a size limitation in Perl is causing your
problem. Perl is specifically designed with as few limits as possible.
Maybe something else in your system is limiting things? And BTW, what
is your hardware? OS? Perl version? What modules are you using?
Their versions? Are you actually loading that many records from a
database into memory all at once? Maybe there's a way to do it a record
at a time?
If you actually want specific help with your problem, you need to ask a
specific question about Perl. For example, whittle your script down to
the smallest subset that still exhibits the problem (no more than a page
if possible), and ask about that. Provide a complete example we can
copy/paste/run to see the problem ourselves. You refer to a "dbload".
I don't see that in the Perl docs. What is it? If it's not Perl, this
is the wrong place. And when you mention your error message, please
copy-paste it into your note so we can see it too.
--
Bob Walton
------------------------------
Date: Thu, 11 May 2000 01:23:19 GMT
From: richard_chen@my-deja.com
Subject: Re: Clear and then Reuse a package name space
Message-Id: <8fd21q$gj8$1@nnrp1.deja.com>
In article <39188d73.723e$42@news.op.net>,
mjd@plover.com (Mark-Jason Dominus) wrote:
> In article <39155774.4C9360FF@snet.net>, Richard Chen
<qchen@snet.net> wrote:
> >The scrub_package written by Mark Jason Dominus
> >almost does it except a fatal flaw which results in the undef
> >of the source subroutine.
>
> That is not a fatal flaw, or a bug. It is a feature.
>
> The function erases everything in a package. If the package that you
> ask it to erase contains the function itself, it erases itself. If it
> didn't do this, *that* would be a bug.
>
Yes, it is supposed to erase everything in a package. But ONLY
for the things in THAT package, not the ones that are outside
the package. For example, if I ask to remove everything
in package Q, it should not erase a subroutine
in the main package. But scrub_package in its original form
does exactly that.
If in the main package you set
*Q::myfunc=\&a_func_in_main;
Then after calling scrub_package, the main::a_func_in_main
is gone!
Here is the simplest demonstration of this "feature":
$ cat tmp.pl
#!/usr/bin/perl -w
use strict;
*Q::hello=\&hello;
scrub_package('Q');
&hello();
sub hello { print "hi"; }
sub scrub_package {
no strict 'refs';
my $pack = shift;
die "Shouldn't delete main package"
if $pack eq "" || $pack eq "main";
my $stash = *{$pack . '::'}{HASH};
my $name;
foreach $name (keys %$stash) {
my $fullname = $pack . '::' . $name;
# Get rid of everything with that name.
undef $$fullname;
undef @$fullname;
undef %$fullname;
undef &$fullname;
undef *$fullname;
}
}
$ ./tmp.pl
Name "Q::hello" used only once: possible typo at ./tmp.pl line 3.
Undefined subroutine &main::hello called at ./tmp.pl line 5.
In the modperl environment this is disastrous because
the next request will not find the subroutine it needs!
It gets undef'ed along with the throw-away package Q.
> Your complaint is like someone complaining that
>
> /bin/rm /bin/*
>
> erases the `rm' command. But that is what it was designed to do.
>
No. It is not a proper analogy. It is like I ask to
get a link to /path/to/file be made. All I ask is to remove
the link. However, after the "rm" removes this link,
the original /path/to/file got removed! Even hard links
on unix will not do that. Hard link on unix will make an extra
link so that once you remove the newly made link, the original
one still exist.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Thu, 11 May 2000 03:51:34 GMT
From: Dan Sugalski <dan@tuatha.sidhe.org>
Subject: Re: COBOL subroutines in Perl?
Message-Id: <a7qS4.83179$hT2.348287@news1.rdc1.ct.home.com>
In comp.lang.perl.modules Doc Shipley <drdoc@mail.utexas.edu> wrote:
> I'm posting this for a friend stranded in VPN-Land, and I'm not familiar
> with perl, si please forgive the crosspost....
>> Is it possible to call a COBOL subroutine in a perl
>> script? I know I can call a compiled COBOL program,
>> but what about an interpreted subroutine?
If your platform supports it, there's no reason you couldn't have XS code
written in COBOL instead of C. The big issue would be writing the wrappers
for it, or convincing the COBOL compiler to spit out what perl wants. (C
wrappers are easier) PDL does this with Fortran, for example.
Dan
------------------------------
Date: Thu, 11 May 2000 02:53:52 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: comparing a folder full of files to a comma,separated list
Message-Id: <x7zopxssoz.fsf@home.sysarch.com>
>>>>> "TW" == The WebDragon <nospam@devnull.com> writes:
TW> In article <x7aehytf58.fsf@home.sysarch.com>, Uri Guttman
TW> <uri@sysarch.com> wrote:
TW> |
TW> | TW> %array = (
TW> | TW> 'as-abraxasassault' => [ 'AS-AbraxasAssault', '1288',
TW> | TW> 'as-abraxasassault', '8' ],
TW> -- Assault
TW> "as-asthenosphere","AS-Asthenosphere",2198,"as-asthenosphere",9
TW> "as-bankjob","AS-Bankjob",2272,"as-bankjob",7.5
TW> "as-bluff","AS-Bluff",3788,"-1",-1
TW> -- CaptureTheFlag
TW> etc etc
TW> could I do
TW> %fileList = ();
the clearing is not needed if you haven't touched it since
declaration. if this is in a larger loop it could be needed.
TW> while (<>) {
TW> next if /^--/ ; #I think I need some kind of modifier there
TW> #It's supposed to skip lines that start with
TW> '--'
the if IS the modifier. that is a common perl idiom. notice the exit
clause is first. in these short skip the line things, the important
thing is the skip so it usually comes first. the other way would be:
/^--/ && next ; ugly
TW> my($filename, $Title, $filesize, $review, $rating) = split ',';
are you sure there are no commas in any of the fields? some of the
strings are quoted so that could happen. use a CSV module (see cpan) to
correctly parse that string for you if there is any doubt about the
input.
and after the split, you are not removing the quote chars around some of
the fields.
p TW> push %fileList{$filename}, [$Title, $filesize, $review, $rating];
TW> };
TW> but now, on second thought after thinking about it..
on second thought, that is very wrong. you don't use push with hashes,
only with arrays. in this case all you need to do is assign the anon
list to the hash entry:
$fileList{$filename} = [$Title, $filesize, $review, $rating] ;
all that is in perldsc as well.
TW> %masterMapsList = (
TW> $gameType => {
TW> $filename => [ $Title, $filesize, $review, $rating ],
TW> },
TW> );
TW> (interesting that you can do that)
why would expect otherwise. that is done all the time for complex data
stuctures.
TW> but I still REALLY don't understand the HOW of it.. there's TOO MUCH
TW> information in those docs. :D ohhhhh god my HEAD hurts.. I can see
TW> somewhat how to do it, but it's still messing with my BRAIN :)
TW> IF I do decide to create a %masterMapsList ... HOW FAST is it to create
TW> and access on the fly ? i.e. if I encode all this mess into a cgi script
TW> that is supposed to grab that maps_list.txt file, and display the
TW> DeathMatch maps by default, and alow the user to select a popup to
TW> display the rest.. on the fly .. how fast is it going to be? (relative
TW> to the size of the list, of course, but besides that)
it all depends on how fast you need it to be. worry about correctness
first, speed later.
TW> o how to create the regexp that grabs the $gametype on the fly from
TW> the -- line (this keeps tripping me up because I don't understand
TW> regexps at all even after re-re-re-reading perlre. everything I try,
TW> fails. I'm gonna get that book, but I need the money for that, which is
TW> one reason I'm studying this and one reason I'm posting so many
TW> questions HERE.. cuz I can't afford all the books yet! I have
TW> "Programming Perl" and "MacPerl Power and Ease" so far.. (just so you
TW> know I'm not completely slacking here)
i assume you mean MRE which is a very good book if slightly out of date
regarding regex enhancements and some speed issues. i don't know what
part of the line is the game type. i keep seeing bits and pieces of your
project so i can't answer you on other areas so quickly.
TW> o how to loop inside the $gametype for the hash while still
TW> streaming thru the file read so no duplicates get created.
???? if the gametype is the key of the main (top level) hash, it is
guaranteed to be unique.
TW> o how to correctly write the line that assignes the correct
TW> variables to the hash of lists of lists during the loop
i showed you that above.
TW> o how to correctly split the line into the appropriate vars (I think
TW> I have it up there, but a confirmation would be nice)
you have that right but the assignment was wrong.
TW> if you can help out with a short example, I CAN wrap my brain
TW> around it because it will directly apply to the 'thing that I'm
TW> trying to do' and will ENORMOUSLY help me in associating that with
TW> the correct syntax for doing so in the future (such as outputting
TW> and searching)
unfortunately i don't think perl data structures are best learned by
example. i think understanding them first makes more sense as they don't
map to commonly used features in other language. the key to perl
structures is grokking that any given scalar may only hold a single
value and that value can be a reference to a hash or array. then it
becomes easy to see how to build them up and walk through them. read
perllol and perldsc some more and it will become clearer. they have
plenty of working examples too.
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: 11 May 2000 03:30:44 GMT
From: The WebDragon <nospam@devnull.com>
Subject: Re: comparing a folder full of files to a comma,separated list
Message-Id: <8fd9h4$jce$1@216.155.32.24>
In article <x7zopxssoz.fsf@home.sysarch.com>, Uri Guttman
<uri@sysarch.com> wrote:
| TW> could I do
| TW> %fileList = ();
|
| the clearing is not needed if you haven't touched it since
| declaration. if this is in a larger loop it could be needed.
ok, I'll remember that.
| TW> while (<>) {
| TW> next if /^--/ ; #I think I need some kind of modifier there
| TW> #It's supposed to skip lines that start with
| TW> '--'
|
| the if IS the modifier. that is a common perl idiom. notice the exit
| clause is first. in these short skip the line things, the important
| thing is the skip so it usually comes first. the other way would be:
|
| /^--/ && next ; ugly
gotcha
| TW> my($filename, $Title, $filesize, $review, $rating) = split
| ',';
|
| are you sure there are no commas in any of the fields? some of the
| strings are quoted so that could happen. use a CSV module (see cpan) to
| correctly parse that string for you if there is any doubt about the
| input.
Actually I've re-written the script that grabs the list for me to strip
out the ""'s, and separate the fields with | (similar to some other
__DATA__ structures I've seen on here) ... this should make parsing that
list MUCH easier. see my other recent post with the new script, and much
will become clearer. (I'm grokking as fast as I can :D)
| and after the split, you are not removing the quote chars around some of
| the fields.
|
| p TW> push %fileList{$filename}, [$Title, $filesize, $review,
| $rating];
| TW> };
|
| TW> but now, on second thought after thinking about it..
|
| on second thought, that is very wrong. you don't use push with hashes,
| only with arrays. in this case all you need to do is assign the anon
| list to the hash entry:
|
| $fileList{$filename} = [$Title, $filesize, $review, $rating] ;
hmm, ok.. absorbing that..
[snippage]
| i assume you mean MRE which is a very good book if slightly out of date
| regarding regex enhancements and some speed issues. i don't know what
| part of the line is the game type. i keep seeing bits and pieces of your
| project so i can't answer you on other areas so quickly.
yes, I understand.. See that other recent post I mentioned above with
the program that creates the completed maps_list.txt file, using the new
formatting. That should help you follow the data structure somewhat
easier.
| TW> o how to loop inside the $gametype for the hash while still
| TW> streaming thru the file read so no duplicates get created.
|
| ???? if the gametype is the key of the main (top level) hash, it is
| guaranteed to be unique.
DOH! OK, got it. :)
| TW> if you can help out with a short example, I CAN wrap my brain
| TW> around it because it will directly apply to the 'thing that I'm
| TW> trying to do' and will ENORMOUSLY help me in associating that with
| TW> the correct syntax for doing so in the future (such as outputting
| TW> and searching)
|
| unfortunately i don't think perl data structures are best learned by
| example. i think understanding them first makes more sense as they don't
| map to commonly used features in other language. the key to perl
| structures is grokking that any given scalar may only hold a single
| value and that value can be a reference to a hash or array. then it
| becomes easy to see how to build them up and walk through them. read
| perllol and perldsc some more and it will become clearer. they have
| plenty of working examples too.
I'm trying, I'm trying! :D
hopefully I can figure this out before my BRAIN MELTS :D
ok, abandoning this topic thread and starting a new one.
--
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: Thu, 11 May 2000 03:18:05 GMT
From: clintp@geeksalad.org (Clinton A. Pierce)
Subject: Re: fork does not work properly on NT!
Message-Id: <NDpS4.70205$h01.493361@news1.rdc1.mi.home.com>
[Posted and mailed]
In article <3919EAC2.DCEB51E7@intel.com>,
"Ioffe, Robert" <robert.ioffe@intel.com> writes:
> I just installed ActiveState Perl 5.6.0 build 613 and want to try
> running my testcases in parallel by forking them. Each testcase is
> relatively heavy on resourses and I have 40 of them. That means that
> after several forks I expect fork to fail, which it prompty does after
> 12 testcases producing the following line:
>
> panic: pseudo fork() failed at regtestout.pl line 25.
>
> The 'right' fork behavior is to return either 0 (child), pid (parent),
> or undefined (fork failed), so I expect third value in my case and I
> never get it! Something happens to parent process (it dies? but then it
> should kill all its offspring according to documentation), so I never
> hear from it again, but all 12 spawned children finish properly.
This is a known problem, and I submitted a patch to the p5p list about
two weeks ago. I hope when 5.6.1 comes out it will be included. The patch
causes the Win32 fork() emulation to follow the Unix way of getting an
error when resources run out: set errno to EAGAIN and return undef.
Until then: Don't Do That. :)
If you absolutely need this patch -- and you're equipped to compile Perl under
Win32 -- I can send it to you in email.
--
Clinton A. Pierce Teach Yourself Perl in 24 Hours!
clintp@geeksalad.org for details see http://www.geeksalad.org
"If you rush a Miracle Man,
you get rotten Miracles." --Miracle Max, The Princess Bride
------------------------------
Date: Wed, 10 May 2000 22:43:16 -0400
From: Sydney Lu <slu_2@altavista.net>
Subject: Getting the text of a subroutine?
Message-Id: <7m6khs8pl0b0j6hni3gbaeuh0qf2ngkste@4ax.com>
My basic approach on this might be flawed, and if you have any
suggestions, please do tell, but:
I'm learning Perl/Tk, and the one thing I can't stand is having all
these hash-key value pairs stuck in the middle of my program, when as
far as I'm concerned, things like window positioning and the style of
buttons should be data.
So I wrote a little module that can read a file, and stick value pairs
like -expand=1 and -anchor=NW into a hash. The filehandle seems to
like to quote everything, so I had to do unholy evals to get anonymous
subroutine references into the hash correctly (for -command).
Now my question is, given a reference to an anonymous subroutine, is
there ANY way I can get back a string that contains that subroutine?
As in, if I do a
$sub_ref = sub { print 'Hello world!' };
is there anything like unholy_evil_magic_function($sub_ref) that will
yield a text string consisting of "sub { print 'Hello world!' } " ?
The reason is because I currently have a corresponding subroutine that
dumps all values back out to a file again, to be read in next time...
and I'm clueless on how to dump that back out again.
TIA,
Sydney
------------------------------
Date: Thu, 11 May 2000 13:51:40 +1000
From: Peter Hill <phill@modulus.com.au>
Subject: Re: Help Needed - Perl Matching Operator
Message-Id: <391A2E4C.3FC9@modulus.com.au>
Abigail wrote:
>
[snip]
>
> But what's that got to do with checking for valid email addresses?
> There are lots of strings that contain '@', but aren't valid email
> addresses, and lots of valid email addresses that don't contain a '@'.
That last bit ("...and lots of valid email addresses that don't contain
a '@'.") caught me by surprise. Am I reading the RFC822 BNF for
addresses wrongly, or are you referring to
non-RFC822-compliant-but-nevertheless-valid addresses?
--
Peter Hill,
Modulus Pty. Ltd.,
http://www.modulus.com.au/
------------------------------
Date: Thu, 11 May 2000 11:15:24 -0700
From: Dai Yuwen <yuwen@microtek.com.cn>
Subject: How to inspect "my" variables in perldebug?
Message-Id: <391AF8BC.56C09714@microtek.com.cn>
I can't inspect "my" variables by using X or V command in perldebug
until I remove "my" in the source. Does that mean "my" variables are
invisible?
------------------------------
Date: 11 May 2000 03:17:43 GMT
From: The WebDragon <nospam@devnull.com>
Subject: MUCH better DATA file formatting :) (THANK YOU)
Message-Id: <8fd8on$jce$0@216.155.32.24>
ok, taking my cue from another post I saw around here regarding column
transposition, and __DATA__ sections, I've made a few changes to my
code. :)
THIS should make my life a LOT easier when I go to convert this to
my %master_list = (
$game_type => {
$filename => [ $title, $size, $review, $rating]
}
}
you are welcome to try this one .. this should work beautifully. :D
#!perl -w
use strict;
use diagnostics -verbose;
use LWP::UserAgent;
use File::Spec;
my $input_dir = File::Spec->catfile( File::Spec->curdir(),
'input_files', '');
my $baseURL = "http://www.planetunreal.com/nalicity/";
# map fileslist to section titles
my %files_list = (
'ut_assault_maps.htm' => 'utassault',
'ut_capturetheflag_maps.htm' => 'utctf',
'ut_dm_maps.htm' => 'utdm',
'ut_dm_maps_b.htm' => 'utdm',
'ut_domination_maps.htm' => 'utdomination',
'ut_other_maps.htm' => 'utother'
);
#active fileslist (now deprecated)
#opendir(DIR, $input_dir) || die ("Cannot opendir $input_dir : $!");
# my @files_list = readdir(DIR);
#closedir DIR;
for (keys %files_list) {
my $ua = new LWP::UserAgent;
my $request = new HTTP::Request 'GET' => $baseURL . $_;
my $response = $ua->request($request);
die "$baseURL $_ failed: ",$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 @data_List;
for (sort(keys %files_list)) {
my $grab_File = $input_dir . $_;
open(GRAB, "<$grab_File") or die ("Cannot open file $grab_File :
$!");
print "Successful open of $grab_File\n";
my $section = $files_list{$_};
while(<GRAB>) {
tr/\r//d;
s/\"//g;
s/\,/\|/g;
next unless /^\Qmaps[i++] = new Map(\E([^)]+)/;
push @data_List, "$section\|$1\|\n" ;
}
close (GRAB);
};
open(OUT, ">maps_list.txt") or die ("DOH! can't create the maps list :
$!");
# for (@data_List) { print OUT "$_\n" }
print OUT @data_List;
close (OUT);
__END__
--
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: Wed, 10 May 2000 20:10:57 -0500
From: Nnickee TFMJ <nnickee@nnickee.com>
Subject: Re: Net::Telnet question
Message-Id: <4D1296AEED583785.25005B663A77B528.A41C9F8B97D3AC0B@lp.airnews.net>
On 11 May 2000 01:01:15 GMT, someone claiming to be efflandt@xnet.com
(David Efflandt) said:
>On Wed, 10 May 2000 18:25:07 GMT, Aran Meuser <aran@mapcruzin.com> wrote:
>>Go to your command prompt (dos shell) and type "ppm". This will start the
>>Perl Package Manager for ActivePerl. Then, you can do several things like
>>search, install, uninstal, etc, but they provide a good help for it all.
>>You'll see what I mean when you run it.
>Not sure if Win version is case sensitive, but look for "Net::Telnet",
>not "NET::telnet".
I'm not sure what the default is, but you can set case No to make it
not case sensitive.
------------------------------
Date: 11 May 2000 01:13:31 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: Net::Telnet question
Message-Id: <8fd1fr$4k1$2@nntp9.atl.mindspring.net>
bahram22@my-deja.com wrote:
: However, I cannot find the NET::telnet.pm module
: on my PC. I have installed ActivePerl5.6 on my
: WIN NT machine. Is there a site that I can
: download this particular module? Any other
: pointers will be greatly appreciated!
It's part of the bundle called libnet, which is not part of the basic
ActivePerl distribution, but is available from ActiveState by using PPM.
------------------------------
Date: Wed, 10 May 2000 23:24:18 -0400
From: Sydney Lu <slu_2@altavista.net>
Subject: Re: Object Question
Message-Id: <dt9khsodue100lqt071sh3qcf8ln9ultuo@4ax.com>
I've also found perltootc to be very enlightening.
On Wed, 10 May 2000 23:04:15 GMT, Ala Qumsieh <aqumsieh@hyperchip.com>
wrote:
>There are several good pods on OOPerl:
>
> perlobj
> perltoot
> perlbot
> perlboot
>
>Also, there is a very good book out there called "Object Oriented Perl"
>by Damian Conway (a clpmisc lurker). I recommend that you buy it.
>
>--Ala
------------------------------
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 3011
**************************************