[12497] in Perl-Users-Digest
Perl-Users Digest, Issue: 6097 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jun 22 17:07:19 1999
Date: Tue, 22 Jun 99 14:00:23 -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 Tue, 22 Jun 1999 Volume: 8 Number: 6097
Today's topics:
Re: 2 simple (not to me tho) questions (Charles DeRykus)
Re: 2 simple (not to me tho) questions <tchrist@mox.perl.com>
Re: 2 simple (not to me tho) questions <aqumsieh@matrox.com>
Re: 2 simple (not to me tho) questions <aqumsieh@matrox.com>
Re: [q] Timing of a simple looping cycle PERL vs C (Ilya Zakharevich)
Re: [q] Timing of a simple looping cycle PERL vs C <tchrist@mox.perl.com>
Re: [q] Timing of a simple looping cycle PERL vs C (Dean Hudson)
Re: A month behind using localtime(time) ? <emschwar@rmi.net>
Re: A month behind using localtime(time) ? (Larry Rosler)
Re: Breaking up is hard to do <aqumsieh@matrox.com>
DBI/DBD mSQL: mSQL.so bobnospam@khusro.math.umn.edu
Re: foreach and while (<FILE>) (Larry Rosler)
Forking off a process <andy@mtco.com>
Re: function to read a line & return it <mhc@Eng.Sun.COM>
Re: How many questions about localtime? (Andrew Johnson)
Re: How many questions about localtime? <dgris@moiraine.dimensional.com>
Re: how to remove spaces in a line (Larry Rosler)
Re: Is it better perl than awk ? (Filip M. Gieszczykiewicz)
Re: Is it better perl than awk ? (Filip M. Gieszczykiewicz)
MIME kill code ? (root)
Re: MIME kill code ? <tchrist@mox.perl.com>
Re: Multidimensional Associative (hash) array jtubaugh@cftnet.com
Re: Multidimensional Associative (hash) array (Bart Lateur)
Re: Need to edit cgi script using Windows PC, which pro <srishti@vsnl.com>
Re: Newbie - Perl books - which to get? ufmemo@my-deja.com
Newbie PWS problems help! <Sp.Ross@btinternet.com>
perl, htaccess, authorization pweck@ixc.net
Re: Piping through Less. (Alastair)
Re: Statistics for comp.lang.perl.misc (J. Moreno)
Re: Statistics for comp.lang.perl.misc (Lee)
Summing an array <james@britlinks.co.uk>
Re: Summing an array <tchrist@mox.perl.com>
Re: Summing an array <james@britlinks.co.uk>
Re: Summing an array <uri@sysarch.com>
Re: time question <srishti@vsnl.com>
Re: unable to create or rename files in subdirectories <rg@fubar.net>
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 22 Jun 1999 18:28:28 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: 2 simple (not to me tho) questions
Message-Id: <FDqrBG.Fux@news.boeing.com>
In article <376EF026.56082447@frontiernet.net>,
Bob Walton <walton@frontiernet.net> wrote:
>Casey R Tweten wrote:
>
> ....
>my @animal=("c","a","t");
>print for @animal;
>
another wretched one for the menagerie...
print my @animal=qw/c a t/;
--
Charles DeRykus
------------------------------
Date: 22 Jun 1999 13:24:28 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: 2 simple (not to me tho) questions
Message-Id: <376fe2ec@cs.colorado.edu>
print my @animal=qw"c a t";
--tom
--
"The effect of his affected accent affected her,
and effected a change in her affections."
--Steve Chapin
------------------------------
Date: Tue, 22 Jun 1999 13:06:52 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: 2 simple (not to me tho) questions
Message-Id: <x3yu2s0cggl.fsf@tigre.matrox.com>
morpheus@despair.rpglink.com (Steve Lamb) writes:
> On 21 Jun 1999 17:19:25 -0700, Tom Christiansen <tchrist@mox.perl.com> wrote:
> >:foreach (@animal){
> >: print("$_");
> >:}
>
> >Why is that quoted?
>
> Hm, my email to your CC didn't get through. BTW, CC's aren't needed.
>
> Anyway, you would get the same answer if you had asked me, "Why is that in
> parens?" Just my style to do it that way even though neither are really
> needed.
You don't even need the $_.
print;
is sufficient.
------------------------------
Date: Tue, 22 Jun 1999 13:08:48 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: 2 simple (not to me tho) questions
Message-Id: <x3yso7kcgdb.fsf@tigre.matrox.com>
abigail@delanet.com (Abigail) writes:
>
> Bob Walton (walton@frontiernet.net) wrote on MMCXXI September MCMXCIII in
> <URL:news:376EF026.56082447@frontiernet.net>:
> ,, Casey R Tweten wrote:
> ,,
> ,, > ...I agree, in fact, why is that so long?
> ,, >
> ,, > my @animal=("c","a","t");
> ,, > print foreach @animal;
> ,,
> ,, If shorter is better...
> ,,
> ,, my @animal=("c","a","t");
> ,, print for @animal;
>
>
> If shorter is better...
>
> my @animal = ("c", "a", "t");
> print @animal;
If shorter is better...
my @animal = qw/c a t/;
print @animal;
Ala
------------------------------
Date: 22 Jun 1999 19:26:28 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: [q] Timing of a simple looping cycle PERL vs C
Message-Id: <7koo14$3kl$1@mathserv.mps.ohio-state.edu>
[A complimentary Cc of this posting was sent to Augur the Genius
<augur@icelord.net>],
who wrote in article <Pine.LNX.3.96.990622182831.31976A-100000@localhost>:
> %time perl d.pl
> 13.59user 0.02system 0:13.79elapsed 98%CPU\
> // optimized for gcc -O6 b.c -o b
> 0.05user 0.02system 0:00.06elapsed 112%CPU\
> // optimized for gcc -O2 b.c -o b1
> 0.23user 0.01system 0:00.24elapsed 98%CPU\
> Don't you think that 14 seconds for a perl variant is too far against even
> 0.25sec for .c variant?
Why wold we think so? Perl is *known* to be circa 200 times slower
than C for *comparable constructs*. What is your point?
Ilya
------------------------------
Date: 22 Jun 1999 13:56:22 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: [q] Timing of a simple looping cycle PERL vs C
Message-Id: <376fea66@cs.colorado.edu>
In comp.lang.perl.misc, ilya@math.ohio-state.edu (Ilya Zakharevich) writes:
:Why wold we think so? Perl is *known* to be circa 200 times slower
:than C for *comparable constructs*. What is your point?
And you are known to *lie* to this newsgroup about this matter.
STOP LYING, ILYA.
>From K&P99:
PLATFORM 250mhz Irix 400mhx pII MS line count
C 0.36 sec 0.30 sec 150
Java 4.9 9.2 105
C++/STL/deque 2.6 11.2 70
C++/STL/list 1.7 1.5 70
Awk 2.2 2.1 20
Perl 1.8 1.0 18
And no, this has nothing to do with sysadmin, so you can stuff
that one, too.
--tom
--
I wish there was a knob on the TV to turn up the intelligence. There's
a knob called "brightness", but it doesn't work.
--Gallagher
------------------------------
Date: 22 Jun 1999 13:22:10 -0700
From: deanh@nwnet.net (Dean Hudson)
Subject: Re: [q] Timing of a simple looping cycle PERL vs C
Message-Id: <7kor9i$gg9@cypress.nwnet.net>
In article <376fea66@cs.colorado.edu>,
Tom Christiansen <tchrist@mox.perl.com> wrote:
...
>From K&P99:
> PLATFORM 250mhz Irix 400mhx pII MS line count
> C 0.36 sec 0.30 sec 150
> Java 4.9 9.2 105
> C++/STL/deque 2.6 11.2 70
> C++/STL/list 1.7 1.5 70
> Awk 2.2 2.1 20
> Perl 1.8 1.0 18
...
For those interested also see "Timing Trials, or, the Trials of Timing:
Experiments with Scripting and User-Interface Languages" by Kernighan
and Van Wyk for more detailed and task specific benchmarks of various
languages.
--
--
dean hudson, <deanh@verio.net> Verio Systems Engineering
------------------------------
Date: 22 Jun 1999 13:11:12 -0600
From: Eric The Read <emschwar@rmi.net>
Subject: Re: A month behind using localtime(time) ?
Message-Id: <xkf1zf4m4of.fsf@valdemar.col.hp.com>
bart.lateur@skynet.be (Bart Lateur) writes:
> Eric The Read wrote:
> >Did you actually read the documentation of localtime? If you had, you'd
> >have seen this behaviour explicitly documented.
> >
> >> Does that mean that January is $mon 0 ?
> >
> >Wow, you *are* good.
>
> Nope. It says that the range for the months is 0..11, but it doesn't say
> which month is 0.
Eerily enough, so does my manpage for localtime(2). So now nobody knows
what it is! Quick, everybody stop using tm_mon, until we can get
clarification from the USENET Cabal(tinc) on this important matter!
UN-altered REPRODUCTION and DISSEMINATION of this
IMPORTANT Information is ENCOURAGED.
-=Eric
------------------------------
Date: Tue, 22 Jun 1999 12:27:39 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: A month behind using localtime(time) ?
Message-Id: <MPG.11d983825f3089bc989c1e@nntp.hpl.hp.com>
In article <3770cd5f.2673309@news.skynet.be> on Tue, 22 Jun 1999
17:54:07 GMT, Bart Lateur <bart.lateur@skynet.be> says...
...
> perldoc -f localtime
> -->
> # 0 1 2 3 4 5 6 7 8
> ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
> localtime(time);
>
> All array elements are numeric, and come straight out of
> a struct tm. In particular this means that `$mon' has
> the range `0..11' and `$wday' has the range `0..6' with
> sunday as day `0'.
>
> Nope. It says that the range for the months is 0..11, but it doesn't say
> which month is 0.
Why not throw him the rest of the paragraph for free? Otherwise Jocelyn
Amon will say we're ignoring (or, worse, denying) the Y2K problem.
Also, $year
is the number of years since 1900, that is, $year is `123' in
year 2023, and *not* simply the last two digits of the year. If
you assume it is, then you create non-Y2K-compliant programs--
and you wouldn't want to do that, would you?
Of course, TomC just posted the whole thing, but one wouldn't want
someone to have to read more than 200 lines, would one?
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Tue, 22 Jun 1999 13:01:39 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: Breaking up is hard to do
Message-Id: <x3yvhcgcgp8.fsf@tigre.matrox.com>
Jacques Rall <rall@trema.com> writes:
> I have a very long string, about 1000 characters, which I need to split
> up into 80 character lines or fields.
I would go with substr().
HTH,
Ala
------------------------------
Date: Tue, 22 Jun 1999 15:36:43 CDT
From: bobnospam@khusro.math.umn.edu
Subject: DBI/DBD mSQL: mSQL.so
Message-Id: <1999Jun22.153643@khusro.math.umn.edu>
If the subject heading got your interest, then you probably know how
to solve my little problem.
Towit, some output:
>csctest.pl
perl: can't resolve symbol 'msqlErrMsg'
install_driver(mSQL) failed: Can't load '/usr/local/lib/perl5/site_perl/5.005/
i686-linux/auto/DBD/mSQL/mSQL.so' for module DBD::mSQL:
Unable to resolve symbol at /usr/local/lib/perl5/5.00503/i686-linux/
DynaLoader.pm line 169.
at (eval 1) line 3
at ./csctest.pl line 19
where csctest.pl is just this:
#!/usr/bin/perl -w
use strict;
use DBI;
my $dsn = "DBI:mSQL:database=test_db1;host=myhost.math.umn.edu"
my $dbh = DBI->connect($dsn,$username,$userpasswd,{RaiseError => 1});
Now, /usr/local/../mSQL/mSQL.so exists and has the right permissions. The
code in DynaLoader.pm babbles about the usual problem being some issues in
the initialisation C code, and not in the line
my $libref = dl_load_file($file, $module->dl_load_flags) or
croak("Can't load '$file' for module $module: ".dl_error()."\n");
Is there some common error I am making? I compiled and installed
DBI-1.08
Data-ShowTable-3.3
Msql-Mysql-modules-1.2200
RSVP here and CC to me at bob at math dot umn dot edu.
Thanks for reading this far. :^)
Chris
------------------------------
Date: Tue, 22 Jun 1999 12:53:26 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: foreach and while (<FILE>)
Message-Id: <MPG.11d9898d7db1c31f989c1f@nntp.hpl.hp.com>
[Posted and a courtesy copy mailed.]
In article <376FA74E.63C6@dai.ed.ac.uk> on Tue, 22 Jun 1999 16:10:06
+0100, Chi-Chiang Shei <shei@dai.ed.ac.uk> says...
> Why does while (<FILE>) work only once (for the first element of @array)
> in the following extract:
>
> foreach $element (@index) {
> while (<FILE>) {
> print if (/$element/)
> }
> }
>
> How can I do the while bit for each element of @index?
Gasp! It seems as if you want to reread an entire file looking for each
line that matches every element of an array. That leads to catastrophic
performance problems. Basically, you want to interchange your two
loops, and read the file only once.
I strongly urge you to read the section in perlfaq4 about Arrays,
several times if necessary. What you seem to be trying to do is
discussed there.
If you really want a regex match, not simple string equality, look also
in perlfaq6: "How do I efficiently match many regular expressions at
once?"
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Tue, 22 Jun 1999 15:51:34 -0500
From: Andy Walden <andy@mtco.com>
Subject: Forking off a process
Message-Id: <376FF756.143F17E3@mtco.com>
I am currently faced with an issue where I am trying to fork off a
process
that executes a set of commands in a shell script and then sends the
user on elsewhere,
mailing
the results of the report later. Current I am trying to use:
if (fork)
{
exec ("/backup/usage/web-reports/web-usage-report $username"); };
Its not working out so well. Any ideas are appreciated. Please CC me in
the
response.
thanks for the time,
andy
------------------------------
Date: 22 Jun 1999 13:11:53 -0700
From: Mike Coffin <mhc@Eng.Sun.COM>
Subject: Re: function to read a line & return it
Message-Id: <8p6emj4j8qe.fsf@Eng.Sun.COM>
David Cassell <cassell@mail.cor.epa.gov> writes:
> Not all of us are that grumpy, you know [yes, I saw the smiley].
> I prefer to think of list vs scalar context as one of the
> strengths of Perl, rather than one of the annoyances. Once you
> learn to grok it, you'll find that it is incredibly useful.
>
> @time_stuff = localtime;
> $time_stuff = localtime;
>
> for example.
Wouldn't you agree that replacing the second line with
$time_stuff = ctime();
would not be *that* much harder to use or less useful?
-mike
------------------------------
Date: Tue, 22 Jun 1999 19:11:19 GMT
From: andrew-johnson@home.com (Andrew Johnson)
Subject: Re: How many questions about localtime?
Message-Id: <rdRb3.363$q6.11183@news2.rdc1.on.home.com>
In article <376FA796.6097C11C@ericsson.com>,
Matt Sergeant <matt.sergeant@ericsson.com> wrote:
! How many questions about the return values of localtime() does it take
! before one goes mad reading this ng?
I think the real question is:
How many faqs must a man write down,
before they call him insane?
and the answer, my friend, is probably far less
than 42.
andrew
(with suitable apologies to B. Dylan and D. Adams :-)
------------------------------
Date: 22 Jun 1999 14:20:05 -0600
From: Daniel Grisinger <dgris@moiraine.dimensional.com>
Subject: Re: How many questions about localtime?
Message-Id: <m3k8sw0yyy.fsf@moiraine.dimensional.com>
Matt Sergeant <matt.sergeant@ericsson.com> writes:
> How many questions about the return values of localtime() does it take
> before one goes mad reading this ng?
Hmmmmm..... let's see.
<slurp> One....
<slurp> Two....
<crunch> Three!!!
It takes three questions to get to the center of a mad
perl hacker. :-)
dgris
--
Daniel Grisinger dgris@moiraine.dimensional.com
perl -Mre=eval -e'$_=shift;;@[=split//;;$,=qq;\n;;;print
m;(.{$-}(?{$-++}));,q;;while$-<=@[;;' 'Just Another Perl Hacker'
------------------------------
Date: Tue, 22 Jun 1999 13:09:14 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: how to remove spaces in a line
Message-Id: <MPG.11d98d459a9a335a989c20@nntp.hpl.hp.com>
In article <376FD9BA.EC61E9B1@vsnl.com> on Wed, 23 Jun 1999 00:15:14
+0530, srishti <srishti@vsnl.com> says...
> use
>
> s/^ *//;
>
> ^ here represents begining of line.
>
> write back in case of some problem,
>
> Deepak.
I have two problems with your response, Deepak.
1. I don't like having the program do extra work when there are no
spaces at the beginning of the line.
2. I don't like answering questions that are answered (better) in the
FAQ. perlfaq4: "How do I strip blank space from the beginning/end of a
string?"
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 22 Jun 1999 20:11:15 GMT
From: fmgst+@pitt.edu (Filip M. Gieszczykiewicz)
Subject: Re: Is it better perl than awk ?
Message-Id: <7koql3$5cj$1@usenet01.srv.cis.pitt.edu>
In Article <7JA-fTkHw-B@khms.westfalen.de>, through puissant locution, kaih=7JA-fTkHw-B@khms.westfalen.de (Kai Henningsen) soliloquized:
>demas@sunspot.tiac.net ((Charles Demas)) wrote on 16.06.99 in <7k6sf3$8v4@news-central.tiac.net>:
[snip]
>Awk just doesn't seem to match the way I think about problems.
Same can be said for all the tools in unix and why I consider
perl to be my SCUBA gear on other OSes :-)
--
Filip "I'll buy a vowel" Gieszczykiewicz | http://www.repairfaq.org/
Always and everything for the better!
Now exploring whatever, life, and the meaning of it all... and 'not' :-)
------------------------------
Date: 22 Jun 1999 20:23:08 GMT
From: fmgst+@pitt.edu (Filip M. Gieszczykiewicz)
Subject: Re: Is it better perl than awk ?
Message-Id: <7korbc$5eb$1@usenet01.srv.cis.pitt.edu>
In Article <7JA-eLymw-B@khms.westfalen.de>, through puissant locution, kaih=7JA-eLymw-B@khms.westfalen.de (Kai Henningsen) soliloquized:
[snip]
>As for database access, I seem to recall hearing about an SQL engine
>written in awk+sh. Yes, I do think that's pretty perverted.
I had an HTML processing system that consisted of a 38KB shell (sans
comments) script [1] and over two dozen awk, sed, perl scripts, and
C pgms to do its work... you should have seen ps when that beast was up!!
It can be done... it shouldn't be, though. Then again, when I'm stuck
behind a firewall on some OSF machine without C, being able
to get the job done without the luxury of perl is a lifesaver.
Ugh.
[1] Hehehe... recursion is to shell what AI is to FORTRAN ;-)
--
Filip "I'll buy a vowel" Gieszczykiewicz | http://www.repairfaq.org/
Always and everything for the better!
Now exploring whatever, life, and the meaning of it all... and 'not' :-)
------------------------------
Date: Tue, 22 Jun 1999 19:03:08 GMT
From: root@bigtv.lnx.net (root)
Subject: MIME kill code ?
Message-Id: <slrn7mvno4.an.root@bigtv.lnx.net>
Looking for perl code to strip from mail-digest(s) bodies
mime (html vcards sigs and any non-text cruft)
look at mime tools but did slimply kill the mime.
Any other code out on the net. Using procmail to combine
the bodies of digests lest the headers.
TIA
--
end
cday@inetport.com
is CarL Day of Austin TX 78660-8424
------------------------------
Date: 22 Jun 1999 13:34:41 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: MIME kill code ?
Message-Id: <376fe551@cs.colorado.edu>
[courtesy cc of this posting mailed to cited author]
In comp.lang.perl.misc,
root@bigtv.lnx.net (root) writes:
:Looking for perl code to strip from mail-digest(s) bodies
:mime (html vcards sigs and any non-text cruft)
:look at mime tools but did slimply kill the mime.
:Any other code out on the net. Using procmail to combine
:the bodies of digests lest the headers.
:TIA
Personally, I use this, but I doubt whether it will
really do what you most want, exactly. It never
even makes it past sendmail. A beautiful thing. :-)
--tom
sub mime_check {
local $_;
return unless $_ = $headers{"content-type"};
return if exempt_user();
return if $headers{"form"} =~ /mailer|daemon|root|operator|postmaster/i;
if ( m#multipart/#i ) {
mail_audit("bounce multipart mime");
mft_message();
print STDERR "REJECT multipart\n\n";
exit EX_UNAVAILABLE;
}
if ($headers{'content-transfer-encoding'} =~ /quoted-printable/ ) {
mft_message();
mail_audit("bounce quoted illegible");
print STDERR "REJECT quoted illegible\n\n";
exit EX_UNAVAILABLE;
}
return if /^text$/i || m#text/plain#i;
mft_message();
mail_audit("bounce MIME fmt $_");
exit EX_UNAVAILABLE;
}
sub mft_message {
&deposit("$maildrops/mimes");
print STDERR <<'EOF';
***********************************************
*** MFT (MIME Firewall Toolkit) Intercept ***
***********************************************
Your message was in MIME format, and has therefore been intercepted
by MFT. Although the headers were legible, the remaining parts are
likely unreadable without MIME-aware tools. For optimal convenience
and portability, please do not send MIME messages to individuals on
other systems than your own who have not requested it.
MIME mail not accepted; resend using plain ASCII, or make special
arrangements with recipient.
EOF
}
--
"EMACS belongs in <sys/errno.h>: Editor Too Big!" -me
------------------------------
Date: Tue, 22 Jun 1999 20:00:14 GMT
From: jtubaugh@cftnet.com
Subject: Re: Multidimensional Associative (hash) array
Message-Id: <7koq07$iim$1@nnrp1.deja.com>
In article <376EFC03.1F28DC48@zeus.ia.net>,
Michael Carman <mjcarman@zeus.ia.net> wrote:
>
> # Let's see what we just created
> foreach $outer_key (sort keys %hash) {
> print "$outer_key:\n";
> foreach $inner_key (sort keys %{$hash{$outer_key}}) {
> print " $inner_key = $hash{$outer_key}{$inner_key}\n";
> }
> }
This code is exactly what was needed to do what I was trying to do.
But... before I just grab it and implement it, I want to be sure and
understand it.
What is causing me a little confusion is the "%{$hash{$outer_key}})"
syntax. At the very least I'm not sure that what I *think* is happening
really is. Here is what I think is going on. Can you (or someone) give
me a quick sanity check?
I know you reference rows of a hash by using $hash{$key_value}. What I
think the "%{$hash{$outer_key}})" syntax in the foreach loop is doing is
referencing the value of the outer hash, identified by $outer_key, which
actually contains a pointer to the inner hash.
So the "%" is the hash identifier, and $hash{$outer_key} is the row in
the outer hash table. What I don't understand syntactially is what the
curly braces are that surround the entire {$hash{$outer_key}}. Why are
they necessary, and how would I have known to put them there?
>
> The inner keys don't have to all be the same, either, but if you're
doing
> this it's likely that you're trying to create a
> struct/record/object/whatever you wnat to call it depending on what
you're
> used to programming in, so they often will be.
This is *exactly* what I am trying to do! and I'm trying to keep it as
generic and dynamic as possible.
>
> This really is more advanced than one is likely to encounter in their
first
> stab at Perl. I take it that "Hello, world!" just wasn't enough of a
> challenge? Technically, I believe that what this approach really does
Yeah <grin>. Looks like I jumped right into this one. But its a good
way to learn! And, yes, I have been spending my time in the perlfaq,
tutorials and documentation. But its a lot to absorb.
Thanks for your assistance and explanations.
Jeff
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Tue, 22 Jun 1999 20:32:04 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Multidimensional Associative (hash) array
Message-Id: <376ff14c.702545@news.skynet.be>
jtubaugh@cftnet.com wrote:
>What is causing me a little confusion is the "%{$hash{$outer_key}})"
>syntax.
>Can you (or someone) give me a quick sanity check?
...
>So the "%" is the hash identifier, and $hash{$outer_key} is the row in
>the outer hash table. What I don't understand syntactially is what the
>curly braces are that surround the entire {$hash{$outer_key}}. Why are
>they necessary, and how would I have known to put them there?
You're on the right track. Actually, %{...} expects a hash reference
inside the block, and dereferences it. Reference (=scalar) in, hash out.
The curly braces take care of precedence, and aren't absolutely
necessary, PROVIDED that the precedence rules don't change if you leave
them out.
And yes, I too would have tought that for that use (=precedence), parens
would have made more sense.
$($hash{$outer_key}) # DOES NOT WORK
OTOH, Larry Wall himself wrote in this newsgroup some while ago, that he
remembered the syntax as "a block that may contain anything, as long as
it returns a (hash) reference".
Bart.
------------------------------
Date: Wed, 23 Jun 1999 00:34:25 +0530
From: srishti <srishti@vsnl.com>
To: Mark Austin <austin.m@virgin.net>
Subject: Re: Need to edit cgi script using Windows PC, which prog to use
Message-Id: <376FDE39.EEF91899@vsnl.com>
A general problem of different new-line charactes in UNIX and Windows.
You can edit with Notepad/Wordpad, Only one caution use ftp (in ASCII
mode) to move scripts back to unix system.
Mark Austin wrote:
>
> Actually, I just need to change the baseline (URL) address of a Perl cgi
> script.
> Is it safe to do this in Notepad or Wordpad, I've heard that (if you use the
> wrong progam) it adds some stuff that the Unix box will not like.
>
> RSVP and thanks
>
> Mark
------------------------------
Date: Tue, 22 Jun 1999 19:03:02 GMT
From: ufmemo@my-deja.com
Subject: Re: Newbie - Perl books - which to get?
Message-Id: <7komku$h5r$1@nnrp1.deja.com>
In article <376FB0D7.643584DE@itol.com>,
Rhonda Nowak <rmn@itol.com> wrote:
> Hi All,
> I looked on Amazon for Perl books and found quite a few. I would like
> to order a couple. Here is my narrowed list:
>
> Beginner Level -
> Learning Perl (2nd Edition) - Randal L. Schwartz
> Teach Yourself Perl 5 in 21 Days - David Till
>
> Advanced Level -
> Effective Perl Programming: Writing Better Programs with Perl - Joseph
> N. Hall
> Programming Perl (2nd Edition) - Larry Wall
> Perl: The Programmer's Companion - Nigel Chapman
>
> I read reviews on Amazon, but would like to hear from anyone who
> knows/has heard of these books. Please help me decide which would be
> best for me (beginner) and our more experienced Perl programmer.
>
> Thanks much,
> Rhonda
>
>
You really want the main three from Orilley
1. Learning Perl
2. Programming Perl or Perl In a Nutshell
3. The Perl Cookbook
The first is a walk through or perl, the second two are reference,
and the third is a recipe book.
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Tue, 22 Jun 1999 22:02:20 +0100
From: "Simon Ross" <Sp.Ross@btinternet.com>
Subject: Newbie PWS problems help!
Message-Id: <7kote2$c5o$1@plutonium.btinternet.com>
I still can't get my scripts working on MS Personal Web Server.
I've consulted the ActiveState docs and it suggests that I need to make
changes to my registry (Script Map key)- is this correct? Shouldn't the Perl
installation have sorted this out for me? Any way, I made the changes and my
browser just sits there forever, not sending anything back.
Tell me which part I'm doing wrong:
1. Write simple script e.g:
#!usr/bin/perl
print <<END_of_html;
Content-type: text/html
<html>
<body>
<p>hello cruel world</p>
</body>
</html>
END_of_html;
2. save to SCRIPTS directory as hello.pl
3. in browser, type http://localhost/scripts/hello.pl
4. wait for two possible outcomes:
a) browser waits forever, returning no content (this is WITH registry
changes); or....
b) browser returns above script WITHOUT executing it,ie as raw text.
(this is WITHOUT registry changes).
So: how do I get the perl interpreter to execute my script on 'server side'
BEFORE returning result?
YES - my PC knows and understands the .pl/.plx extensions and runs my
scripts fine from the command line.
YES - my execute and script permissions HAVE been set properly.
Any feedback would be greatly appreciated - I know it must be something
stupidly simple!
Ross.
------------------------------
Date: Tue, 22 Jun 1999 18:50:13 GMT
From: pweck@ixc.net
Subject: perl, htaccess, authorization
Message-Id: <7kolt1$grr$1@nnrp1.deja.com>
Hi,
I have just added .htaccess and .htpasswd to certain directories that i
want to protect. When a user runs a script from these protected
directories, they are presented with a box to enter username and
password. My original purpose for protection was so that the scripts
would be safe from being copied etc...not to restrict access to using
the scripts.
What do i need to do to keep the directories password protected, but at
the same time allow the scripts in those directories to be accessed? Is
there something that i can add to the scripts and/or html documents that
can do this?
Thanks!
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Tue, 22 Jun 1999 20:57:42 GMT
From: alastair@calliope.demon.co.uk (Alastair)
Subject: Re: Piping through Less.
Message-Id: <slrn7n01qo.5o.alastair@calliope.demon.co.uk>
ktb <xyf@inetnebr.com> wrote:
>Rick Delaney wrote:
>> What's wrong with actually piping to less?
>>
>> $ perl yourprog | less
>
>If I pipe it through less at the command line I can't enter the sting I
>want to search for. The program can't run.
Make sure your program accepts a command line argument and use that as a search
term ;
$ perlprogram <searchterm> | less
HTH.
--
Alastair
work : alastair@psoft.co.uk
home : alastair@calliope.demon.co.uk
------------------------------
Date: Tue, 22 Jun 1999 16:00:34 -0400
From: planb@newsreaders.com (J. Moreno)
Subject: Re: Statistics for comp.lang.perl.misc
Message-Id: <1dtt53a.yov94bavpsleN@roxboro0-0035.dyn.interpath.net>
Randal L. Schwartz <merlyn@stonehenge.com> wrote:
> >>>>> "Greg" == Greg Bacon <gbacon@itsc.uah.edu> writes:
>
> Greg> That's beatable too. What if she uses different prefixes for each
> Greg> quoted line?
>
> Maybe Abi deserves to be taken out of the normal mix, and given an
> honorary "automatically historically excessive" OCR place in the
> standings. Item # 0 or something. :)
>
> Maybe what I'm really saying is I don't understand if Abi is using
> different prefixes just to foul up statistics, or what. And if so,
> the stats should just ignore her. And I don't like having that kind
> of confusion in my life. :)
>
> print "Just another confused Perl hacker,"
I'd agree with you totally, if you didn't use a non standard style
yourself.
The more people that use the standard quoting style the easier it is to
convince newsreader authors that they should recognize that there /is/ a
standard.
And ditto for posters -- non-standard quoting just encourages them to
ignore the fact that their newsreaders spew out garbage; after all why
should they take the trouble to switch to something better or fix it by
hand when the old timers/big names are using something non-standard.
--
John "Yes, I am a news nazi, what's wrong with that" Moreno
------------------------------
Date: Tue, 22 Jun 1999 15:42:27 -0500
From: rlb@intrinsix.ca (Lee)
Subject: Re: Statistics for comp.lang.perl.misc
Message-Id: <B3955F639668EFD65@204.112.166.88>
In article <1dtt53a.yov94bavpsleN@roxboro0-0035.dyn.interpath.net>,
planb@newsreaders.com (J. Moreno) wrote:
>The more people that use the standard quoting style the easier it is to
>convince newsreader authors that they should recognize that there /is/ a
>standard.
I have some ODD (oppositional-defiant) friends who could give everyone here
lessons on non-conventional newsreader configuration.
Lee
------------------------------
Date: Tue, 22 Jun 1999 20:42:16 +0100
From: James Stewart <james@britlinks.co.uk>
Subject: Summing an array
Message-Id: <ant2219160e6Lh==@ch0128.charis.co.uk>
Just wondering how to find the sum of all the elements of an array. A
look through the FAQs doesn't yield an answer. I guess I could do it with
a loop, but I'm guessing there's a more elegant solution.
cheers. James.
--
James Stewart - james@britlinks.co.uk | "Telecom ignored us and
The Britlinks - http://www.britlinks.co.uk | democracy has died."
Phantom Tollbooth - http://www.tollbooth.org | -- Fat And Frantic
Sixpence None The Richer in the UK - http://www.britlinks.co.uk/sixpence/
------------------------------
Date: 22 Jun 1999 13:59:21 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Summing an array
Message-Id: <376feb19@cs.colorado.edu>
[courtesy cc of this posting mailed to cited author]
In comp.lang.perl.misc,
James Stewart <james@britlinks.co.uk> writes:
:Just wondering how to find the sum of all the elements of an array. A
:look through the FAQs doesn't yield an answer. I guess I could do it with
:a loop, but I'm guessing there's a more elegant solution.
A loop is inelegant?
--tom
--
There are many times when you want it to ignore the rest of the string just
like atof() does. Oddly enough, Perl calls atof(). How convenient. :-)
--Larry Wall in <1991Jun24.231628.14446@jpl-devvax.jpl.nasa.gov>
------------------------------
Date: Tue, 22 Jun 1999 21:11:33 +0100
From: James Stewart <james@britlinks.co.uk>
Subject: Re: Summing an array
Message-Id: <ant222033f00Lh==@ch0128.charis.co.uk>
In article <376feb19@cs.colorado.edu>, Tom Christiansen
<URL:mailto:tchrist@mox.perl.com> wrote:
> [courtesy cc of this posting mailed to cited author]
>
> In comp.lang.perl.misc,
> James Stewart <james@britlinks.co.uk> writes:
> :Just wondering how to find the sum of all the elements of an array. A
> :look through the FAQs doesn't yield an answer. I guess I could do it with
> :a loop, but I'm guessing there's a more elegant solution.
>
> A loop is inelegant?
not necessarily, but if there were a single command to do this I'd
consider that more elegant.
James.
--
James Stewart - james@britlinks.co.uk | "Telecom ignored us and
The Britlinks - http://www.britlinks.co.uk | democracy has died."
Phantom Tollbooth - http://www.tollbooth.org | -- Fat And Frantic
Sixpence None The Richer in the UK - http://www.britlinks.co.uk/sixpence/
------------------------------
Date: 22 Jun 1999 16:20:45 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Summing an array
Message-Id: <x7pv2o6l7m.fsf@home.sysarch.com>
>>>>> "JS" == James Stewart <james@britlinks.co.uk> writes:
JS> In article <376feb19@cs.colorado.edu>, Tom Christiansen
JS> <URL:mailto:tchrist@mox.perl.com> wrote:
>> [courtesy cc of this posting mailed to cited author]
>>
>> In comp.lang.perl.misc,
>> James Stewart <james@britlinks.co.uk> writes:
>> :Just wondering how to find the sum of all the elements of an array. A
>> :look through the FAQs doesn't yield an answer. I guess I could do it with
>> :a loop, but I'm guessing there's a more elegant solution.
>>
>> A loop is inelegant?
JS> not necessarily, but if there were a single command to do this I'd
JS> consider that more elegant.
my $sum ;
$sum += $_ foreach @addends ;
can't get much simpler (except in apl where it is "SUM<-ARRAY/+" IIR)
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
------------------------------
Date: Wed, 23 Jun 1999 00:27:06 +0530
From: srishti <srishti@vsnl.com>
To: Jimtaylor5 <jimtaylor5@aol.com>
Subject: Re: time question
Message-Id: <376FDC82.7BD97E95@vsnl.com>
You do not need to extract it from localtime, use time instead. It will
give you number of seconds since 01-01-1970.
Deepak.
Jimtaylor5 wrote:
>
> I hope this is not really a dumb question, but I've been trying to figure out
> how to get seconds from localtime (or anywhere) to calculate how long a task
> takes. How would I get the time in seconds from Perl, in order to say this task
> to 11 seconds or whatever it took. I know how to calculate it, jut not how to
> get the time in seconds. Can anyone help?
------------------------------
Date: Tue, 22 Jun 1999 11:36:55 -0700
From: "Rich G." <rg@fubar.net>
Subject: Re: unable to create or rename files in subdirectories
Message-Id: <7kol5p$svg$1@fir.prod.itd.earthlink.net>
JQ wrote in message <3772d2c9.41303568@news.cyberway.com.sg>...
>I am unable to create or rename files that exist in subdirectories.
>
>Everything works fine if I create or rename files that are in the same
>directory as my script:
perldoc permissions
--------------------------------------------------------------------------------
----
Rich G. -- Yet Another Perl Developer
"Give a (person) a (script), they'll run for a day,
Teach them how to (program), they can run forever."
------------------------------
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 6097
**************************************