[18159] in Perl-Users-Digest
Perl-Users Digest, Issue: 327 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Feb 21 14:06:18 2001
Date: Wed, 21 Feb 2001 11:05:18 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <982782318-v10-i327@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest           Wed, 21 Feb 2001     Volume: 10 Number: 327
Today's topics:
    Re: Apache mod_perl & MySQL <tore@extend.no>
    Re: Apache mod_perl & MySQL (Rafael Garcia-Suarez)
    Re: calling other executables from a perl script (Jayant V Rajan)
    Re: calling other executables from a perl script (Jayant V Rajan)
    Re: calling other executables from a perl script (Abigail)
    Re: chop and chomp <roman.stawski@fr.adp.com>
    Re: chop and chomp <flavell@mail.cern.ch>
    Re: Difficult Split Question <bmb@ginger.libs.uga.edu>
        do 'filename.pl' and Test harness problems <todd@andrew2.stanford.edu>
        Free debugger suggestions <mshort@usol.com>
        Help with ?: and ! operators <mshort@usol.com>
    Re: Help with ?: and ! operators <jonni@ifm.liu.se>
    Re: Help with ?: and ! operators <james@NOSPAM.demon.co.uk>
        how to create private/public functions in modules? <foojh@hotmail.com>
    Re: how to create private/public functions in modules? <godzilla@stomp.stomp.tokyo>
    Re: how to create private/public functions in modules? nobull@mail.com
    Re: How to print a...? <joachim.rose@psi.ch>
        IPC with Unix (ksh) system calls <eggrock@MailAndNews.com>
    Re: Is this a bug? Can someone explain? (Anno Siegel)
    Re: Is this a bug? Can someone explain? (Rafael Garcia-Suarez)
    Re: Is this a bug? Can someone explain? (Anno Siegel)
    Re: Is this a bug? Can someone explain? (John Joseph Trammell)
    Re: Is this a bug? Can someone explain? <dev@trahojen.REMOVETHIS.com>
    Re: Is this taint example correct? <ddunham@redwood.taos.com>
    Re: MacPerl help for a newbie <michael.beardsley@dartmouth.edu>
    Re: Need help creating a simple class. nobull@mail.com
    Re: Print a page of HTML (Rafael Garcia-Suarez)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 21 Feb 2001 15:37:13 +0100
