[15594] in Perl-Users-Digest
Perl-Users Digest, Issue: 3007 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed May 10 18:07:23 2000
Date: Wed, 10 May 2000 15:05:25 -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: <957996325-v9-i3007@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Wed, 10 May 2000 Volume: 9 Number: 3007
Today's topics:
Re: 'System' command wont adduser <rootbeer@redcat.com>
Re: 'use integer' causes strange output.. <rootbeer@redcat.com>
Re: 1xPERL PROGRMMER NEEDED... (Isofarro)
a s/// tip from Webqueene <webqueen@my-deja.com>
Re: a s/// tip from Webqueene <tony_curtis32@yahoo.com>
Re: a s/// tip from Webqueene (Abigail)
Re: a s/// tip from Webqueene <tony_curtis32@yahoo.com>
Re: a s/// tip from Webqueene <webqueen@my-deja.com>
Re: after the whatever.cgi? question? <no@spaming-or-else-ill-lame-you.com>
Also error installing libxml-enno-1.02.tar.gz <thomas2@dalnet.se>
Re: Array of Structs. <uri@sysarch.com>
Re: BEGIN and use <bmb@ginger.libs.uga.edu>
blat and mail server (John Colton)
C-shell vs perl fg19537@my-deja.com
Re: Can a informix database manipulated by perl program <makarand_kulkarni@My-Deja.com>
CGI and Upload/Download <callum@online-home.freeserve.co.uk>
Commifying <kristor@NOcuchulainSPAM.com>
Re: Commifying <sariq@texas.net>
Re: Commifying (Andrew Johnson)
Re: Commifying <dave@dave.org.uk>
Re: comparing a folder full of files to a comma,separat <nospam@devnull.com>
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>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 10 May 2000 12:24:35 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: 'System' command wont adduser
Message-Id: <Pine.GSO.4.10.10005101219150.3921-100000@user2.teleport.com>
On Wed, 10 May 2000, Derrick Hopkins wrote:
> $command = "adduser -d /www/htdocs/$fulldomain -s /bin/nologin -g web -m -k
> /www/tmpdomain -p $password $username";
> $add = system($command);
It might be better (since I suspect that some of those values may come
from a potentially-untrusted source) to use the list-form of system. In
fact, it would probably be good to check the perlsec manpage for safety
reasons.
I suspect that the adduser command is either trying to talk directly to
the terminal (perhaps because it _can_ ask for a password and it's written
to require that, say) or it's reporting something useful to standard error
(where, perhaps, your cron is not putting it where you're looking. It may
help to make sure that errors are going to a log file somewhere, and to
make sure that you can run adduser when you call it from cron directly -
but don't set it to keep running every fifteen minutes. :-)
Of course, the author of adduser may have made it non-scriptable on
purpose, for security reasons. (Well, not "non-scriptable" exactly, but
requiring a tty.)
Good luck!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Wed, 10 May 2000 12:08:51 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: 'use integer' causes strange output..
Message-Id: <Pine.GSO.4.10.10005101159180.3921-100000@user2.teleport.com>
On Wed, 10 May 2000, Justin Wyllie wrote:
> I've got the following line in my code:
>
> use integer;
>
> This pragma (I'm none too sure what a pragma is I have to admit being
> new to this) forces my calculations to return integer values eg. 8 / 3
> results in 2 not 2.666667.
A 'pragma' is a directive to the compiler, telling it something about your
code.
> This all works fine when I run my code under my active state port of perl
> for win32. But when I run the same script, which contains this line, on my
> ISP's server (Linux) I get a scrambled result.
> I am using CGI.pm as you probably guessed.
Yes, I guessed that, but probably not for the reason you suspected! Using
the Psi::ESP module, I can see from here that you're using the "named
argument syntax" for calling some of the CGI module's functions. Due to a
bug in older versions of Perl, there's a conflict between 'use integer'
and the way that the named argument syntax works. (Technical information
for those who are interested: A dash in front of a string is actually
"negating" that string, and integer negation used code which didn't do
this properly for strings.)
You could fix this by upgrading the perl installation, but that may not be
an option for you. The workaround is to quote the first named argument,
like I've done in this code which calls the cgi_defrotz function, which is
available in imaginary versions of CGI.pm.
my @fred = cgi_defrotz(
'-name' => 'bedrock.html', # quotes around '-name'!
value => 42,
pet => 'dino',
);
Cheers!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Wed, 10 May 2000 18:12:32 GMT
From: micd@isofarro.freeservewithnochips.co.uk (Isofarro)
Subject: Re: 1xPERL PROGRMMER NEEDED...
Message-Id: <3919a68e.4718106@news.freeserve.net>
On 9 May 2000 21:18:32 -0600, Art Sackett <asackett@artsackett.com>
wrote:
>On Tue, 09 May 2000 19:33:52 GMT in alt.html AztecOne / Chris
><pagesusa@hotmail.com> honored us all with these words:
>AC:
>AC: You seem to assume our prices are unreasonable. Our prices are not
>AC: unreasonable.
>
>Speak for yourself. My prices are very much unreasonable.
_don't_ use that as your marketing logo :-)
Iso.
--
alt.html microFAQ: http://hyweljenkins.com/support/mfaq.htm
HTML FAQ: http://www.htmlhelp.com/faq/html/all.html
Jukka's Usenet guide: http://www.hut.fi/u/jkorpela/usenet/
Hiding source code: http://www.vortex-webdesign.com/help/hidesource.htm
------------------------------
Date: Wed, 10 May 2000 18:39:40 GMT
From: webqueen, queen of the web <webqueen@my-deja.com>
Subject: a s/// tip from Webqueene
Message-Id: <8fcad8$leo$1@nnrp1.deja.com>
I discovered a little trick today that might be interesting to some
readers.
I was trying to add a zero to integers. So for a given integer:
34093
becomes 340930
I didn't give it a second thought an immediately coded:
$d =~ s/(\d+)/$1\0/;
which some of you (non-gurus like me) may have thought of too. As you
would find out as did I, this results in:
34093
and as far as can be determined from the screen, did nothing. Pulling
out the ol' Perl Programming to p 74, I rediscovered something I'd read
in my early days of Perl study but never had occasion to use, that \N (N
an integer) results in the control-char for that ASCII value, so I guess
I was in fact appending a non-printing ^0 to my integer.
Tom's fix which worked nicely, was to enclose the $n variable in braces:
$d =~ s/(\d+)/${1}0/;
And botta-bing botta-boom I got the right result:
340930
Just thought I'd share this little tidbit as it may save you some time
later.
HUG,
-WQ
--
Time is nature's way of preventing everything from happening at once.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 10 May 2000 13:57:12 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: a s/// tip from Webqueene
Message-Id: <873dnqw7w7.fsf@shleppie.uh.edu>
>> On Wed, 10 May 2000 18:39:40 GMT,
>> webqueen, queen of the web <webqueen@my-deja.com> said:
> I was trying to add a zero to integers. So for a given
> integer:
> 34093 becomes 340930
"Adding" a zero to an integer would be a no-op.
> I didn't give it a second thought an immediately coded:
Well, there's no need to pull in the weight of regexps.
perl will do the right thing
$n .= 0;
autoconverting between numeric and string values.
You could also smash with interpolation:
$n = "${n}0";
Or of course the more obvious
$n *= 10;
since this is a numeric value :-)
hth
t
------------------------------
Date: 10 May 2000 19:17:16 GMT
From: abigail@foad.org (Abigail)
Subject: Re: a s/// tip from Webqueene
Message-Id: <slrn8hjdds.so9.abigail@ucan.foad.org>
On 10 May 2000 13:57:12 -0500, Tony Curtis <tony_curtis32@yahoo.com> wrote:
++ >> On Wed, 10 May 2000 18:39:40 GMT,
++ >> webqueen, queen of the web <webqueen@my-deja.com> said:
++
++ > I was trying to add a zero to integers. So for a given
++ > integer:
++ > 34093 becomes 340930
++
++ "Adding" a zero to an integer would be a no-op.
++
++ > I didn't give it a second thought an immediately coded:
++
++ Well, there's no need to pull in the weight of regexps.
++ perl will do the right thing
++
++ $n .= 0;
++
++ autoconverting between numeric and string values.
++
++ You could also smash with interpolation:
++
++ $n = "${n}0";
++
++ Or of course the more obvious
++
++ $n *= 10;
++
++ since this is a numeric value :-)
That fails for $n == 0.
Abigail
------------------------------
Date: 10 May 2000 14:27:30 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: a s/// tip from Webqueene
Message-Id: <87zopyurx9.fsf@shleppie.uh.edu>
> On 10 May 2000 19:17:16 GMT,
> abigail@foad.org (Abigail) said:
>> Or of course the more obvious $n *= 10;
>> since this is a numeric value :-)
> That fails for $n == 0.
Pooh, stupid boundary condtitions :-) Well, it fails if
"add a zero" doesn't mean exactly "* 10"; the ambiguity
was in the original article which unfortunately confused
integer and string values, and only used a non-zero
example.
Point taken though.
t
------------------------------
Date: Wed, 10 May 2000 21:13:34 GMT
From: webqueen, queen of the web <webqueen@my-deja.com>
Subject: Re: a s/// tip from Webqueene
Message-Id: <8fcjdf$bp$1@nnrp1.deja.com>
Tony:
The regex was vastly simplfied from it's original for the purpose of
illustration. Otherwise I would have used one of the obvious solutions
you gave. Adding the 0 was only a small part of the substitution, but
the rest wasn't relevent.
However, I do like that little "Smash with interpolation" gem you tossed
in I'm gonna play with that a bit :)
HUG,
-WQ
In article <873dnqw7w7.fsf@shleppie.uh.edu>,
Tony Curtis <tony_curtis32@yahoo.com> wrote:
> >> On Wed, 10 May 2000 18:39:40 GMT,
> >> webqueen, queen of the web <webqueen@my-deja.com> said:
>
> > I was trying to add a zero to integers. So for a given
> > integer:
> > 34093 becomes 340930
>
> "Adding" a zero to an integer would be a no-op.
>
> > I didn't give it a second thought an immediately coded:
>
> Well, there's no need to pull in the weight of regexps.
> perl will do the right thing
>
> $n .= 0;
>
> autoconverting between numeric and string values.
>
> You could also smash with interpolation:
>
> $n = "${n}0";
>
> Or of course the more obvious
>
> $n *= 10;
>
> since this is a numeric value :-)
>
> hth
> t
>
--
Time is nature's way of preventing everything from happening at once.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 10 May 2000 22:59:04 +0100
From: "Jeff Winner" <no@spaming-or-else-ill-lame-you.com>
Subject: Re: after the whatever.cgi? question?
Message-Id: <8fcm3i$7oc$1@supernews.com>
Whats this CGI.pm do i download and put it on my server or what?
Jeff
"Jeff Winner" <no@spaming-or-else-ill-lame-you.com> wrote in message
news:8f954t$ncp$1@supernews.com...
> say if i had whatever.cgi?chacha=lalala
>
> how do i get the value of the think after the question mark (chacha) and
> after the equals (lalala)
>
> Thanks
>
> Jeff
>
>
------------------------------
Date: Wed, 10 May 2000 20:30:05 GMT
From: "Thomas Åhlen" <thomas2@dalnet.se>
Subject: Also error installing libxml-enno-1.02.tar.gz
Message-Id: <hFjS4.26$kt.9881@dummy.bahnhof.se>
This isn't making me any happier either.
cpan> install E/EN/ENNO/libxml-enno-1.02.tar.gz
Running make for E/EN/ENNO/libxml-enno-1.02.tar.gz
Unwrapped into directory /root/.cpan/build/libxml-enno-1.02
Has already been processed within this session
Running make test
make[1]: Entering directory `/root/.cpan/build/libxml-enno-1.02/XQLParser'
make[1]: Leaving directory `/root/.cpan/build/libxml-enno-1.02/XQLParser'
PERL_DL_NONLAZY=1
/usr/bin/perl -Iblib/arch -Iblib/lib -I/usr/lib/perl5/5.00503/i386-linux -I/
usr/lib/perl5/5.00503 -e 'use Test::Harness qw(&runtests $verbose);
$verbose=0; runtests @ARGV;' t/*.t
t/build_dom.........FAILED test 2
Failed 1/2 tests, 50.00% okay
t/chk_batch.........FAILED tests 1, 3, 7, 15, 17, 21, 27, 29, 31, 35, 41,
43, 49
Failed 13/56 tests, 76.79% okay
t/dom_astress.......ok
t/dom_attr..........Can't locate object method "equals" via package
"XML::Parser::ContentModel" at CmpDOM.pm line 179.
dubious
Test returned status 255 (wstat 65280, 0xff00)
Undefined subroutine &Test::Harness::WCOREDUMP called at
/usr/lib/perl5/5.00503/Test/Harness.pm line 288.
make: *** [test_dynamic] Error 255
/usr/bin/make test -- NOT OK
------------------------------
Date: Wed, 10 May 2000 18:22:21 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Array of Structs.
Message-Id: <x7d7mutgdf.fsf@home.sysarch.com>
>>>>> "TW" == The WebDragon <nospam@devnull.com> writes:
TW> damn.. there's not a newer build of MacPerl than 520r4 (perl 5, Mac
TW> revision 2.0 patchlevel 4)
TW> Tried looking up some of the FAQ's on the web, but none seem to have any
TW> info regarding pending future releases.
i know they are working on a 5.6 port to macperl. they have a mailing
list and stuff. go to perl.org and look for their mail page.
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: Wed, 10 May 2000 15:15:22 -0400
From: Brad Baxter <bmb@ginger.libs.uga.edu>
Subject: Re: BEGIN and use
Message-Id: <Pine.A41.4.10.10005101456110.12498-100000@ginger.libs.uga.edu>
On Wed, 10 May 2000, Ala Qumsieh wrote:
> I hope that any difference between
>
> {
> STATEMENT;
> }
>
> and
>
> {
> STATEMENT
> }
>
> is compiled away before the script starts running though!
>
> --Ala
It would have to be, or implicit return values wouldn't be as expected.
1 #!/usr/local/bin/perl -w
2 use strict;
3
4 sub tree { 'tree' }
5 sub forest { 'forest'; }
6 sub jungle { 'jungle'; ; }
7
8 print for tree, forest, jungle
--
Brad
------------------------------
Date: Wed, 10 May 2000 21:18:08 GMT
From: colton@socrates.berkeley.edu (John Colton)
Subject: blat and mail server
Message-Id: <3919d026.517323664@agate.berkeley.edu>
I'm trying to use blat from within a perl script to send email. It's
not working. So, I decided to see if I could get blat to work from
command line (probably what I should have done first). More problems.
Here's my sample commandline:
blat file.txt -t person@wherever.com
Here's the ouput:
Sending file.txt to person@wherever.com
Login name is (sender's address from blat install)
Error: Mail server refused connection.Error: Not a socket.
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?
Thanks for any help,
John
------------------------------
Date: Wed, 10 May 2000 21:22:45 GMT
From: fg19537@my-deja.com
Subject: C-shell vs perl
Message-Id: <8fcjui$114$1@nnrp1.deja.com>
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.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 10 May 2000 11:34:39 -0700
From: Makarand Kulkarni <makarand_kulkarni@My-Deja.com>
Subject: Re: Can a informix database manipulated by perl programming
Message-Id: <3919ABBF.99D71A6E@My-Deja.com>
> Does perl have the neccesary subroutines to manipulate informix
> database Version 6.0 (Unix version) and provide functions such as add
> record modify record delete record and different operation on database
> which will be ported on web
>
check
http://www.symbolstone.org/technology/perl/DBI/
The DBI home page.
--
------------------------------
Date: Wed, 10 May 2000 20:58:17 +0100
From: "Callum" <callum@online-home.freeserve.co.uk>
Subject: CGI and Upload/Download
Message-Id: <8fcf7t$666$1@news6.svr.pol.co.uk>
I have a simple problem but do not know how to fix it. I can easily upload
a file from the client to the server using standard multi-part forms, but
how do I get a file from the server to the client ?
I have been looking for a solution to this for ages, it must be simple but I
just can't find a Perl example anywhere.
If any of you enlightend Perl users out there know the answer I would really
like to know !
I would appreciate any response e-mailed to : cmacalli@fsmail.net
Many thanks for all your help.
Kind Regards
Callum
------------------------------
Date: Wed, 10 May 2000 19:22:07 GMT
From: "Chris Williams" <kristor@NOcuchulainSPAM.com>
Subject: Commifying
Message-Id: <zFiS4.2188$gl2.87839@typhoon1.ba-dsg.net>
I'm trying to put commas in the output of larger numbers and I came across
the following subroutine in the Cookbook that is fine except it places a
leading comma even if there is no number in front of it. ie;
$,123,456.78... looks dumb... right? Any thoughts would help.
Thanks
sub commify {
my $text = reverse $_[0];
$text =~ s/(\d\d\d)(?!\d*\.)/$1,/g;
return scalar reverse $text;
}
------------------------------
Date: Wed, 10 May 2000 15:44:37 -0500
From: Tom Briles <sariq@texas.net>
Subject: Re: Commifying
Message-Id: <3919CA35.EC02E3F8@texas.net>
Chris Williams wrote:
>
> I'm trying to put commas in the output of larger numbers
Perhaps this question has been asked frequently?
perldoc -q comma
- Tom
------------------------------
Date: Wed, 10 May 2000 21:42:43 GMT
From: andrew-johnson@home.com (Andrew Johnson)
Subject: Re: Commifying
Message-Id: <nJkS4.11760$95.148897@news1.rdc1.mb.home.com>
In article <zFiS4.2188$gl2.87839@typhoon1.ba-dsg.net>,
Chris Williams <kristor@NOcuchulainSPAM.com> wrote:
> I'm trying to put commas in the output of larger numbers and I came across
> the following subroutine in the Cookbook that is fine except it places a
> leading comma even if there is no number in front of it. ie;
> $,123,456.78... looks dumb... right? Any thoughts would help.
>
> Thanks
>
> sub commify {
> my $text = reverse $_[0];
> $text =~ s/(\d\d\d)(?!\d*\.)/$1,/g;
> return scalar reverse $text;
> }
My copy of the cookbook shows the commify routine with the
same regex as is in the FAQ:
s<(\d\d\d)(?=\d)(?!\d*\.)><$1,>g;
^^^^^^
you seem to be missing part of the regex in your version.
andrew
--
Andrew L. Johnson http://members.home.net/andrew-johnson/epwp.html
In theory, there's no difference between
theory and practice, but in practice there is!
------------------------------
Date: Wed, 10 May 2000 22:49:18 +0100
From: Dave Cross <dave@dave.org.uk>
Subject: Re: Commifying
Message-Id: <39mjhs8kvjfr2472gbhgn8ksdep7n9hjug@4ax.com>
On Wed, 10 May 2000 19:22:07 GMT, "Chris Williams"
<kristor@NOcuchulainSPAM.com> wrote:
>I'm trying to put commas in the output of larger numbers and I came across
>the following subroutine in the Cookbook that is fine except it places a
>leading comma even if there is no number in front of it. ie;
>$,123,456.78... looks dumb... right? Any thoughts would help.
>
>Thanks
>
>sub commify {
> my $text = reverse $_[0];
> $text =~ s/(\d\d\d)(?!\d*\.)/$1,/g;
> return scalar reverse $text;
>}
You might like to check what you've got there against what is actually
printed on page 64 of the Cookbook.
My version is subtly different (i.e. correct :-)
hth,
Dave...
--
<http://www.dave.org.uk> SMS: sms@dave.org.uk
yapc::Europe - London, 22 - 24 Sep <http://www.yapc.org/Europe/>
"There ain't half been some clever bastards" - Ian Dury [RIP]
------------------------------
Date: 10 May 2000 18:30:56 GMT
From: The WebDragon <nospam@devnull.com>
Subject: Re: comparing a folder full of files to a comma,separated list
Message-Id: <8fc9t0$mjv$0@216.155.32.13>
(referring to previous post on this topic)
after reading Uri's excellent tutorial on hash slices..
I'm still somewhat confused
basically I THINK I would like to read in that text file and wind up
with a hash of the form
%array = (
'as-abraxasassault' => [ 'AS-AbraxasAssault', '1288',
'as-abraxasassault', '8' ],
'as-airportterror' => [ 'AS-AirportTerror', '928',
'as-airportterror', '4.5' ],
'as-asthenosphere' => [ 'AS-Asthenosphere', '2198',
'as-asthenosphere', '9' ],
'as-bankjob' => [ 'AS-Bankjob', '2272', 'as-bankjob', '7.5' ],
'as-bluff' => ['AS-Bluff', '3788', '-1', '-1'],
# etc etc
) ;
but I'm not quite sure how to parse it in as I read it.
any assistance is appreciated..
the keys will be the actual name of the zip file with .zip stripped off.
$var1 is the Title
$var2 is the Filesize
$var3 is the name of the html file containing the review, with .html
stripped off
$var4 is the rating of the map contained in the review.
-1 denotes that there is neither a review nor a rating, and never in any
case should one exist without the other.
I'd like to be able to generate this list as html output
each section is preceded by "-- $section_name\n" so it is easy to find
the beginning of a particular section, and also to test for the end of a
section (either -- or \n by itself (which terminates the entire list)).
(for the below: bear in mind that I already know how to do the html, and
how to use CGI.pm to create the form elements! I DO NOT need help with
that! :D what I need is help with the regex's since I REALLY don't
understand them well enough yet, and with the parsing routines via
getting the data into the hash slices and back out again appropriately)
I'd like to be able to show ALL maps, all DM maps, all CTF maps, all DOM
maps, all AS maps, and all OTHER maps, selectable from a popup menu.
(default list will be the DM maps)
I'd like to be able to add radio buttons to show
o all the maps in that subsection
o only the maps that have been reviewed
o only the maps that have NOT been reviewed.
EDITING this list will be a separate script to be dealt with later. :-)
--
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 18:48:53 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: comparing a folder full of files to a comma,separated list
Message-Id: <x7aehytf58.fsf@home.sysarch.com>
>>>>> "TW" == The WebDragon <nospam@devnull.com> writes:
TW> after reading Uri's excellent tutorial on hash slices..
thanx.
TW> basically I THINK I would like to read in that text file and wind up
TW> with a hash of the form
TW> %array = (
TW> 'as-abraxasassault' => [ 'AS-AbraxasAssault', '1288',
TW> 'as-abraxasassault', '8' ],
TW> 'as-airportterror' => [ 'AS-AirportTerror', '928',
TW> 'as-airportterror', '4.5' ],
TW> 'as-asthenosphere' => [ 'AS-Asthenosphere', '2198',
TW> 'as-asthenosphere', '9' ],
TW> 'as-bankjob' => [ 'AS-Bankjob', '2272', 'as-bankjob', '7.5' ],
TW> 'as-bluff' => ['AS-Bluff', '3788', '-1', '-1'],
TW> # etc etc
TW> ) ;
that looks pretty normal. read perldsc and perllol and there is plenty
of stuff on perl data structures in the perl cookbook and some other
books. you are moving from being a newbie to intermediate when you get
into this area. it would be better for you to do some more studying (you
seem to be a quick learner) before you just get some code in return as
it will probably just confuse you. but once you learn the secret
handshake to decipher perl structures, you will understand it in a
glance.
when you have finished your reading, it would be a good problem for you
to create and print out that structure you designed. then figuring out
how to populate it and then converting it to html will be easier.
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: 10 May 2000 21:33:08 GMT
From: The WebDragon <nospam@devnull.com>
Subject: Re: comparing a folder full of files to a comma,separated list
Message-Id: <8fckik$h4r$0@216.155.32.13>
In article <x7aehytf58.fsf@home.sysarch.com>, Uri Guttman
<uri@sysarch.com> wrote:
| >>>>> "TW" == The WebDragon <nospam@devnull.com> writes:
|
| TW> after reading Uri's excellent tutorial on hash slices..
|
| thanx.
No, no, thank YOU, sir. :D
| TW> basically I THINK I would like to read in that text file and wind
| up
| TW> with a hash of the form
|
| TW> %array = (
| TW> 'as-abraxasassault' => [ 'AS-AbraxasAssault', '1288',
| TW> 'as-abraxasassault', '8' ],
| TW> 'as-airportterror' => [ 'AS-AirportTerror', '928',
| TW> 'as-airportterror', '4.5' ],
| TW> 'as-asthenosphere' => [ 'AS-Asthenosphere', '2198',
| TW> 'as-asthenosphere', '9' ],
| TW> 'as-bankjob' => [ 'AS-Bankjob', '2272', 'as-bankjob', '7.5' ],
|
| TW> 'as-bluff' => ['AS-Bluff', '3788', '-1', '-1'],
| TW> # etc etc
| TW> ) ;
|
|
| that looks pretty normal. read perldsc and perllol and there is plenty
pshew.. and also perlref (gah my head is exploding!)
| of stuff on perl data structures in the perl cookbook and some other
| books. you are moving from being a newbie to intermediate when you get
heh.. 'intermediate' he says.. see below. :D
| into this area. it would be better for you to do some more studying (you
| seem to be a quick learner) before you just get some code in return as
thanks. It helps that I have a CLEAR idea of my objectives. :)
| it will probably just confuse you. but once you learn the secret
| handshake to decipher perl structures, you will understand it in a
| glance.
|
| when you have finished your reading, it would be a good problem for you
| to create and print out that structure you designed. then figuring out
| how to populate it and then converting it to html will be easier.
so given an external file structure of
-- Assault
"as-asthenosphere","AS-Asthenosphere",2198,"as-asthenosphere",9
"as-bankjob","AS-Bankjob",2272,"as-bankjob",7.5
"as-bluff","AS-Bluff",3788,"-1",-1
-- CaptureTheFlag
etc etc
could I do
%fileList = ();
while (<>) {
next if /^--/ ; #I think I need some kind of modifier there
#It's supposed to skip lines that start with '--'
my($filename, $Title, $filesize, $review, $rating) = split ',';
push %fileList{$filename}, [$Title, $filesize, $review, $rating];
};
but now, on second thought after thinking about it..
since there are 5 $gameTypes (Assault, CaptureTheFlag, DeathMatch,
Domination, Other) (which one determines by reading the value after
"-- $gameType\n" which is found on a single line in the input file,
preceeding each section.)
It WOULD (possibly) be 'easier' to create a complex hash of the type
%masterMapsList = (
$gameType => {
$filename => [ $Title, $filesize, $review, $rating ],
#etc etc etc ad nauseum
},
);
(interesting that you can do that)
but I still REALLY don't understand the HOW of it.. there's TOO MUCH
information in those docs. :D ohhhhh god my HEAD hurts.. I can see
somewhat how to do it, but it's still messing with my BRAIN :)
IF I do decide to create a %masterMapsList ... HOW FAST is it to create
and access on the fly ? i.e. if I encode all this mess into a cgi script
that is supposed to grab that maps_list.txt file, and display the
DeathMatch maps by default, and alow the user to select a popup to
display the rest.. on the fly .. how fast is it going to be? (relative
to the size of the list, of course, but besides that)
gah! I just tried writing this out again, and my brain just won't wrap
around it. :/
I see all these examples, but none of them work the way my idea does
(naturally) or I'd just swipe the code outta the manpages. :]
I could write it by HAND now..
%masterMapsList = (
'Assault' => {
'as-abraxasassault' => [ 'AS-AbraxasAssault', '1288',
'as-abraxasassault', '8' ],
'as-airportterror' => [ 'AS-AirportTerror', '928',
'as-airportterror', '4.5' ],
'as-asthenosphere' => [ 'AS-Asthenosphere', '2198',
'as-asthenosphere', '9' ],
},
'CaptureTheFlag' => {
'ctf-2fort' => [ 'CTF-2Fort', '221', '-1', '-1' ]
},
);
etc etc..
but some things are stumbling me when I try and grab that input from the
file :
o how to create the regexp that grabs the $gametype on the fly from
the -- line (this keeps tripping me up because I don't understand
regexps at all even after re-re-re-reading perlre. everything I try,
fails. I'm gonna get that book, but I need the money for that, which is
one reason I'm studying this and one reason I'm posting so many
questions HERE.. cuz I can't afford all the books yet! I have
"Programming Perl" and "MacPerl Power and Ease" so far.. (just so you
know I'm not completely slacking here)
o how to loop inside the $gametype for the hash while still
streaming thru the file read so no duplicates get created.
o how to correctly write the line that assignes the correct
variables to the hash of lists of lists during the loop
o how to correctly split the line into the appropriate vars (I think
I have it up there, but a confirmation would be nice)
if you can help out with a short example, I CAN wrap my brain around it
because it will directly apply to the 'thing that I'm trying to do' and
will ENORMOUSLY help me in associating that with the correct syntax for
doing so in the future (such as outputting and searching)
as you say, I'm a quick learner, but still a learner. :)
--
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: 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 3007
**************************************