[13179] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 589 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Aug 19 13:12:56 1999

Date: Thu, 19 Aug 1999 10:10:16 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Thu, 19 Aug 1999     Volume: 9 Number: 589

Today's topics:
        regular expressions in Perl and Oracle/SQL <Philippe.Emeriau@infineon.com>
    Re: regular expressions in Perl and Oracle/SQL (SZEKERES Istvan)
    Re: regular expressions in Perl and Oracle/SQL <prochak@my-deja.com>
        Spec'ing software <kj0@mailcity.com>
    Re: Spec'ing software <bivey@teamdev.com>
        System call from with an oracle perl cartridge poocus@my-deja.com
        system or exec???  Many defunct processes... <jethridgeNOseSPAM@netscape.net>
        system or exec???  Many defunct processes... <jethridgeNOlySPAM@netscape.net>
    Re: Untainting and Safe Pipe Opens for reading <rootbeer@redcat.com>
    Re: Wacky Programming Tales (elephant)
    Re: Will program in exchange for... <toby@venice.cas.utk.edu>
    Re: Win32::OLE + Word/Excel (Michel Dalle)
        Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Thu, 19 Aug 1999 17:06:35 +0200
From: Philippe Emeriau <Philippe.Emeriau@infineon.com>
Subject: regular expressions in Perl and Oracle/SQL
Message-Id: <37BC1D7B.3F854DDB@infineon.com>

Hi *,