From: Tore Aursand <tore@extend.no>
Subject: Re: Apache mod_perl & MySQL
Message-Id: <MPG.14fdf102f190fee19898be@news.online.no>
In article <970evm$6f8$1@plaza.suomi.net>, jyli-luu@gc2.geracap.fi 
> [mod_perl/apache]
> Can anyone give me a hint for this one?
<URL:http://perl.apache.org/>
-- 
Tore Aursand - tore@extend.no - http://www.extend.no/~tore/
------------------------------
Date: Wed, 21 Feb 2001 14:42:10 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: Apache mod_perl & MySQL
Message-Id: <slrn997kt3.aso.rgarciasuarez@rafael.kazibao.net>
Jaakko Yli-Luukko wrote in comp.lang.perl.misc:
>
> I am using Apache with mod_perl and my Perl (CGI-)script is accessing MySQL
> server.
> 
> I need to speed up my Apache requests. I understand it is possible to leave
> MySQL connection 'open' between Apache request.But I don't know how should I
> do that.
> Can anyone give me a hint for this one?
The mod_perl site (http://perl.apache.org/) has a lot of useful info.
For a quick overview, look at :
http://perl.apache.org/src/mod_perl.html#PERSISTENT_DATABASE_CONNECTIONS
which is also in the mod_perl manpage that should be installed on your
system. The docs for Apache::DBI may also be useful.
-- 
Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/
------------------------------
Date: 21 Feb 2001 15:56:56 GMT
From: jrajan@red.seas.upenn.edu (Jayant V Rajan)
Subject: Re: calling other executables from a perl script
Message-Id: <970og8$et6$1@netnews.upenn.edu>
: But what kind of problems do you get? When do they happen?
: Why aren't you checking your return values of open()?
: What are @lines1 and @lines2?
: Abigail
: -- 
I was just being sloppy re: checking return values of open. In the past, 
for the kinds of things I've needed to do, I've never had a problem with 
reading/writing files.
The arrays @lines1 and @lines2 are just the repositories for respective 
split() statements. Each line of the files I'm reading is a record, and I 
parse each one. Since I need to compare the contents of the two files, 
in the first case I jsut use a hash (this is %sts) to keep track of IDs 
that I've already seen. The main purpose of the line parsing is to give 
me the IDs to compare. Hope that helps/makes sense. Thanks.
JR
------------------------------
Date: 21 Feb 2001 16:16:44 GMT
From: jrajan@red.seas.upenn.edu (Jayant V Rajan)
Subject: Re: calling other executables from a perl script
Message-Id: <970plc$r6$1@netnews.upenn.edu>
: But what kind of problems do you get? When do they happen?
: Why aren't you checking your return values of open()?
: What are @lines1 and @lines2?
: Abigail
Oops. My apologies. I forgot to clearly identify the problem(s) I have. 
Basically, here's the problem: I need the results of a previous system 
call (at the bottom of the loop; the first call to the program "e-pcr" is 
outside the loop) in order to make the next call. In essence, I naively 
assumed that execution of the loop would wait for the system call to 
"finish". Here's how I (roughly) thought the program would work:
Begin loop:
	
1)open previous results file, store list of IDs
2)compare IDs from results file to IDs in the old ID file that was used 
in the run that created the results file
3) write a new list of IDs, retaining only those from the ID file that are
_not_ in the results file
4) call the "e-pcr" program again, with the next set of parameters, using
the new ID file and redirecting output to a new results file
End loop
When I run the script, it basically looks like I get a successive series 
of system calls. I tested this out by just sticking a print statment in 
one of the earlier sections of the loop that should (in theory) execute 
during every iteration of the loop. Instead, I find that the print 
statement "appears" to execute only once, i.e. I only see it on the 
screen once. I'm guessing that this has something to do with the fact 
that the executable (e-pcr) I'm calling outputs to STDOUT, which is 
presumably inherited from the parent process.
I don't know if anyof what I've written makes sense, but if anyone has 
any insight, I'd appreciate hearing it. If worst comes to worst, I can 
just write a shell script, but it's an uglier solution and I'd rather not 
do so if I don't have to.
JR
------------------------------
Date: 21 Feb 2001 18:53:50 GMT
From: abigail@foad.org (Abigail)
Subject: Re: calling other executables from a perl script
Message-Id: <slrn9983lu.8cf.abigail@tsathoggua.rlyeh.net>
Jayant V Rajan (jrajan@red.seas.upenn.edu) wrote on MMDCCXXXI September
MCMXCIII in <URL:news:970plc$r6$1@netnews.upenn.edu>:
}} : But what kind of problems do you get? When do they happen?
}} : Why aren't you checking your return values of open()?
}} : What are @lines1 and @lines2?
}} 
}} 
}} 
}} : Abigail
}} 
}} Oops. My apologies. I forgot to clearly identify the problem(s) I have. 
}} Basically, here's the problem: I need the results of a previous system 
}} call (at the bottom of the loop; the first call to the program "e-pcr" is 
}} outside the loop) in order to make the next call. In essence, I naively 
}} assumed that execution of the loop would wait for the system call to 
}} "finish". Here's how I (roughly) thought the program would work:
Perl does.
However, if the called program forks() and its children outlive the
parent, Perl can't know, and will continue as soon as the parent exists.
}} 
}} Begin loop:
}} 	
}} 1)open previous results file, store list of IDs
}} 2)compare IDs from results file to IDs in the old ID file that was used 
}} in the run that created the results file
}} 3) write a new list of IDs, retaining only those from the ID file that are
}} _not_ in the results file
}} 4) call the "e-pcr" program again, with the next set of parameters, using
}} the new ID file and redirecting output to a new results file
}} 
}} End loop
}} 
}} When I run the script, it basically looks like I get a successive series 
}} of system calls. I tested this out by just sticking a print statment in 
}} one of the earlier sections of the loop that should (in theory) execute 
}} during every iteration of the loop. Instead, I find that the print 
}} statement "appears" to execute only once, i.e. I only see it on the 
}} screen once. I'm guessing that this has something to do with the fact 
}} that the executable (e-pcr) I'm calling outputs to STDOUT, which is 
}} presumably inherited from the parent process.
It does, but that's irrelevant. That looks like you have a problem with
the logic controlling the loop, not with Perl calling external programs.
What happens if you run the program where you replace the call to
e-pcr with a trivial thing creating the file that would be created?
Abigail
-- 
perl -wle 'eval {die [[qq [Just another Perl Hacker]]]};; print
           ${${${@}}[$#{@{${@}}}]}[$#{${@{${@}}}[$#{@{${@}}}]}]'
------------------------------
Date: Wed, 21 Feb 2001 17:06:59 +0100
From: Roman Stawski <roman.stawski@fr.adp.com>
Subject: Re: chop and chomp
Message-Id: <3A93E7A3.6A7597C8@fr.adp.com>
Bernard El-Hagin wrote:
> 
> On Tue, 20 Feb 2001 07:33:10 -0800, brian d foy <comdog@panix.com>
> wrote:
> >In article <slrn994fdl.lgi.bernard.el-hagin@gdndev32.lido-tech>,
> >bernard.el-hagin@lido-tech.net wrote:
> >
> >> That's not entirely accurate. chomp removes whatever $\ is set to,
> >> whether it's a newline or not.
> >
> >chomp removes whatever $/ ($INPUT_RECORD_SEPARATOR).
> 
> I always get the symbols of those two mixed up. :)
> 
Couldn't we add $€ (<-Euro symbol) to Perl to specify which way the 
slash goes in $/ (or was that $\)?
<ducks>
-- 
Roman Stawski - ADPgsi
------------------------------
Date: Wed, 21 Feb 2001 18:40:57 +0100
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: chop and chomp
Message-Id: <Pine.LNX.4.30.0102211838550.13205-100000@lxplus003.cern.ch>
On Wed, 21 Feb 2001, Roman Stawski wrote:
(in a posting marked as
Content-Type: text/plain; charset=iso-8859-1 )
> Couldn't we add $^A (<-Euro symbol) to Perl
No, if only because what you typed was a control-function in
iso-8859-1 , not a displayable character at all.
> <ducks>
Quack, quack...
;-}
------------------------------
Date: Wed, 21 Feb 2001 10:40:26 -0500
From: Brad Baxter <bmb@ginger.libs.uga.edu>
Subject: Re: Difficult Split Question
Message-Id: <Pine.A41.4.21.0102211029250.11852-100000@ginger.libs.uga.edu>
On Wed, 21 Feb 2001, Christopher Burke wrote:
> Thanks for the hint - I'll give it a go.
> 
> On a scale of 1 to 10 in Perl where 10 = guru, I'm still at about 3 or 4.
You're doing better than me.  The more I learn the small my number gets.
:-)
Brad
------------------------------
Date: Wed, 21 Feb 2001 09:48:16 -0800
From: Todd Richmond <todd@andrew2.stanford.edu>
Subject: do 'filename.pl' and Test harness problems
Message-Id: <todd-A07C85.09481621022001@nntp.stanford.edu>
I'm working on a small script to run a number of '.t' files on a Mac, 
since we don't have the option of using the standard "make", "make 
test", "make install" sequence. The following code works but dies after 
the first test:
use File::Basename;
my ($app, $path) = fileparse($0);
opendir(DIR, $path) || die "Can't open test script directory";
@tests = grep(/.*\.t$/, readdir(DIR));
foreach $test (@tests) {
   $testfile = $path.$test;
   select STDOUT;
   print "Running ", $test,"\n";
   do $testfile or die; # propagate any errors.
}
The output:
Running AAChange.t
1..24
ok 1
 ...
