[12442] in Perl-Users-Digest
Perl-Users Digest, Issue: 6042 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jun 18 11:07:29 1999
Date: Fri, 18 Jun 99 08:00:31 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Fri, 18 Jun 1999 Volume: 8 Number: 6042
Today's topics:
Re: A buggy intersection-method <thomas@bibsyst.no>
Re: a thread on threads (the skinny on the schedule) <tchrist@mox.perl.com>
Re: a thread on threads <tchrist@mox.perl.com>
accessing nested variable names vectorcalculus@my-deja.com
Re: Afraid to ask about Y2K! (Chris Nandor)
Re: Afraid to ask about Y2K! <camerond@mail.uca.edu>
Re: changing hash keys thru subroutine <rick.delaney@home.com>
Re: changing text in a file? <rootbeer@redcat.com>
Error reading news <thomas@bibsyst.no>
Re: Error reading news (Malcolm Ray)
Extract mail-headers with Net::POP3 <thomas@bibsyst.no>
filenames into an array by pattern matching? <dscapin@harris.com>
Re: having dots on screen while waiting <rootbeer@redcat.com>
Re: Help- time <rootbeer@redcat.com>
Re: HOWTO compare two arrays, an get the difference <tchrist@mox.perl.com>
Re: image counter with perl <crt@highvision.com>
Re: LD_LIBRARY_PATH setting within the perl program <rootbeer@redcat.com>
localtime function using Activestates perl on NT4 <garth.cunningham@nz.eds.com>
looking for script to monitor acct abuse iha@cgocable.net
Re: Losing referrer information when passing through a <martin@adoma.se>
Re: matinal musings and the madrugada (Larry Rosler)
mSQL and DBI Questions <sales@daytonsoftware.com>
Re: Multidimensional Associative (hash) array jtubaugh@cftnet.com
Re: Neet Perl Obfucation Program (Philip 'Yes, that's my address' Newton)
Re: Neet Perl Obfucation Program (Jerome O'Neil)
Re: Online database <crt@highvision.com>
Re: parsing a compressed file <tchrist@mox.perl.com>
Re: parsing a compressed file <tchrist@mox.perl.com>
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 18 Jun 1999 15:46:01 +0200
From: Thomas Weholt <thomas@bibsyst.no>
To: Uri Guttman <uri@sysarch.com>
Subject: Re: A buggy intersection-method
Message-Id: <376A4D99.4AC93AD0@bibsyst.no>
>
> maybe the getEntries function is buggy? we can't tell since you didn't
> post the code for it.
>
> uri
>
> --
> Uri Guttman ----------------- SYStems ARCHitecture and Software Engineering
> uri@sysarch.com --------------------------- Perl, Internet, UNIX Consulting
> Have Perl, Will Travel ----------------------------- http://www.sysarch.com
> The Best Search Engine on the Net ------------- http://www.northernlight.com
Here`s the getEntries-method :
sub getEntries(){
my @array = split(/$delim/, lc $index_hash{$_[0]});
return @array;
}
I`m pretty new to perl so the idiomatic way of typing things and my code tend to
be verbose and uneffective. Thanks for the tip by the way!
But I don`t think the getEntries is buggy ( allthough, I`m a newbie, and you,
judging by the way you commented my coding-style, must be an experienced
perl-hacker).
The thing is that I want the user to give as many keywords to lookup as he/she
pleases. The make the search more exclusive all keywords must be present in a
string to qualify as a hit.
Uah! - anyhu, thanks for your help. I`ll ehem ... cut down on the ugly-factor
in my scripts! ;->
Thomas W
------------------------------
Date: 18 Jun 1999 06:48:56 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: a thread on threads (the skinny on the schedule)
Message-Id: <376a4038@cs.colorado.edu>
[courtesy cc of this posting mailed to cited author]
In comp.lang.perl.misc, abigail@delanet.com writes:
:I think you wanted to write:
: Also, the LW part of LWP is definitely overvalued these days. Linux
: "processes" are still faster than NT "threads".
Yes, thank you. I did.
--tom
--
"Patriotism is the virtue of the vicious."
- Oscar Wilde
------------------------------
Date: 18 Jun 1999 06:47:03 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: a thread on threads
Message-Id: <376a3fc7@cs.colorado.edu>
[courtesy cc of this posting mailed to cited author]
In comp.lang.perl.misc,
bart.lateur@skynet.be (Bart Lateur) writes:
:I definitely agree. Yesterday, I went hunting for some old post with
:benchmarks. I gave up. Having to loadi over 50k for each and every
:article is total and utter nonsense. Slow as mail.
You are a programmer, so program. :-) Write some fancy LWP program
that filters for just what you want. Probably give in a CGI front-end.
Return it to what it used to look like, before the advercrap.
--tom
--
Comments on data are usually much more helpful than on algorithms. --Rob Pike
------------------------------
Date: Fri, 18 Jun 1999 13:47:41 GMT
From: vectorcalculus@my-deja.com
Subject: accessing nested variable names
Message-Id: <7kdilq$hmj$1@nnrp1.deja.com>
With this setup:
$first = 'This is the text I want to get at';
$second = '$first';
Is there a way I can get to the contents of $first
by only directly accessing $second? If I knew
that $second contained the name of a valid scalar,
can I get to the contents of the named scalar?
Thanks
Greg Preston
greg@dns.kode.net
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Fri, 18 Jun 1999 12:43:31 GMT
From: pudge@pobox.com (Chris Nandor)
Subject: Re: Afraid to ask about Y2K!
Message-Id: <pudge-1806990843360001@192.168.0.77>
In article <7kbp4i$v46$1@nnrp1.deja.com>, finsol@ts.co.nz wrote:
# The Y2K problem in Perl code goes beyond just the localtime booby trap.
# The localtime issue is just the most obvious but even so few Perl coders
# on this site acknowledge it as being a problem their reasoning being
# that the manual states quite clearly how localtime should be used.
Yeah. Go figure. Rely on documentation? Never! Caveat scriptor.
You see, we happen to believe that in order to program effectively, you should:
1. Know how to program
2. Know the language you are programming in
3. Read the documentation when you are unclear of something
If you cannot do that, your code will suck. Y2K errors will be the least
of your worries. If you do these things, you will not have Y2K errors.
It is quite simple, really.
Sure, Y2K errors can happen in Perl. But they cannot happen for
programmers who know what they are doing, or programmers who don't know
but make a minimally reasonable effort to find out.
You are blaming the language, which is nonsense. That's like blaming
English because people can incite riots using it.
--
Chris Nandor mailto:pudge@pobox.com http://pudge.net/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10 1FF77F13 8180B6B6'])
------------------------------
Date: Fri, 18 Jun 1999 09:32:14 -0500
From: Cameron Dorey <camerond@mail.uca.edu>
Subject: Re: Afraid to ask about Y2K!
Message-Id: <376A586E.B050BBAD@mail.uca.edu>
"J. Moreno" wrote:
>
> [snip]
> Find a Y2K problem in code by Tom P, Jonathan, Larry, Abigail, Tad, David, Uri
> or Tom C and you'll convince *me* that it's something I need to give some extra
> consideration.
One thing's for certain, you won't find any Y2K problems in Abigail's
code. She's perpetually in 1993 (or, rather, MCMXCIII).
Cameron
--
Cameron Dorey
Associate Professor of Chemistry
University of Central Arkansas
Phone: 501-450-5938
camerond@mail.uca.edu
------------------------------
Date: Fri, 18 Jun 1999 12:52:47 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: changing hash keys thru subroutine
Message-Id: <376A40DD.8C0D8BF@home.com>
[posted & mailed]
irfna@my-deja.com wrote:
>
> foreach $key(keys %myHash){
> $key="bye bye";
> print "$key\n";
> }
$key is not aliased to the actual key in %myHash. The function keys
returns a separate list.
If you want to change the key you will need to delete the original and
add the new one. But it seems pretty strange to use foreach to replace
all the entries of %myHash with one entry with the key "bye bye". Maybe
you're trying to do something else?
Some basics:
perldoc perldata
perldoc perlsyn
--
Rick Delaney
rick.delaney@home.com
------------------------------
Date: Fri, 18 Jun 1999 07:18:13 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: changing text in a file?
Message-Id: <Pine.GSO.4.02A.9906180717530.5420-100000@user2.teleport.com>
On Fri, 18 Jun 1999, outlaw_torn wrote:
> open (MYFILE, ">$myfile");
Even when your script is "just an example" (and perhaps especially in that
case!) you should _always_ check the return value after opening a file.
Thanks!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Fri, 18 Jun 1999 15:05:13 +0200
From: Thomas Weholt <thomas@bibsyst.no>
Subject: Error reading news
Message-Id: <376A4409.70931E19@bibsyst.no>
Hi,
Below is a code snippet directly from the Perl Cookbook. It doesn` t
generate any errors, but the script just won`t end and nothing happens.
It seems after the connection is made the process halts. I want to store
all the messages to files. Looked at nntpget in the New-Scan module, but
that used a spool, and I want to create web-pages with a list of each
article, with each articles subject-field as text in an index.
If this code works for anybody else, please let me know!
Thomas Weholt
#!/usr/bin/perl
use Net::NNTP;
$group = "comp.lang.perl.misc";
$server = "news.eunet.no";
$server = Net::NNTP->new($server) or die "Cannot connect to server:
$!\n";
($articles, $first, $last, $name) = $server->group($group) or die "Error
opening group $group :$!\n";
$headers = $server->head($first) or die "Error getting header : $!\n";
$bodytext = $server->body($first) or die "Error getting body $first :
$!\n";
$article = $server->article($first+100) or die "Error getting article
$first : $!\n";
$server->postok() or warn "Cannot post!!\n";
$server->post([@lines]) or die "Cant post : $!\n";
$grouplist = $server->list() or die "Error getting group-list\n";
------------------------------
Date: 18 Jun 1999 13:28:26 GMT
From: M.Ray@ulcc.ac.uk (Malcolm Ray)
Subject: Re: Error reading news
Message-Id: <slrn7mkibq.cpc.M.Ray@carlova.ulcc.ac.uk>
On Fri, 18 Jun 1999 15:05:13 +0200, Thomas Weholt <thomas@bibsyst.no> wrote:
>Hi,
>
>Below is a code snippet directly from the Perl Cookbook. It doesn` t
>generate any errors, but the script just won`t end and nothing happens.
>It seems after the connection is made the process halts. I want to store
>all the messages to files. Looked at nntpget in the New-Scan module, but
>that used a spool, and I want to create web-pages with a list of each
>article, with each articles subject-field as text in an index.
>
>If this code works for anybody else, please let me know!
>
>Thomas Weholt
>
>#!/usr/bin/perl
>
>use Net::NNTP;
>
>$group = "comp.lang.perl.misc";
>$server = "news.eunet.no";
>
>$server = Net::NNTP->new($server) or die "Cannot connect to server:
>$!\n";
Change that to:
$server = Net::NNTP->new($server, Debug => 1)
or die "Cannot connect to server: $!\n";
It won't fix your problem, but it'll let you see the dialogue between
your program and the server, which may reveal what the problem is.
--
Malcolm Ray University of London Computer Centre
------------------------------
Date: Fri, 18 Jun 1999 15:30:28 +0200
From: Thomas Weholt <thomas@bibsyst.no>
Subject: Extract mail-headers with Net::POP3
Message-Id: <376A49F4.33BB36A7@bibsyst.no>
Hi,
I was wondering how I could extract the subject and from field from an
email using the Net::POP3 module.
Thomas W
------------------------------
Date: Fri, 18 Jun 1999 10:00:50 -0400
From: Deamon George Scapin <dscapin@harris.com>
Subject: filenames into an array by pattern matching?
Message-Id: <376A5111.18C9428E@harris.com>
Another little question. I currently use the following statement in order to
put jpg file names into an array. How do I add the capablility to get gif
filenames into the same array?
@thumbnail = grep /\-a.jpg$/, readdir(DIR);
------------------------------
Date: Fri, 18 Jun 1999 07:21:42 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: having dots on screen while waiting
Message-Id: <Pine.GSO.4.02A.9906180719270.5420-100000@user2.teleport.com>
On Thu, 17 Jun 1999, Steve . wrote:
> I have a while loop. At certain points in the look there can be
> delays in excess of 5 minutes. This is normal and fine. I would
> however like to make sure things stay active so would like a dot to be
> displayed in the screen every 15 seconds when nothing is being
> displayed.
>
> while ( <PGP_READ> )
> {
> print;
> print "\n";
> }
>
> The above is basically pulling info from an open3 shell script. Is
> there a way to add what I am looking for into the above loop?
You could use an alarm, but that's not as reliable as using the four-arg
select and sysread.
You should probably set up a naked block in which you call select with a
one-second timeout. When it returns, you can process the incoming data (if
any), issue a dot (if it's time), and restart the loop (with redo) unless
sysread returned zero. (But see your system's read(2) manpage for more
information about what sysread is doing.)
Good luck with it!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Fri, 18 Jun 1999 07:28:36 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Help- time
Message-Id: <Pine.GSO.4.02A.9906180725580.5420-100000@user2.teleport.com>
On Fri, 18 Jun 1999 olmert@netvision.net.il wrote:
> I want to create a script that reads a file, prints it's content and
> then sleeps for 4 seconds, checks if there is any new content in the
> file, and if so- PRINTS ONLY THE NEW CONTENT.
Sure; the FAQ has a method which is better than what you had.
> I am not a perl expert, so with the help of some ppl, I made this
> follwoing code. It doesn't work, so the server ptoduces no output. Any
> ideas?
When you're having trouble with a CGI program in Perl, you should first
look at the please-don't-be-offended-by-the-name Idiot's Guide to solving
such problems. It's available on CPAN.
http://www.perl.com/CPAN/
http://www.perl.org/CPAN/
http://www.perl.org/CPAN/doc/FAQs/cgi/idiots-guide.html
http://www.perl.org/CPAN/doc/manual/html/pod/
> open (IN, $myfile);
Even when your script is "just an example" (and perhaps especially in that
case!) you should _always_ check the return value after opening a file.
> #Wait another 20 seconds
> sleep 4;
It's probably better to use comments which don't lie.
Cheers!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 18 Jun 1999 08:16:18 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: HOWTO compare two arrays, an get the difference
Message-Id: <376a54b2@cs.colorado.edu>
[courtesy cc of this posting mailed to cited author]
In comp.lang.perl.misc,
"Torfinn Keringen" <tor@kmd.dk> writes:
:I have @array1 @array2, both of them contains a few lines of text,
:what I want is an @array3 containing the lines from @array1
: that is missing in @array2
I guess you didn't like the standard answer in the standard perlfaq4
manpage distributed with every single version of perl (and no it doesn't
matter that you're a Prisoner of Bill so you all stop your collective
whimpering) and prefer the traditional answer instead.
% man 1 comm
COMM(1) OpenBSD Reference Manual COMM(1)
NAME
comm - select or reject lines common to two files
SYNOPSIS
comm [-123] file1 file2
DESCRIPTION
The comm utility reads file1 and file2, which should be sorted
lexically, and produces three text columns as output: lines only
in file1; lines only in file2; and lines in both files.
The filename ``-'' means the standard input.
The following options are available:
-1 Suppress printing of column 1.
-2 Suppress printing of column 2.
-3 Suppress printing of column 3.
Each column will have a number of tab characters prepended to
it equal to the number of lower numbered columns that are being
printed. For example, if column number two is being suppressed,
lines printed in column number one will not have any tabs preceding
them, and lines printed in column number three will have one.
comm assumes that the files are lexically sorted; all characters
participate in line comparisons.
DIAGNOSTICS
The comm utility exits 0 on success or >0 if an error occurred.
SEE ALSO
cmp(1), diff(1), sort(1), uniq(1)
STANDARDS
The comm utility conforms to IEEE Std1003.2-1992 (``POSIX.2'').
OpenBSD 2.3 June 6, 1993 1
--
tmps_base = tmps_max; /* protect our mortal string */
--Larry Wall in stab.c from the perl source code
------------------------------
Date: Fri, 18 Jun 1999 10:02:03 -0400
From: "Casey Tweten" <crt@highvision.com>
Subject: Re: image counter with perl
Message-Id: <7kdk2b$5d65@news.icubed.com>
Ute Mvlter <moelter@legion.de> wrote in message
news:7kbcr0$4rv$1@news-hrz.uni-duisburg.de...
: I'm trying around for a few days with an image counter.
: I can't get it work. I've searched the internet and tried a few scripts
: but it doesen't work, too.
: My html file has a line like that
:
: <img src="http://www.ser.ver/cgi-bin/count.pl">
:
: and the perl script something like that:
:
: print "Location: "http://www.ser.ver/images/1.gif\n\n";
:
: or
:
: print "Content-Type: text/html\n\n";
: print "<IMG SRC=\"http://www.ser.ver/images/1.gif\">";
:
: or
:
: any other possible combination i know
:
: What's wrong ?
: Can anybody help me ?
Use the GD module, find it at CPAN, and use it. Well documented, and has
examples of what you want to do.
The header will not be text/html it is image/* (what ever format you have)
--
+-----------------+
| Casey R. Tweten |
+--------------+--------+--------+--------------+
| * KiskiNet ISP | HighVision Associates |
| * HighVision Studio | Web Developer |
| * ISP-ProServices | www.highvision.com |
| * CityBuilder.com | crt@highvision.com |
+-----------------------+-----------------------+
| <joke>This is 100% virus free code</joke> |
+-----------------------------------------------+
------------------------------
Date: Fri, 18 Jun 1999 07:38:23 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: LD_LIBRARY_PATH setting within the perl program
Message-Id: <Pine.GSO.4.02A.9906180730480.5420-100000@user2.teleport.com>
On Thu, 17 Jun 1999, murali wrote:
> I tried $ENV{LD_LIBRARY_PATH}='/opt/sybase/lib';
> both with and without the BEGIN block... no use.
> I didnt want to use a shell script wrapper to do this as it will slow
> the process.
How often do you run this program? If you run it twenty or thirty times
per day, and if the wrapper (whether written in Perl, Shell, or C) takes a
whopping one full second(!) to run, that's still not a lot of time in the
big scheme of things.
OTOH, if this program is called every minute, you should consider setting
it up as a "data server" which stays around in memory waiting for simple
lightweight clients to connect to it.
In any case, it looks as if you're going to have either to put the library
files in the directories already listed in your LD_LIBRARY_PATH, or to fix
the value of LD_LIBRARY_PATH before your program is run. Cheers!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Thu, 17 Jun 1999 17:18:07 +1200
From: "Garth Cunningham" <garth.cunningham@nz.eds.com>
Subject: localtime function using Activestates perl on NT4
Message-Id: <7ka0si$99q$1@hermes.nz.eds.com>
Hi,
I have the following piece of code.
my @lt = localtime();
printf ("%d-%d-%d %d:%d:%d",$lt[3],$lt[4]+1,$lt[5],$lt[2],$lt[1],$lt[0]);
On my unix system with perl 5.004_04 and the TZ environment variable set
this returns the correct local date and time.
Running this code on an NT4 workstation with Activestates perl ( build 509 )
it returns a time that is an hour fast. The system is set at the correct
time ( ie type time at the command prompt ).
Do I need to set or pick up some timezone info ?
Any help gratefully received.
Thanks
Garth
Garth Cunningham BSc
EDS (New Zealand) Ltd.
2 Pacific Rise, Mt Wellington
P.O. Box 12-634, Penrose
Auckland, New Zealand
DDI +64-9-574 1864
Fax +64-9-573 5573
Mob 025-515 413
Email garth.cunningham@nz.eds.com
------------------------------
Date: Fri, 18 Jun 1999 10:54:52 -0400
From: iha@cgocable.net
Subject: looking for script to monitor acct abuse
Message-Id: <376A5DBB.A34D9BBC@cgocable.net>
I am looking for a script or an example of code that can track acct
abuse (multiple ip's using the same username) by reading an apache web
log file, and sending an alert email to the admin We are running a
5,000+ mysql jobs database
thanks for any help
------------------------------
Date: Fri, 18 Jun 1999 14:41:09 +0100
From: "Martin Quensel" <martin@adoma.se>
Subject: Re: Losing referrer information when passing through a perl script...?
Message-Id: <7kdfup$dlp$1@zingo.tninet.se>
Euro Jake skrev i meddelandet <7kd7g9$mbf$1@news3.Belgium.EU.net>...
>Hello all,
>
>Through javascript, Im trying to use document.referrer to track where a
>visitor came from on my site. Everything works fine until I have a password
>access handled by a perl script. Once passed the perl generated html page,
>the document.referrer info seems blank...
>
>Most certainly im overlooking a detail...
>Anyone give me a hand?
>Thanks in advance
give you a hand on what?
All i can say to you is:
It seems like it doesent work the way you want it to work.
Maybee you are overlooking a detail, maybee not.
Now, that dident help you much im afraid.
maybee this will help
http://www.plover.com/~mjd/perl/Questions.html
Best regards
Martin Quensel
------------------------------
Date: Fri, 18 Jun 1999 07:05:32 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: matinal musings and the madrugada
Message-Id: <MPG.11d3f1f29cd69484989bf8@nntp.hpl.hp.com>
In article <376d2207.165249526@news.insnet.net> on Fri, 18 Jun 1999
10:41:43 GMT, David Cantrell <NukeEmUp@ThePentagon.com> says...
> On Thu, 17 Jun 1999 14:46:24 -0400, Greg Bartels <gbartels@xli.com>
> said:
>
> >course, the Marine Corps always dated their documents YY/MM/DD
> >(which was a pain in the butt to unlearn in civilian life)
> >so I dont know that they're the leaders in time standards.
>
> Makes it nice n' easy to sort by date in a language which doesn't
> support a Date type (see - back on topic!) which is a Good Thing.
I sense a certain limit to the sortability of that, which the
originators of its use didn't concern themselves with, somehow. Some
might consider this a Bad Thing.
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Fri, 18 Jun 1999 10:24:00 -0400
From: "Brian Schell" <sales@daytonsoftware.com>
Subject: mSQL and DBI Questions
Message-Id: <#EDbbWZu#GA.51@cpmsnbbsa05>
What are the steps in getting Perl to connect to a mSQL server? I picked up
the latest DBI Module and make/installed it without a hitch. I also
downloaded Msql-Mysql-modules-1.2200 (Or something close to that) but MAKE
blew up and did a core dump...
When I try to run a short script to link to the database it gives several
errors including "Database Driver not found"
Is there a module I'm missing or a specific order to the install process?
I've read what little documentation comes with these modules, but they are
geared more toward what to do with the modules AFTER installation...
begin 666 Brian D Schell.vcf
M0D5'24XZ5D-!4D0-"E9%4E-)3TXZ,BXQ#0I..E-C:&5L;#M"<FEA;CM$.T1R
M+@T*1DXZ0G)I86X@1"!38VAE;&P-"D]21SI$87ET;VX@4V]F='=A<F4-"E1%
M3#M73U)+.U9/24-%.CDS-RTR.30M,#$V-@T*5$5,.U=/4DL[1D%8.CDS-RTR
M.30M,#$V-@T*0412.U=/4DLZ.SLR-S<X(%=I;&UI;F=T;VX@4&EK93M+971T
M97)I;F<[3T@[-#4T,3D[55-!#0I,04)%3#M73U)+.T5.0T]$24Y'/5%53U1%
M1"U04DE.5$%"3$4Z,C<W."!7:6QM:6YG=&]N(%!I:V4],$0],$%+971T97)I
M;F<L($]((#0U-#$Y/3!$/3!!55-!#0I8+5=!0BU'14Y$15(Z,@T*55),.@T*
M55),.FAT=' Z+R]W=W<N9&%Y=&]N<V]F='=A<F4N8V]M#0I%34%)3#M04D5&
M.TE.5$523D54.G-A;&5S0&1A>71O;G-O9G1W87)E+F-O;0T*14U!24P[24Y4
M15).150Z<F%D:6] 9&%Y<'5B+F-O;0T*4D56.C$Y.3DP-C$X5#$T,C0P,%H-
,"D5.1#I60T%21 T*
`
end
------------------------------
Date: Fri, 18 Jun 1999 11:14:31 GMT
From: jtubaugh@cftnet.com
Subject: Re: Multidimensional Associative (hash) array
Message-Id: <7kd9mi$ejb$1@nnrp1.deja.com>
In article <7k8o2s$quu$1@nnrp1.deja.com>,
jtubaugh@cftnet.com wrote:
> Does anybody know of a way to store a hash array within another hash
> array?
>
> What I want to do is define a hash array like this:
>
> %ARRAY1 = ("key1","value1", "key2","value2");
>
> Then store it in a second array:
>
> %ARRAY2 = ("key1", %ARRAY1);
>
> Each row in %ARRAY2 will have different values set for %ARRAY1.
>
> Then when I reference %ARRAY2, I can pull out the information for
> %ARRAY1.
>
> Basically what I am trying to do is create a multidimensional
> associative array.
>
Thank you to all who provided some assistance and other references.
While I have done a good amount of programming in other languages (shell
scripting being one) I am very new to perl ("new" as in, this is my
first perl script) and have not had a lot of time to aquaint myself with
its features - basically I just "jumped in."
I read a technique in a Perl book that I ended up using. Basically what
I ended up doing was storing an @array as the values of each occurence
of the %hash array. For each @array occurence I used join to build a
set of "key/value" pairs. Then when retrieving @array values, I used
split to retrieve the "key/value" pairs.
I had to do this because for each occurence of the %hash array, I had a
different value set for the @array, and couldn't figure out a way use a
reference to an original %hash array. It seems a little complicated and
"newbie" in technique, but it is working (and I actually understand what
I did!).
Here is basically what I did:
#!/usr/local/bin/perl
#
#Load each occurence of the hash array with its "attribute" values
#
$HASH_ARRAY{'A FIRST'} = "ATTR1 This is the first attribute of FIRST";
$HASH_ARRAY{'A FIRST'} = join($;,$HASH_ARRAY{'A FIRST'}, "ATTR2 This is
the second attribute of FIRST");
$HASH_ARRAY{'A FIRST'} = join($;,$HASH_ARRAY{'A FIRST'}, "ATTR3 This is
the third attribute of FIRST");
$HASH_ARRAY{'B SECOND'} = "ATTR1 This is the first attribute of SECOND";
$HASH_ARRAY{'B SECOND'} = join($;,$HASH_ARRAY{'B SECOND'}, "ATTR2 This
is the second attribute of SECOND");
$HASH_ARRAY{'B SECOND'} = join($;,$HASH_ARRAY{'B SECOND'}, "ATTR3 This
is the third attribute of SECOND");
$HASH_ARRAY{'Z ETC'} = "ATTR1 This is the first attribute of ETC";
$HASH_ARRAY{'Z ETC'} = join($;,$HASH_ARRAY{'Z ETC'}, "ATTR2 This is the
second attribute of ETC");
$HASH_ARRAY{'Z ETC'} = join($;,$HASH_ARRAY{'Z ETC'}, "ATTR3 This is the
third attribute of ETC");
$HASH_ARRAY{'Z ETC'} = join($;,$HASH_ARRAY{'Z ETC'}, "ATTR4 I may have
more or less ATTRs in multiple occurences of HASH_ARRAY");
#
#Retrieve each occurence of the hash array and split out the attribute
values.
#
foreach $HASH_KEY (sort keys %HASH_ARRAY) {
split ($;,$HASH_ARRAY{$HASH_KEY});
@ATTR_ARRAY = @_;
print "-------------------------------\n";
print "HASH_KEY = $HASH_KEY\n";
foreach $ATTR_VAL (@ATTR_ARRAY) {
#
# Split out the "key/value" pairs of the internal array
#
$ATTR_NM = substr($ATTR_VAL,0,index($ATTR_VAL," "));
$ATTR_VAL =~ s/$ATTR_NM //;
print "ATTR_NM = $ATTR_NM\n";
print "ATTR_VAL = $ATTR_VAL\n";
}
}
Any comments/critique would be welcomed.
Jeff
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Fri, 18 Jun 1999 14:17:49 GMT
From: nospam.newton@gmx.net (Philip 'Yes, that's my address' Newton)
Subject: Re: Neet Perl Obfucation Program
Message-Id: <376a0afd.10922730@news.nikoma.de>
On 17 Jun 1999 20:44:09 GMT, jeromeo@atrieva.com (Jerome O'Neil)
wrote:
>vi -x mycode.pl
Would this not also make the code very difficult for an authorised
Perl interpreter to read?
Cheers,
Philip
--
Philip Newton <nospam.newton@gmx.net>
------------------------------
Date: 18 Jun 1999 14:37:28 GMT
From: jeromeo@atrieva.com (Jerome O'Neil)
Subject: Re: Neet Perl Obfucation Program
Message-Id: <7kdlj8$pe1$1@brokaw.wa.com>
In article <376a0afd.10922730@news.nikoma.de>,
nospam.newton@gmx.net (Philip 'Yes, that's my address' Newton) writes:
> On 17 Jun 1999 20:44:09 GMT, jeromeo@atrieva.com (Jerome O'Neil)
> wrote:
>>vi -x mycode.pl
>
> Would this not also make the code very difficult for an authorised
> Perl interpreter to read?
It would "...make it very difficult for unauthrorized personnel to read."
Also, I tried to send you email, but it bounced. Your e-mail address is
newton@gmx.net
right?
--
Jerome O'Neil, Operations and Information Services
Atrieva Corporation, 600 University St., Ste. 911, Seattle, WA 98101
jeromeo@atrieva.com - Voice:206/749-2947
The Atrieva Service: Safe and Easy Online Backup http://www.atrieva.com
------------------------------
Date: Fri, 18 Jun 1999 10:12:24 -0400
From: "Casey Tweten" <crt@highvision.com>
Subject: Re: Online database
Message-Id: <7kdkln$5d67@news.icubed.com>
Neil <neil@pacifier.com> wrote in message
news:37694088.0@news.pacifier.com...
: I am looking for Online database options: actually just a flatfile
: database.
:
: The intn'l trade association I work for has a Virtual Server
: running on a UNIX box at our ISP.
:
: We want to have a simple database that would consist of companies
: and 15 possible services. Each company provides from 1 to a maximum
: of all 15 services.
(IMHO) mySQL
: We want visitors to the Web page to, using a form, query the database
: based on services. Maybe a checkbox next to each service, and the user
: can check those services he or she wants and then click submit and the
: database would return companies that provide the services selected. The
: output would just be a simple table with basic information and a hyperlink
: if more information about a specific company is desired.
(IMHO) mySQL
Of course, you could just use a common delimeter, | for instance, and then
open the file, do a regexe to see if the service code is there, and if it
is, do another regexe to get the name of the company, and link it to another
script that handles the companies info itself.
But that is a pain, and mySQL would be better, the reason I chose to say
that database is because it is a free as a simple text file, and more
secure.
: I am looking for a recommendation on perl scripts that will accomplish the
: above.
....... see below
: On another topic, I am happy to report that I have ordered the Ram and
: am looking forward to learning some Perl. My learning strategy will be
: to read, program, and lurk in this group.
write it, good strategy, learn your stuff, and then write the code, then
lurk here...
: Neil
--
+-----------------+
| Casey R. Tweten |
+--------------+--------+--------+--------------+
| * KiskiNet ISP | HighVision Associates |
| * HighVision Studio | Web Developer |
| * ISP-ProServices | www.highvision.com |
| * CityBuilder.com | crt@highvision.com |
+-----------------------+-----------------------+
| <joke>This is 100% virus free code</joke> |
+-----------------------------------------------+
------------------------------
Date: 18 Jun 1999 08:05:35 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: parsing a compressed file
Message-Id: <376a522f@cs.colorado.edu>
[courtesy cc of this posting mailed to cited author]
In comp.lang.perl.misc,
"Sefi Kraemer" <skraemer@iil.intel.com> writes:
:Is there a way to parse compressed (gzip'ed) files, in the same manner the
:GNU function 'gzgrep' does it ?
@ARGV = map { /^\.(gz|Z)$/ ? "gzip -dc $_ |" : $_ } @ARGV;
while (<>) {
......
}
--tom
--
"For it, that's now" --Larry Wall
------------------------------
Date: 18 Jun 1999 08:05:54 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: parsing a compressed file
Message-Id: <376a5242@cs.colorado.edu>
[courtesy cc of this posting mailed to cited author]
In comp.lang.perl.misc,
ebohlman@netcom.com (Eric Bohlman) writes:
:Get the module Compress::Zlib and read the documentation for it.
That's rather grossly unlazy.
--tom
--
There's no such thing as a simple cache bug. --Rob Pike
------------------------------
Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>
Administrivia:
Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing.
]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body. Majordomo will then send you instructions on how to confirm your
]subscription. This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
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 V8 Issue 6042
**************************************