I would like to know if there is somewhere in Perl a function that
computes a regular expression and gives the result stored inside a
string ?
Example : the regexp is "foo[1-6]", and I would like to store the result
"foo1 foo2 foo3 foo4 foo5 foo6" in a variable.
Be careful , the regexp can be very more powerful, with |, &&, [, (, ...
supported operators !!!

I know that Perl computes the regular expression internally, but I would
like to keep the result for me, and use it to translate it in an SQL
query (that's why I need the long string, that can be cut in different
substrings to create the SQL query)

Thanks in advance for any help or information
Cheers

Philippe

Philippe EMERIAU
Senior Software Engineer
Infineon Technologies Sophia Antipolis
Gaïa, 2600 Route des Crêtes
F-06560 Sophia Antipolis – FRANCE
WARNING : NEW EMAIL !!!
Email: Philippe.Emeriau@infineon.com
Tel: (+33)(0)4 92 38 37 21
Fax: (+33)(0)4 92 38 37 99




------------------------------

Date: 19 Aug 1999 18:54:43 GMT
From: szekeres@sysdata.siemens.hu (SZEKERES Istvan)
Subject: Re: regular expressions in Perl and Oracle/SQL
Message-Id: <slrn7ro94i.75b.szekeres@pc0504sd.sysdata.siemens.hu>

In article <37BC1D7B.3F854DDB@infineon.com>, Philippe Emeriau wrote:
>I would like to know if there is somewhere in Perl a function that
>computes a regular expression and gives the result stored inside a
>string ?
>Example : the regexp is "foo[1-6]", and I would like to store the result
>"foo1 foo2 foo3 foo4 foo5 foo6" in a variable.

Tell me please what value do you expect for the regexp "a.*b" :-)


Pista


------------------------------

Date: Thu, 19 Aug 1999 16:52:27 GMT
From: Ed Prochak <prochak@my-deja.com>
To: Philippe Emeriau <Philippe.Emeriau@infineon.com>
Subject: Re: regular expressions in Perl and Oracle/SQL
Message-Id: <7phco4$4ol$1@nnrp1.deja.com>

In article <37BC1D7B.3F854DDB@infineon.com>,
  Philippe Emeriau <Philippe.Emeriau@infineon.com> wrote:
> Hi *,
>
> I would like to know if there is somewhere in Perl a function that
> computes a regular expression and gives the result stored inside a
> string ?
> Example : the regexp is "foo[1-6]", and I would like to store the
result
> "foo1 foo2 foo3 foo4 foo5 foo6" in a variable.
> Be careful , the regexp can be very more powerful, with |, &&, [, (,
 ...
> supported operators !!!
>
> I know that Perl computes the regular expression internally, but I
would
> like to keep the result for me, and use it to translate it in an SQL
> query (that's why I need the long string, that can be cut in different
> substrings to create the SQL query)
>
> Thanks in advance for any help or information
> Cheers
>
> Philippe
>
> Philippe EMERIAU
> Senior Software Engineer
> Infineon Technologies Sophia Antipolis
> Gaïa, 2600 Route des Crêtes
> F-06560 Sophia Antipolis – FRANCE
> WARNING : NEW EMAIL !!!
> Email: Philippe.Emeriau@infineon.com
> Tel: (+33)(0)4 92 38 37 21
> Fax: (+33)(0)4 92 38 37 99
>
>

Sorry, but PERL does NOT generate all possibilities from the
expression. If you want to use something as powerful as PERL's regular
expressions, why not use PERL? You can query the database for the key
fields, parse them in PERL, create a new query (or set of queries) from
the parsed key list and get your results. Alternately you could use
Pro*C in a similar manner.

The approach you suggest doesn't work. (as already pointed out by
another poster). What you want is code which: given a regular
experssion, generates the finite state machine that recognizes that
pattern. You then call the generated routine with a string and the
routine returns TRUE or FALSE whether the string fits the pattern.

So you may have to rethink your problem. What are you really try to do?


--
Ed Prochak
Magic Interface, Ltd.
ORACLE services
440-498-3702


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


------------------------------

Date: 19 Aug 1999 15:27:52 GMT
From: kj0 <kj0@mailcity.com>
Subject: Spec'ing software
Message-Id: <7ph7po$hsm$1@news.panix.com>




[Though this is a general software engineering question, I post it in
comp.lang.misc since most of my programming is in Perl, and I'd
therefore I'd prefer to learn the opinions of those with an outlook
more congenial to the Perl community than to, say, the IBM community.
I also think the answer would be of interest to many of the readers of
comp.lang.perl.misc.]


Help!  The size of the projects that we (I and my associates) are
taking on is growing, and we're finding our old seat-of-the-pants
programming style inadequate.  I think we've reached the stage (gasp)
at which we have to include some degree of formal design and source
code specification (I'm not even sure I'm using these words right) in
our work.  Can anyone suggest a good (cook)book on the subject of
*drafting* source code specifications for large (largish) software
projects?

Thanks for your advice,

KJ


------------------------------

Date: 19 Aug 1999 15:56:55 GMT
From: "William" <bivey@teamdev.com>
Subject: Re: Spec'ing software
Message-Id: <01beea5b$2bfd59e0$583c08cf@bill.jump.net>

kj0 <kj0@mailcity.com> wrote in article <7ph7po$hsm$1@news.panix.com>...
 
> Help!  The size of the projects that we (I and my associates) are
> taking on is growing, and we're finding our old seat-of-the-pants
> programming style inadequate.  I think we've reached the stage (gasp)
> at which we have to include some degree of formal design and source
> code specification (I'm not even sure I'm using these words right) in
> our work.  Can anyone suggest a good (cook)book on the subject of
> *drafting* source code specifications for large (largish) software
> projects?


Check out "Debugging the Development Process" and
"Rapid Development" (both are from Microsoft Press,
I believe). There are other books from MP that might
be helpful as well.

You might also want to take a peek at NASA's Software
Engineering Lab - http://sel.gsfc.nasa.gov/ - they
have some interesting stuff.-Wm


------------------------------

Date: Thu, 19 Aug 1999 16:08:40 GMT
From: poocus@my-deja.com
Subject: System call from with an oracle perl cartridge
Message-Id: <7pha5t$2f2$1@nnrp1.deja.com>

I am working on a piece of code that needs to make a system call, but
the command 'system' will not work and is probably due to the fact that
it is being invoked from within the oracle perl cartridge, does anybody
know of a fix or workaround for this problem?


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


------------------------------

Date: Thu, 19 Aug 1999 07:58:09 -0700
From: jethridge <jethridgeNOseSPAM@netscape.net>
Subject: system or exec???  Many defunct processes...
Message-Id: <000b8d9b.c2ea257b@usw-ex0102-009.remarq.com>

I have written a perl script that forks several processes 
based on information I pull out of an oracle database ( I 
use the DBI module to get a list of "jobs" to run and 
perform many actions on these "jobs" within my script.)  
Based on the number of "jobs" I retrieve from the database, 
the number of processes I fork can become rather large.  I 
have minimized the number of processes by putting in a 
MAXPROCESS variable that will limit the number of "jobs" I 
work on at any given iteration.  Here is a quick and dirty 
process description without getting into details:

1.  Query Oracle for a list of "jobs" to process.
2.  Get a job from the list.
3.  Perform action 1 on job.
4.  Perform action 2 on job.
5.  Perform action 3 on job.
6.  Increment counter.
7.  is counter == MAXPROCESS? 
     Yes  -  sleep for a while to let 3, 4, and 5 finish up, 
then go back to 1.
	  NO   -  go to 2.



Here is a code snippet of the piece that will spawn the 
"actions."

##  Spawn external processes to handle:
##            Autocompare,  ( an ART*Enterprise application 
using a perl wrapper. )
##            Statistic Compare, ( perl Script - uses CGI, 
DBI.  This script is accessible through
                                   the command line or web 
browser.)
##            Tolerances and Threshold updates. ( perl 
script -  uses DBI )
unless ( fork() ) {
  exec( "$autocompare_cmd" ) && die "Cannot execute 
$autocompare_cmd  ERROR:$!";
}
$stat_compare_cmd = "$STATCOMPARE job_id=$job_id dsn=$dsn 
cycle=$cycle drpt=$drpt";
unless ( fork() ) {
  exec( "$stat_compare_cmd" ) && die "Cannot execute 
$stat_compare_cmd  ERROR:$!";
}
$update_tt_cmd = "$UPDATE_TT -j $job_id";
unless ( fork() ) {
  exec( "$update_tt_cmd" ) && die "Cannot execute 
$update_tt_cmd ERROR: $!\n";
}
##  If we made it to here, an autocompare is taking place.
SetStatus( $job_id, "A" );