ok 24
Running AAReverseMutate.t
# Test::plan(): should not be called more than once
File 'Cellwall:Documents:Downloads:bioperl-live:t:AAReverseMutate.t'; 
Line 16
# BEGIN failed--compilation aborted.
File 'Cellwall:Documents:Downloads:bioperl-live:t:AAReverseMutate.t'; 
Line 17
   ...propagated.
File 'Cellwall:Documents:Downloads:bioperl-live:t:mactests.pl'; Line 17
So Test::plan can only be called once from the invoking script? Any way 
to "reset" Test::plan() so that it thinks it's being called for the 
first time for each test script? Or is there another way to run each of 
the 60+ test scripts? I know I could use Applescript to script MacPerl 
and run each one separately, but for now I'd like to stick with a pure 
Perl solution.
Thanks, Todd
-- 
---
Dr. Todd Richmond
Carnegie Insitution, Dept of Plant Biology
260 Panama Street
Stanford, CA 94305
------------------------------
Date: Wed, 21 Feb 2001 12:30:54 -0800
From: "mshort" <mshort@usol.com>
Subject: Free debugger suggestions
Message-Id: <t97uit2423mj90@corp.supernews.com>
I am currently using SynEdit for Perl editing, however, I don't like not
have line numbers, but I like the fact that I can hit F8 and have the script
run in dos mode.  Any suggestions on another editing tool?
Thanks,
Matt
------------------------------
Date: Wed, 21 Feb 2001 12:27:02 -0800
From: "mshort" <mshort@usol.com>
Subject: Help with ?: and ! operators
Message-Id: <t97ubh41vneo57@corp.supernews.com>
I am just learning Perl 5 and will probably have questions from time to
time.  Here's my first-
1?2?3:4:5
The book says that this equates to 3 and is the same as 1?(2?3:4):5
When looking at that statement and speaking in english is this what you
think--
1 is true so 2, 2 is true so 3.  STOP since 3 is true it doesn't mean 4 or 5
otherwise
And the other question is with the ! operator
if
!1 is 0
!0 is 1
I think I understand the !1.  It means NOT 1, but I don't understand how !0
equals 1.  Unless 0 is false and 1 is true.  Is that right?
Any help would be appreciated,
Matt
------------------------------
Date: Wed, 21 Feb 2001 18:51:31 +0100
From: "Jonas Nilsson" <jonni@ifm.liu.se>
Subject: Re: Help with ?: and ! operators
Message-Id: <970v57$8do$1@newsy.ifm.liu.se>
!expr returns empty string for all expr except for '' 0 '0' (it returns 1
for these).
/jN
--
 _____________________     _____________________
|   Jonas Nilsson     |   |                     |
|Linkoping University |   |      Telephone      |
|       IFM           |   |      ---------      |
| Dept. of Chemistry  |   | work: +46-13-285690 |
|  581 83 Linkoping   |   | fax:  +46-13-281399 |
|      Sweden         |   | home: +46-13-130294 |
|_____________________|   |_____________________|
"mshort" <mshort@usol.com> wrote in message
news:t97ubh41vneo57@corp.supernews.com...
> I am just learning Perl 5 and will probably have questions from time to
> time.  Here's my first-
>
> 1?2?3:4:5
>
> The book says that this equates to 3 and is the same as 1?(2?3:4):5
>
> When looking at that statement and speaking in english is this what you
> think--
>
> 1 is true so 2, 2 is true so 3.  STOP since 3 is true it doesn't mean 4 or
5
> otherwise
>
>
>
> And the other question is with the ! operator
>
> if
> !1 is 0
> !0 is 1
>
> I think I understand the !1.  It means NOT 1, but I don't understand how
!0
> equals 1.  Unless 0 is false and 1 is true.  Is that right?
>
> Any help would be appreciated,
>
> Matt
>
>
------------------------------
Date: Wed, 21 Feb 2001 17:53:22 +0000
From: James Taylor <james@NOSPAM.demon.co.uk>
Subject: Re: Help with ?: and ! operators
Message-Id: <ant2117220b0fNdQ@oakseed.demon.co.uk>
In article <t97ubh41vneo57@corp.supernews.com>, mshort
<URL:mailto:mshort@usol.com> wrote:
> 
> 1?2?3:4:5
> 
> The book says that this equates to 3 and is the same as 1?(2?3:4):5
> 
> When looking at that statement and speaking in english is this what you
> think--
> 
> 1 is true so 2, 2 is true so 3.  STOP since 3 is true it doesn't mean 4 or 5
> otherwise
Personally I wouldn't get that far, I'd just look at how it parsed ie.
1?(2?3:4):5 and then look to see how it evaluates, but then I'm more
of a visual person rather than verbal. I think you've got the right
idea though.
> And the other question is with the ! operator
> 
> if
> !1 is 0
> !0 is 1
> 
> I think I understand the !1.  It means NOT 1, but I don't understand how !0
> equals 1.  Unless 0 is false and 1 is true.  Is that right?
Yes, the ! operator is a logical NOT (as opposed to the ~ operator
which is a bitwise NOT).
-- 
James Taylor <james (at) oakseed demon co uk>
Based in Hammersmith, London, UK.
PGP key available ID: 3FBE1BF9
Fingerprint: F19D803624ED6FE8 370045159F66FD02
------------------------------
Date: Wed, 21 Feb 2001 23:53:55 +0800
From: "JH Foo" <foojh@hotmail.com>
Subject: how to create private/public functions in modules?
Message-Id: <970o95$6en$1@newsie.singa.pore.net>
Hi guys, I'm trying to write some perl modules and I want to emulate
OOP-style programming as much as possible. for starters, i want to create
modules which have 'internal' functions to be called by other functions
within the modules. I also want to have some public functions which are
'safe' to be called by other modules.
it seems to be that perl does not have this kind of restriction. can someone
pls confirm this?
------------------------------
Date: Wed, 21 Feb 2001 09:10:31 -0800
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: how to create private/public functions in modules?
Message-Id: <3A93F687.53C3B7E6@stomp.stomp.tokyo>
JH Foo wrote:
 