My problem is whenever I fork all of these processes, I end 
up with a bunch of zombie processes that will not go away 
until the parent process is killed off.

I was under the impression that exec() will execute a 
process and then "go away", so whenever I fork a child (no 
pun intended) the child process should execute and disappear 
whenever it is finished.  I have tried using system() in 
place of exec() in the above example, but I end up with many 
child processes which are copies of the original process 
running and my parent process dies almost immediately.

These programs are running on a Sun E10000 with 24 cpus, 
gigs and gigs of memory, and 2 terabytes of disk storage.  
Whenever I kick this script off, I can end up with 80 or 90 
defunct processes.  Since these defunct processes will not 
go away, I soon run out of processes.  My parent process 
will then puke.

Is there any way I can minimize the number of defunct 
processes here?

Jay Ethridge


* Sent from RemarQ http://www.remarq.com The Internet's Discussion Network *
The fastest and easiest way to search and participate in Usenet - Free!



------------------------------

Date: Thu, 19 Aug 1999 08:15:44 -0700
From: jethridge <jethridgeNOlySPAM@netscape.net>
Subject: system or exec???  Many defunct processes...
Message-Id: <0a0133f8.c78012a6@usw-ex0102-009.remarq.com>

Wow, I did not realize that remarq would butcher my code 
snippet so badly.  I really do know how to indent and 
comment my code!!!!!  I guess I will have to try a different 
news service...


* Sent from RemarQ http://www.remarq.com The Internet's Discussion Network *
The fastest and easiest way to search and participate in Usenet - Free!



------------------------------

Date: Thu, 19 Aug 1999 09:03:44 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Untainting and Safe Pipe Opens for reading
Message-Id: <Pine.GSO.4.10.9908190855250.17303-100000@user2.teleport.com>

On Thu, 19 Aug 1999, Bill Moseley wrote:

> I'm running a program with open( PIPE, "$command_line|" ) which -T
> checks don't like, of course.

Why "of course"? Taint checking doesn't prevent pipe opens in general, but
it will keep you from making some foolish mistakes.

> 2) exec() is the only way to run an external program without running 
> through the shell, which is considered dangerous.

It's one way, not the only way.

> Am I thinking clearly?

Probably not. :-)  If a piped open would do the task, you should probably
use that. Properly and securely, of course.

> (Is is faster to spawn a child and exec than run through the shell?)