> Hi guys, I'm trying to write some perl modules and I want to emulate
> OOP-style programming as much as possible. for starters, i want to create
> modules which have 'internal' functions to be called by other functions
> within the modules. I also want to have some public functions which are
> 'safe' to be called by other modules.
 
> it seems to be that perl does not have this kind of restriction. 
> can someone pls confirm this?
You best and most authoritative confirmation of your
notions, is to write a simple test module which includes
your parameters, then test. You will have an exacting
answer, instantly. Scientific Observation is always
preferable, compared to public conjecture.
Godzilla!
------------------------------
Date: 21 Feb 2001 17:42:28 +0000
From: nobull@mail.com
Subject: Re: how to create private/public functions in modules?
Message-Id: <u9r90s2arf.fsf@wcl-l.bham.ac.uk>
"JH Foo" <foojh@hotmail.com> writes:
> Hi guys, I'm trying to write some perl modules and I want to emulate
> OOP-style programming as much as possible. for starters, i want to create
> modules which have 'internal' functions to be called by other functions
> within the modules. I also want to have some public functions which are
> 'safe' to be called by other modules.
> 
> it seems to be that perl does not have this kind of restriction. can someone
> pls confirm this?
Confirmed.  (Should be in Perl6).
-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\
------------------------------
Date: Wed, 21 Feb 2001 15:46:16 +0100
From: Joachim Rose <joachim.rose@psi.ch>
Subject: Re: How to print a...?
Message-Id: <3A93D4B8.8C2CEEBA@psi.ch>
have your tried  <  instead of < ?
Example:
Output: A<B   Code: A<B
Achim  
Gop wrote:
> 
> What I would like to do is print a "<" in a label with the radio_group
> function in a cgi script (so it would output it as a < instead of <). I
> have tried everything I can think of so now I'm asking the helpful group...
------------------------------
Date: Wed, 21 Feb 2001 11:52:17 -0500
From: Allan <eggrock@MailAndNews.com>
Subject: IPC with Unix (ksh) system calls
Message-Id: <3A956F3D@MailAndNews.com>
This has two parts, I'll try to keep it short.
1) I want to call a .ksh script that sets and exports various variables from 
a 
Perl script, and have those values available in %ENV.
2) I also want to pass arguments to the .ksh script
Here's what I came up with:
`ksh ". /path/to/program.ksh arg1 arg2"`;
This seems to work, but I don't know if I should be checking return values, 
or 
using open() (which BTW I completely don't understand after reading the IPC 
FAQ).
Thanks!
------------------------------
Date: 21 Feb 2001 14:20:31 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Is this a bug? Can someone explain?
Message-Id: <970irf$ehs$1@mamenchi.zrz.TU-Berlin.DE>
According to Trahojen <dev@trahojen.REMOVETHIS.com>:
> Anno,
> 
> >> Can someone explain to me why this code doesn't produce the intended
> results
> >> when using qq()?
> > What are the intended results, and what happens instead?
> 
> Had you run the code, you'd have noticed.
Running code from a Usenet article isn't trivial.  First off, you
must check manually if it is benign, which takes time.  Next, often
also done manually, you must see if it has a reasonable chance to
run in your environment.  If both answers are yes, you'll have to
cut-and-paste it into an executable file and usually make some
adjustments.  *Then* you run it and interpret the results.
All articles with code in them compete for this treatment, but only
a few can get it.
I usually do it when a question interests me.  Doing it to decide *if*
a question interests me is too much bother.
> But I totally agree I should have included that.
I'm glad you agree.
[snippage]
> >> Also note that \n works fine. \s does not.
> > Works how?  \s has only a special meaning in regular expressions, where
> > it is any whitespace character.  In quoted text, \s is the same as s.
> 
> To much regex'ing lately. That explains it all.
What should the expansion of "\s" be anyhow?  In a regex, \s is
equivalent to [ \t\n\r\f], but the expansion would have to decide
for one of them.
------------------------------
Date: Wed, 21 Feb 2001 14:36:25 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: Is this a bug? Can someone explain?
Message-Id: <slrn997kia.aso.rgarciasuarez@rafael.kazibao.net>
Anno Siegel wrote in comp.lang.perl.misc:
>
> Running code from a Usenet article isn't trivial.  First off, you
> must check manually if it is benign, which takes time.  Next, often
> also done manually, you must see if it has a reasonable chance to
> run in your environment.  If both answers are yes, you'll have to
> cut-and-paste it into an executable file and usually make some
> adjustments.  *Then* you run it and interpret the results.
Or, if your newsreader supports it, and if the original post is well
formatted, you can pipe the article through perl -x.
-- 
#!/usr/bin/perl -p
BEGIN { *ARGV=*DATA }
__END__
Just another Perl hacker,
------------------------------
Date: 21 Feb 2001 15:03:21 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Is this a bug? Can someone explain?
Message-Id: <970lbp$h9n$1@mamenchi.zrz.TU-Berlin.DE>
According to Rafael Garcia-Suarez <rgarciasuarez@free.fr>:
> Anno Siegel wrote in comp.lang.perl.misc:
> >
> > Running code from a Usenet article isn't trivial.  First off, you
> > must check manually if it is benign, which takes time.  Next, often
> > also done manually, you must see if it has a reasonable chance to
> > run in your environment.  If both answers are yes, you'll have to
> > cut-and-paste it into an executable file and usually make some
> > adjustments.  *Then* you run it and interpret the results.
> 
> Or, if your newsreader supports it, and if the original post is well
> formatted, you can pipe the article through perl -x.
Yes, but that are exceptionally well-prepared postings (not that it's
that hard).  It also requires the code to be as portable as possible.
We don't get many of those.
Anno
------------------------------
Date: Wed, 21 Feb 2001 15:30:40 GMT
From: trammell@bayazid.hypersloth.net (John Joseph Trammell)
Subject: Re: Is this a bug? Can someone explain?
Message-Id: <slrn997lkk.8dk.trammell@bayazid.hypersloth.net>
On Wed, 21 Feb 2001 13:34:16 +0100, <dev@trahojen.REMOVETHIS.com> wrote:
[snip]
>   foreach(@$ref1)
>   {
>     $t_val = $_;
>     foreach(@$ref2)
>     {
>       push(@list, $_) if /^$t_val$/i;
>     }
>   }
Looping is an inefficient way to handle this.  How about a
lookup table?
  my %lookup;
  for (@$ref1) { $lookup{"\L$_"}++ } # convert to lowercase
  for (@$ref2) { push @list, $_ if $lookup{"\L$_"} }
This is also addressed in Perl FAQ #4:
  http://www.perldoc.com/perl5.6/pod/perlfaq4.html
------------------------------
Date: Wed, 21 Feb 2001 16:43:38 +0100
From: "Trahojen" <dev@trahojen.REMOVETHIS.com>
Subject: Re: Is this a bug? Can someone explain?
Message-Id: <hnRk6.3434$hi2.9906@nntpserver.swip.net>
Hey, relax guys. I'm sorry if someone was offended by my post.
If there had been any code porting problems worth considering I wouldn't
have bothered posting it.
If the "not intended results" were exceptions or violations I'd have said
that. The script runs *fine*, it just doesn't give the intended result. I
provided the test program I was using myself to illustrate the oddity I was
experiencing.
Stop the wining about it, I'm the one who should be offended, because here I
ask a simple question due to a simple (somewhat annoying) mistake, and is
taken as lamer by default.
The mistake was obvious, but as most obvious things it doesn't occur obvious
until someone points that out.
As I said, too much regex'ing. Too much work.
It's not as if it's a very frequent remark, this.
But Thank You for helping me. It's solved now, I don't have to worry about
it anymore.
regards,
- Samuel [dev@trahojen.REMOVETHIS.com]
------------------------------
Date: Wed, 21 Feb 2001 18:17:42 GMT
From: Darren Dunham <ddunham@redwood.taos.com>
Subject: Re: Is this taint example correct?
Message-Id: <aDTk6.97108$Wq1.40232487@nnrp5-w.sbc.net>
Michael Fuhr <mfuhr@dimensional.com> wrote:
> Darren Dunham <ddunham@redwood.taos.com> writes:
>> % perl -wT -e 'system {"/bin/echo"} "Arg0", "Arg1";'
>> Insecure $ENV{PATH} while running with -T switch at -e line 1.
>> % perl -wT -e 'system {"/bin/echo"} "/Arg0", "Arg1";'
>> Arg1
>>
>> So even though the first element of the LIST to system is not executed
>> or operated upon, it looks to me like it still has to pass the "relative
>> path" test.
>>
>> Is this a bug?
>>
>> I'm using 5.005_03.
> I'd guess that because the program receives the first element as
> argv[0], that argument needs to pass the path test.  The called program
> might use argv[0] to exec itself under certain circumstances such as
> a configuration change (sendmail does this, for example) -- if argv[0]
> weren't taint-clean, you could have a security problem.
> Just a guess.
Sure.  I have no problem with that.  But in this case argv[0] *is* taint
clean (it came from static text in the script).  It is somehow proposing
that argv[0] will be used to later call some program in the PATH
directly, or the leading '/' wouldn't untaint it.
I disagree with this assesment.  
In the particular script I'm writing, I can work around this pretty
easily, but it still confused me.  
-- 
Darren Dunham                                           ddunham@taos.com
Unix System Administrator                    Taos - The SysAdmin Company
Got some Dr Pepper?                           San Francisco, CA bay area
      < Please move on, ...nothing to see here,  please disperse >