Yes, it should be. After all, you have to fork and exec a shell which then
forks and execs another process, so that's more overhead.

> And in the perlipc manpage, there's the line:
> 
>    ($EUID, $EGID) = ($UID, $GID); # suid only
> 
> What does that do for me security wise?  If the parent is running suid
> does that make the kid run NOT suid?

Yes, _IF_ you're doing it right and the kernel allows it. You can check
the values of those variables after the assignment to see whether it
"took".

> Is there another way to untaint the open( PIPE, "$command|")?

Didn't you do as perlsec said?

If $command has tainted data, you have to read perlsec and make sure that
you know it's safe when you extract the untainted data from it. But don't
miss the discussion of environment vars, especially $ENV{PATH}, in
perlsec.

Good luck with it!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



------------------------------

Date: Fri, 20 Aug 1999 02:07:35 +1000
From: elephant@squirrelgroup.com (elephant)
Subject: Re: Wacky Programming Tales
Message-Id: <MPG.1226d6d63a058d69989c5c@news-server>

Mark W. Schumann writes ..
>In article <37b62939@cs.colorado.edu>,
>Tom Christiansen  <tchrist@mox.perl.com> wrote:
>>Gosh yes.  I think it was the rogue source that had something like:
>>
>>    #define until(expr) while(!expr)
>>    #define otherwise   break; default:
>>
>>I don't remember whether it also had these, but I have
>>seen them elsewhere:
>>
>>    #define forever()  for(;;)
>>    #define unless(expr) if(!expr)
>
>I've seen
>
>#define ARBEGIN {
>#define AREND   }

in his section on Privacy in "Advanced Perl Programming" Sriram 
Srinivasan mentions (as a counterexample to syntactically enforced 
privacy) seeing the following in some C++ code just before a header file 
was included

  #define private public

there must be something wrong with me .. because I'd never thought of 
that

-- 
 jason - elephant@squirrelgroup.com -


------------------------------

Date: Thu, 19 Aug 1999 11:16:26 -0400
From: toby <toby@venice.cas.utk.edu>
Subject: Re: Will program in exchange for...
Message-Id: <37BC1FCA.A0A8A9D0@venice.cas.utk.edu>



400 Meg Hosting wrote:

> Hi All,
>    I'll do:
> Web Development:
>  Web Design
>  Graphics Design
>  Perl Programming (CGI stuff)
>
> Or VB Programming for you.
>

Actually, I am looking for someone to pour a concrete floor in my basement. I'll
trade an old Amiga for the work.

T.



------------------------------

Date: Thu, 19 Aug 1999 16:19:02 GMT
From: michel.dalle@usa.net (Michel Dalle)
Subject: Re: Win32::OLE + Word/Excel
Message-Id: <7phaue$8s8$1@news.mch.sbs.de>

In article <32zSYAAKawu3EwQN@beausys.freeserve.co.uk>, Andrew Fry <andrewf@beausys.freeserve.co.uk> wrote:
>Anyone know to use WIn32::OLE to...
>1. Determine how many lines are in a Word document,
>   and then read these lines ?
>2. Determine how many rows/cols are occupied in an
>   Excel document, and then read the cells ?
>   (Actually, I think I know how to read the cells...).
>
>I've been reading the ActivePerl documentation, but it
>doesnt go very far. Very few examples about.

Well, I'd suggest you re-read the following ActivePerl FAQ :
"Using OLE with Perl".

The following topics are quite interesting :
        - How do I convert a VBA macro to Perl?
        - Where do I find documentation for the object models?

So, have you tried opening Word/Excel and do what you want in
a VBA macro to see what it looks like ? Why not ?
After all, you are manipulating Word and/or Excel here, not Perl.

For example, Word works with documents, content, ranges,
paragraphs, etc. It's all in the Word helpfile :-)

Have fun,

Michel.


------------------------------

Date: 1 Jul 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 1 Jul 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.  

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" from
almanac@ruby.oce.orst.edu. The real FAQ, as it appeared last in the
newsgroup, can be retrieved with the request "send perl-users FAQ" from
almanac@ruby.oce.orst.edu. 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" from
almanac@ruby.oce.orst.edu. 

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V9 Issue 589
*************************************


home help back first fref pref prev next nref lref last post