------------------------------
Date: Wed, 21 Feb 2001 12:17:01 -0500
From: mbb <michael.beardsley@dartmouth.edu>
Subject: Re: MacPerl help for a newbie
Message-Id: <B6B9623D.4108%michael.beardsley@dartmouth.edu>
Here's the crux of the trouble.  I need to provide these worksheet files on
win2k machines that do NOT have Excel on them.  Microsoft provides a free
Excel viewer that can act as either a stand-alone app or as a web browser
plug-in.
All these worksheet files are named with a string of 5 numbers and then the
extension.  The string of numbers doesn't mean anything to a user so I was
planning on creating a simple HTML page with the descriptive titles for the
worksheets as hyperlinks to the file.  Excel viewer would load and everyone
would be happy.
Excel viewer doesn't like *.wk1 files.  So, I was hoping that Perl, VBA,
AppleScript or something could take all the files in a directory and convert
them to *.xls in one fell swoop.
This problem is going to be annual for me (as the data is provided in this
form from the vendor) so I was hoping for an elegant solution rather than
using my workstudy student's time to do "Save As" for 400 some files.
Thanks again for the ideas!  I'll see if I can figure out how to trick Excel
viewer into associating to *.wk1 files.
Mike
in article 90069t8hck5soqf58hg91rjf65g70i7nn3@4ax.com, Bart Lateur at
bart.lateur@skynet.be wrote on 2/20/01 6:40 PM:
> mbb wrote:
> 
>> I have a number of folders containing *.wk1 files (old Lotus 123 format)
>> that I need to convert to MS Excel *.xls format.
> 
>> I can't figure out how to ask it
>> to rename all the file's last 3 characters to "xls".
> 
> Actually, .WK1 files and .XLS files are not the same format. So simply
> changing creator and file type, and extension, is cheating. I don't care
> about the creator, but you'd better leave the other properties alone.
> For Windows, all you need to do is associate the file extension .WK1
> with Excel.
> 
> I'd be surprised if Excel didn't do that by default, when installing. It
> would be very µ-softish.
------------------------------
Date: 21 Feb 2001 14:03:47 +0000
From: nobull@mail.com
Subject: Re: Need help creating a simple class.
Message-Id: <u94rxo3zgc.fsf@wcl-l.bham.ac.uk>
Craig Manley <c.manley@chello.nl> writes:
> egwong@netcom.com wrote:
> > 
> > Craig Manley <c.manley@chello.nl> wrote:
> > > I read the perltoot but it doesn't explain how to access class variables
> > > as in my example.
I assume you mean 'instance' not 'class'.
Why should it?  There's nothing different in tie()ing a varable that
happens to be an instance variable from tie()ing any other variable.
Why should perltoot say anything about it?
> > > I don't want to use accessor methods, but a sort
> > > of $dude->{'age'} = 10; thingy just as in the DBI when you say
> > > $dbh->{AutoCommit} = 1; Setting $dbh->{AutoCommit} in the DBI causes
> > > multiple statements to be executed instead of just setting a class
> > > variable.
> > 
> > Please put your replies *underneath* the quoted text -- it makes
> > it easier for people to follow.
> > 
> > My guess is that you want to read up on tie-ing a hash in perltie.
Actually in this case tie()ing scalars is probably more relevant if
only a few elements of the hash need to be magical.  There are also
more complex solutions using tied hashes.
> I've already read perltoot, perltie, perloo, the DBI source, and tried
> expermenting writing a simple class but couldn't get it right.
There is a typo in line 17.
> That's when I posted my first question. So I guess I'm still stuck
> where I was then. I was just hoping somebody could quickly put me on
> the right track with a short example.
The problem is that your question is fundamentally not simple, in that
it consists of two separate (simple) sub-problems: objects and tied
variables.
The _simple_ approach is to use accessor methods:
$dude->age(10); # Store age attribute 
print $dude->age(); # Fetch age attribute
But you say you don't want to use accessor methods.  What you really
mean is you want to dress up the accessor methods in syntactic sugar
so that you can do the same apparently by simply accessing elements of
the hash %$dude.
Try something like:
#!/usr/bin/perl
use warnings;
use strict;
package Tie::Scalar::Property;
sub TIESCALAR { bless [ @_[1,2] ], $_[0] }
sub FETCH { $_[0][0]->${\$_[0][1]}() }
sub STORE { $_[0][0]->${\$_[0][1]}( $_[1] ) }
sub make {
    my $class = shift;
    my $object = shift;
    tie $object->{$_}, $class, $object, $_
	for @_;
}  
package FOO;
sub new {
    my $class = shift;
    my $self = bless {}, $class;
    Tie::Scalar::Property->make($self => qw( Bar ));
    $self;
}
sub Bar {
    my $self = shift;
    if ( my ($value) = @_ ) {
	print "Set Bar to $value\n";
	$self->{Internals}{Bar} = $value;
    } else {
	print "Fetch Bar\n";
	$self->{Internals}{Bar};
    }
}
package main;
my $foo = FOO->new;
# Explict accessor method interface
$foo->Bar(1);
print $foo->Bar,"\n";
# Property interface
$foo->{Bar} = 2;
print "$foo->{Bar}\n";
__END__
-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\
------------------------------
Date: Wed, 21 Feb 2001 14:46:13 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: Print a page of HTML
Message-Id: <slrn997l4m.aso.rgarciasuarez@rafael.kazibao.net>
Sereno Barr-Kumar wrote in comp.lang.perl.misc:
> How could I print a HTML formatted page to a printeer
> using perl or any other method.
> 
> Is this possible,  I imagine some browser emulation
> of the page needs to be done before it is sent to
> the printer.
Yes, I imagine that a good way to do this is to convert the page to
postscript. I don't know if there are perl modules on CPAN that perform
this conversion -- you'll have to search (http://search.cpan.com/).
There is probably some software somewhere on the web that perform this
conversion, and that are callable from the command-line (and
consequently from Perl). Sorry, I can't help more...
-- 
Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/
------------------------------
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 V10 Issue 327
**************************************