[25716] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 7956 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Apr 8 21:05:40 2005

Date: Fri, 8 Apr 2005 18:05:10 -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           Fri, 8 Apr 2005     Volume: 10 Number: 7956

Today's topics:
    Re: FAQ 3.5 How do I debug my Perl programs? <hendrik_maryns@despammed.com>
        finding the first match in a string size14feet@gmail.com
    Re: Help with regular expression <skuo@psi.nsc.com>
    Re: Help with regular expression <someone@example.com>
        Log in Rakuten <noone@nowhere.com>
    Re: Not able to connect to oracle db using DBI ( Active <glex_nospam@qwest.invalid>
    Re: param verification: is a handle? <skuo@psi.nsc.com>
    Re: param verification: is a handle? <a-sicken@web.de>
    Re: Perl function for negative integers using the 2's c <liam@nedernet.net>
    Re: Perl on TRIPOD hosted sites..file uploading questio <wdflannery@aol.com>
    Re: Perl on TRIPOD hosted sites..file uploading questio <segraves_f13@mindspring.com>
    Re: Q: // and "magic" xhoster@gmail.com
        Start a program and get a hold of it's STDOUT and STDIN <snail@localhost.com>
    Re: Start a program and get a hold of it's STDOUT and S <someone@example.com>
    Re: Start a program and get a hold of it's STDOUT and S (Anno Siegel)
    Re: Start a program and get a hold of it's STDOUT and S axel@white-eagle.invalid.uk
    Re: thread priority xhoster@gmail.com
    Re: thread priority <yyusenet@yahoo.com>
    Re: Windows fork emulation (and buffering?) problem <henry.townsend@not.here>
    Re: Windows fork emulation (and buffering?) problem <1usa@llenroc.ude.invalid>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Fri, 08 Apr 2005 19:58:15 +0200
From: Hendrik Maryns <hendrik_maryns@despammed.com>
Subject: Re: FAQ 3.5 How do I debug my Perl programs?
Message-Id: <1112983116.655937@seven.kulnet.kuleuven.ac.be>

PerlFAQ Server schreef:
> 
> 3.5: How do I debug my Perl programs?
> 
>     Have you tried "use warnings" or used "-w"? They enable warnings to
>     detect dubious practices.
> 
>     Have you tried "use strict"? It prevents you from using symbolic
>     references, makes you predeclare any subroutines that you call as bare
>     words, and (probably most importantly) forces you to predeclare your
>     variables with "my", "our", or "use vars".
> 
>     Did you check the return values of each and every system call? The
>     operating system (and thus Perl) tells you whether they worked, and if
>     not why.
> 
>       open(FH, "> /etc/cantwrite")
>         or die "Couldn't write to /etc/cantwrite: $!\n";

In the light of recent posts about the three-argument form of open, 
shouldn't this now be
        open(FH, ">", "/etc/cantwrite")
          or die "Couldn't write to /etc/cantwrite: $!\n";

>     Did you read perltrap? It's full of gotchas for old and new Perl
>     programmers and even has sections for those of you who are upgrading
>     from languages like *awk* and *C*.
> 
>     Have you tried the Perl debugger, described in perldebug? You can step
>     through your program and see what it's doing and thus work out why what
>     it's doing isn't what it should be doing.
> 
> 
> 


-- 
Hendrik Maryns

Interesting websites:
www.lieverleven.be	(I cooperate)
www.eu04.com		European Referendum Campaign
aouw.org		The Art Of Urban Warfare


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

Date: 8 Apr 2005 17:18:53 -0700
From: size14feet@gmail.com
Subject: finding the first match in a string
Message-Id: <1113005932.958796.39010@g14g2000cwa.googlegroups.com>

must simple way to do this...

I have a string.      I have several patterns to match for.   I'd like
to determine which pattern finds a match in the string first & at what
position.

Anyone have an elegant way to do this?  I don't mind using a CPAN
module, if need be.


much appreciated-
matt



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

Date: Fri, 8 Apr 2005 10:07:11 -0700
From: Steven Kuo <skuo@psi.nsc.com>
Subject: Re: Help with regular expression
Message-Id: <Pine.LNX.4.60.0504080956290.25605@psi.nsc.com>

On Fri, 8 Apr 2005, Anno Siegel wrote:

> Steven Kuo  <skuo@mtwhitney.nsc.com> wrote in comp.lang.perl.misc:
>> On 7 Apr 2005 soup_or_power@yahoo.com wrote:
>>
>>> I need help with this regex. It looks the keys of fdat are searched for
>>> "$prefix" and fdat hash is deleted. I have no idea what the map is
>>> trying to do. Thanks for your help.
>>>
>>>  debug my %indices  = map { (/^\Q$prefix.\E(.+)/), $_ } grep { delete
>>> $fdat{$_} } grep /^\Q$prefix.\E/, keys %fdat;
>>
>>
>>
>> That's likely to be wrong as 'map' may return an odd number of elements
>
> How?  The first grep (chronologically, so textually the last one) makes
> sure that /^\Q$prefix.\E/ will always match, so the map block will
> always return exactly two elements.
>
> I agree that the operation could be better written.
>




The problem is subtle.  However there is a string that will 
pass through the grep "filter" pattern but fail to match the 
map "key generation" pattern.  In particular, this string:

     $prefix . '.';

The failed match in list context does not return a empty string
but instead omits an element.

One can see this more clearly if we return the output to an
array:

use Data::Dumper;

my $prefix = 'foo';
my @count_items =
     map { (/^\Q$prefix.\E(.+)/), $_ }
     grep /^\Q$prefix.\E/,
     (
 	$prefix . '.',
 	$prefix . '.something else'
     );

print Dumper \@count_items;

$VAR1 = [
           'foo.',
 	  'something else',
 	  'foo.something else'
 	];

There are an odd number of elements!  Worse is that perl will,
without warnings enabled, tacitly accept this and construct a hash
with corrupted data:

my %bad_results =
     map { (/^\Q$prefix.\E(.+)/), $_ }
     grep /^\Q$prefix.\E/,
     (
 	$prefix . '.',
 	$prefix . '.something else'
     );


print Dumper \%bad_results;

$VAR1 = {
           'foo.something else' => undef,
           'foo.' => 'something else'
         };


I'm not the OP, who may be willing to assert that "my data will never
look like that".

The alternative code I proposed, however, does not return an odd
number of elements, regardless of the form of input data.

-- 
Regards,
Steven


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

Date: Fri, 08 Apr 2005 22:13:15 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: Help with regular expression
Message-Id: <%lD5e.10016$yV3.1537@clgrps12>

Steven Kuo wrote:
> On Fri, 8 Apr 2005, Anno Siegel wrote:
> 
>> Steven Kuo  <skuo@mtwhitney.nsc.com> wrote in comp.lang.perl.misc:
>>
>>> On 7 Apr 2005 soup_or_power@yahoo.com wrote:
>>>
>>>> I need help with this regex. It looks the keys of fdat are searched for
>>>> "$prefix" and fdat hash is deleted. I have no idea what the map is
>>>> trying to do. Thanks for your help.
>>>>
>>>>  debug my %indices  = map { (/^\Q$prefix.\E(.+)/), $_ } grep { delete
>>>> $fdat{$_} } grep /^\Q$prefix.\E/, keys %fdat;
>>>
>>> That's likely to be wrong as 'map' may return an odd number of elements
>>
>> How?  The first grep (chronologically, so textually the last one) makes
>> sure that /^\Q$prefix.\E/ will always match, so the map block will
>> always return exactly two elements.
>>
>> I agree that the operation could be better written.
> 
> The problem is subtle.  However there is a string that will pass through 
> the grep "filter" pattern but fail to match the map "key generation" 
> pattern.  In particular, this string:
> 
>     $prefix . '.';
> 
> The failed match in list context does not return a empty string
> but instead omits an element.

That can be "fixed" by adding one character to the original:

my %indices = map { (/^\Q$prefix.\E(.+)/), $_ } grep { delete $fdat{$_} } grep 
/^\Q$prefix.\E./, keys %fdat;


John
-- 
use Perl;
program
fulfillment


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

Date: Fri, 08 Apr 2005 21:49:28 +0200
From: noone <noone@nowhere.com>
Subject: Log in Rakuten
Message-Id: <pan.2005.04.08.19.49.17.372151@nowhere.com>

Hi,

Anyone know how a Perl script can log onto Rakuten?

Here is what I do in my script:


$ua = LWP::UserAgent->new(
			  'agent' => $agent,
			  'cookie_jar' =>  {file => "cookies.txt", autosave => 1, ignore_discard => 1},
			  'requests_redirectable' => ['GET', 'HEAD', 'POST']
			  );

$request = HTTP::Request->new(POST => 'https://grp02.id.rakuten.co.jp/rms/nid/login');
$request->content_type('application/x-www-form-urlencoded');
$request->content('service_id=59&return_url=index.phtml%3F&u=mylogin&p=mypassword&auto_logout=true');
$response = $ua->request($request);
if (!$response->is_success) {
    die $response->status_line;
}


After the $response->content indicates I am logged in, and the cookies
seems to be well set.  But then when I access another url in Rakuten, it
has forgotten I am logged in!  It is of course not the expected behaviour.
 And it is not what happen with Mozilla or Internet Explorer.

Thanks for any help,

David.



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

Date: Fri, 08 Apr 2005 10:40:12 -0500
From: "J. Gleixner" <glex_nospam@qwest.invalid>
Subject: Re: Not able to connect to oracle db using DBI ( Activestate )
Message-Id: <xBx5e.7$jL6.558@news.uswest.net>

debhatta@hotmail.com wrote:
> Hi all,
> 
> I have a script like :
> 
> use strict;
> use DBI;
> my $con;
> $con = DBI->connect("dbi:Oracle:hrdrel","hr","hr") or die "It cannot be
> done";
> 
> When I am running it the error is :
> 
> install_driver(Oracle) failed: Can't locate DBD/Oracle.pm in @INC (@INC
> contain
> : D:/Perl/lib D:/Perl/site/lib .) at (eval 1) line 3.
> Perhaps the DBD::Oracle perl module hasn't been fully installed,
> or perhaps the capitalisation of 'Oracle' isn't right.
> Available drivers: ADO, Chart, DBM, ExampleP, File, ODBC, Proxy,
> Sponge.
>  at example.pl line 7
> 
> Now I am using Activestate perl, and have installed the DBI module
> using PPM. But I am feeling that above error is due to some other
> module missing. Can anyone kindly guide me to the correct one or any
> help on the above issue?

Using a search engine, like Google, may have helped you find the answer 
to your situation much quicker.

See ya


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

Date: Fri, 8 Apr 2005 10:22:38 -0700
From: Steven Kuo <skuo@psi.nsc.com>
Subject: Re: param verification: is a handle?
Message-Id: <Pine.LNX.4.60.0504081020540.25971@psi.nsc.com>

On Fri, 8 Apr 2005, A. Sicken wrote:

> Hello,
>
> I have to handle follwing problem: A class method can be called with an
> argument, which can be
> a) a simple filename
> b) a glob (perls default file handles)
> c) a reference to a glob (IO::Handle object for example)
>
> How do I verify the argument? Or where can I find an example how to do
> it?



The 'openhandle' function in Scalar::Util should do this nicely.

-- 
Hope this helps,
Steven


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

Date: Fri, 08 Apr 2005 21:26:22 +0200
From: "A. Sicken" <a-sicken@web.de>
Subject: Re: param verification: is a handle?
Message-Id: <d36lsu$d25vj$1@hades.rz.uni-saarland.de>

Steven Kuo wrote:

> On Fri, 8 Apr 2005, A. Sicken wrote:
> 
>> Hello,
>>
>> I have to handle follwing problem: A class method can be called with
>> an argument, which can be
>> a) a simple filename
>> b) a glob (perls default file handles)
>> c) a reference to a glob (IO::Handle object for example)
>>
>> How do I verify the argument? Or where can I find an example how to
>> do it?
> 
> 
> 
> The 'openhandle' function in Scalar::Util should do this nicely.
> 

Thank, you - that's it!
AndSi
-- 
PGP-Key: 875F5C96


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

Date: 8 Apr 2005 09:31:52 -0700
From: "stylechief" <liam@nedernet.net>
Subject: Re: Perl function for negative integers using the 2's complement in hex?
Message-Id: <1112977912.753774.130120@o13g2000cwo.googlegroups.com>


Thanks for the help, guys.  It is a 24 bit number I'm working with.



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

Date: 8 Apr 2005 13:14:03 -0700
From: "joesplink" <wdflannery@aol.com>
Subject: Re: Perl on TRIPOD hosted sites..file uploading question..
Message-Id: <1112991243.537636.50250@z14g2000cwz.googlegroups.com>

>>>>.because of the one-second limit imposed by Tripod for
script execution.


Do you know someone at the company?  I.e., just out of curiosity, where
are you getting this info?

Will



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

Date: Fri, 08 Apr 2005 21:38:34 GMT
From: "Bill Segraves" <segraves_f13@mindspring.com>
Subject: Re: Perl on TRIPOD hosted sites..file uploading question..
Message-Id: <uRC5e.2771$sp3.98@newsread3.news.atl.earthlink.net>

"joesplink" <wdflannery@aol.com> wrote in message
news:1112991243.537636.50250@z14g2000cwz.googlegroups.com...
> >>>>.because of the one-second limit imposed by Tripod for
> script execution.
>
>
> Do you know someone at the company?

No.

> I.e., just out of curiosity, where
> are you getting this info?

From the Tripod CGI documentation.
--
Bill Segraves






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

Date: 08 Apr 2005 16:39:11 GMT
From: xhoster@gmail.com
Subject: Re: Q: // and "magic"
Message-Id: <20050408123911.327$fA@newsreader.com>

Joe Smith <joe@inwap.com> wrote:
> xhoster@gmail.com wrote:
>
> >>   If the PATTERN evaluates to the empty string, the last
> >>   *successfully* matched regular expression is used instead. In
> >>   this case, only the "g" and "c" flags on the empty pattern is
> >>   honoured - the other flags are taken from the original pattern.
> >>   If no match has previously succeeded, this will (silently) act
> >>   instead as a genuine empty pattern (which will always match).
> >
> > So, does anyone find this behavior useful?  I've never intentionally
> > used it, and I can't imagine doing so in the future.
>
> That's the way vi works.  (And jove but not emacs.)

My version of vi doesn't work that way.  It uses the most recently
specified search, not the most recently successful search.  (But I just use
'n' when I want to repeat a search, so I could ask the same question
on this vi feature as I did on the Perl one.)

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service                        $9.95/Month 30GB


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

Date: Fri, 8 Apr 2005 15:04:56 -0700
From: "Snail" <snail@localhost.com>
Subject: Start a program and get a hold of it's STDOUT and STDIN?
Message-Id: <d36v1g$ssk$1@news.astound.net>

Hello. I am trying to write a logging program to wrap around a server 
program that we need that doesn't have logging capabilities of it's own. 
Normally, one would just redirect it on the command line:

 ./server 2>&1 logfile.log

But this doesn't have any dating what so ever and it can get hard to 
read as it grows.

My goal is to start the program from my program and get both it's 
STDOUT/ERR and STDIN, that way my program can see live Output as it 
comes in from the server and also respond to certain events (the server 
accepts console commands when it is normally run in the foreground, so 
it can be fully interactive, accepting command via STDIN normally.

I've been search all over (perldoc, google, etc) and all I could find 
was examples of getting STDIN or STDOUT (using pipes) but not both at 
the same time. Further mode, I need this to be in real time (when the 
server spits out something to STDOUT/ERR I want my program to 
immediately get this, and then process it (add a line to the log file, 
perform some processing if a certain event occurs, such has a new 
connection, etc.)

Thank for any help. 




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

Date: Fri, 08 Apr 2005 22:37:44 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: Start a program and get a hold of it's STDOUT and STDIN?
Message-Id: <YID5e.10018$yV3.3180@clgrps12>

Snail wrote:
> Hello. I am trying to write a logging program to wrap around a server 
> program that we need that doesn't have logging capabilities of it's own. 
> Normally, one would just redirect it on the command line:
> 
> ./server 2>&1 logfile.log
> 
> But this doesn't have any dating what so ever and it can get hard to 
> read as it grows.
> 
> My goal is to start the program from my program and get both it's 
> STDOUT/ERR and STDIN, that way my program can see live Output as it 
> comes in from the server and also respond to certain events (the server 
> accepts console commands when it is normally run in the foreground, so 
> it can be fully interactive, accepting command via STDIN normally.
> 
> I've been search all over (perldoc, google, etc) and all I could find 
> was examples of getting STDIN or STDOUT (using pipes) but not both at 
> the same time. Further mode, I need this to be in real time (when the 
> server spits out something to STDOUT/ERR I want my program to 
> immediately get this, and then process it (add a line to the log file, 
> perform some processing if a certain event occurs, such has a new 
> connection, etc.)

perldoc -q STDERR


John
-- 
use Perl;
program
fulfillment


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

Date: 8 Apr 2005 22:38:45 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Start a program and get a hold of it's STDOUT and STDIN?
Message-Id: <d3715l$qm$1@mamenchi.zrz.TU-Berlin.DE>

Snail <snail@localhost.com> wrote in comp.lang.perl.misc:
> Hello. I am trying to write a logging program to wrap around a server 
> program that we need that doesn't have logging capabilities of it's own. 
> Normally, one would just redirect it on the command line:
> 
> ./server 2>&1 logfile.log
> 
> But this doesn't have any dating what so ever and it can get hard to 
> read as it grows.
> 
> My goal is to start the program from my program and get both it's 
> STDOUT/ERR and STDIN, that way my program can see live Output as it 
> comes in from the server and also respond to certain events (the server 
> accepts console commands when it is normally run in the foreground, so 
> it can be fully interactive, accepting command via STDIN normally.
> 
> I've been search all over (perldoc, google, etc) and all I could find 
> was examples of getting STDIN or STDOUT (using pipes) but not both at 
> the same time. Further mode, I need this to be in real time (when the 
> server spits out something to STDOUT/ERR I want my program to 
> immediately get this, and then process it (add a line to the log file, 
> perform some processing if a certain event occurs, such has a new 
> connection, etc.)

perldoc IPC::Open2.  If that doesn't cut it, see Expect.pm on CPAN.

Anno


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

Date: Fri, 08 Apr 2005 19:07:12 -0500
From: axel@white-eagle.invalid.uk
Subject: Re: Start a program and get a hold of it's STDOUT and STDIN?
Message-Id: <1POdnT0VbZYtgcrfRVn-jw@adelphia.com>

Snail <snail@localhost.com> wrote:
> Hello. I am trying to write a logging program to wrap around a server 
> program that we need that doesn't have logging capabilities of it's own. 
> Normally, one would just redirect it on the command line:
 
> ./server 2>&1 logfile.log
 
> But this doesn't have any dating what so ever and it can get hard to 
> read as it grows.
> 
> My goal is to start the program from my program and get both it's 
> STDOUT/ERR and STDIN, that way my program can see live Output as it 
> comes in from the server and also respond to certain events (the server 
> accepts console commands when it is normally run in the foreground, so 
> it can be fully interactive, accepting command via STDIN normally.

Does the wrapper program actually need to process any commands before
they are passed to the server? If not...

	$ ./server 2>&1 | wrapper_prog
 
Axel


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

Date: 08 Apr 2005 16:28:35 GMT
From: xhoster@gmail.com
Subject: Re: thread priority
Message-Id: <20050408122835.940$70@newsreader.com>

cji_work@yahoo.com wrote:
> I agree with both of you, but maybe I should have it specified at the
> first time.
> When I was running the test, I need to see the performance of both the
> Apache and the backend DB. Right now when I increase the number of
> users, I will see the load on the Apache is growing up. But I guess as
> too many users that causes extra requests have been turn down, the load
> on the DB is actually going down.

How are measuring these two loads?

> So the really problem for me is how I can increase the load on web
> server as well as on the DB?

My first thought is "why would I want to?"  If Apache is the rate limiting
step, then optimizing the DB performance isn't going to get you anywhere.
And whatever you do learn about DB performance *now* may no longer be
applicable once Apache is optimized, as then the patterns of usage will
likely be differnt.

But anyway, my second thought is that I'd try to make another test script
which incorporates enough of the code from the web-app into it that it can
bypass apache and go straight to the database.  That way I could verify
whether, once apache is removed as the bottleneck, the database could keep
up.

If that proved hard to do because the database-specific code is too mingled
in with the cgi-specific parts of the code, I would try to deploy a copy of
the web-app to the test server.  Then the load testing script would split
up the cgi work to two different servers, but all of the DB work would
converge back to one server, allowing you to increase the load on the DB
beyond what you could otherwise do.


> I was thinking if somehow I can set the high priority of the first 200
> threads (if it is possible), these transactions are guaranteed. For the
> rest, it may just depends on if there is extra rooms.

I don't know how you can do that, and I also don't see what it would get
you if you could.  You already know that there is no extra room there.


Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service                        $9.95/Month 30GB


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

Date: Fri, 08 Apr 2005 16:18:47 -0600
From: YYUsenet <yyusenet@yahoo.com>
Subject: Re: thread priority
Message-Id: <d3700b$m1m$1@news.xmission.com>

cji_work@yahoo.com wrote:
> I agree with both of you, but maybe I should have it specified at the
> first time.
> When I was running the test, I need to see the performance of both the
> Apache and the backend DB. Right now when I increase the number of
> users, I will see the load on the Apache is growing up. But I guess as
> too many users that causes extra requests have been turn down, the load
> on the DB is actually going down.
> 
> So the really problem for me is how I can increase the load on web
> server as well as on the DB?
> 
> I was thinking if somehow I can set the high priority of the first 200
> threads (if it is possible), these transactions are guaranteed. For the
> rest, it may just depends on if there is extra rooms.
> 
> 
> -CJ

Normally, when a 500 error occurs the request is still processed and 
completed.  However, if you really want to set the priority of the 
different threads, then what are you aiming at?  Do you mean the 
priority in which Apache reads its requests? Because AFAIK that cannot 
be done.


-- 
k g a b e r t (at) x m i s s i o n (dot) c o m

*Use Mozzila/Firefox*!
http://www.spreadfirefox.com/?q=user/register&r=71209


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

Date: Fri, 08 Apr 2005 13:47:24 -0400
From: Henry Townsend <henry.townsend@not.here>
Subject: Re: Windows fork emulation (and buffering?) problem
Message-Id: <IPqdnT2595oxXsvfRVn-1w@comcast.com>

A. Sinan Unur wrote:
> I understand. Now, the question is, are you in control of the system 
> call above? If you are, and you need to process the output of an 
> external program, say cat, you could use backticks to launch it, or open 
> a pipe to it. The former would return all the output, the latter would 
> allow you to process the output of the external command line by line, as 
> in:

Well ... internally we have a LOT of old scripts. I'm hoping to solve 
the problem generically in a module (you could go back just a little 
ways in clpm to a thread called "output-monitoring module" to see what 
I'm trying to achieve) without having to modify the scripts. And of 
course I'd like to come out of it with a module I could contribute back 
too. That's why I'm trying to find an OS-level solution which happens to 
be implemented in Perl rather than a Perl solution.

I could go a bit farther with your idea and override system(), replacing 
it with a sub that uses qx(). But I'm not sure how reliably I could 
capture every method of creating subprocesses that might be in use down 
deep in some script.

-- 
Henry Townsend


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

Date: Fri, 08 Apr 2005 21:29:14 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Windows fork emulation (and buffering?) problem
Message-Id: <Xns9632B1D47CB14asu1cornelledu@127.0.0.1>

Henry Townsend <henry.townsend@not.here> wrote in
news:IPqdnT2595oxXsvfRVn-1w@comcast.com: 

> Well ... internally we have a LOT of old scripts. I'm hoping to solve 
> the problem generically in a module (you could go back just a little 
> ways in clpm to a thread called "output-monitoring module" to see what
> I'm trying to achieve) without having to modify the scripts.

 ...

> I could go a bit farther with your idea and override system(),
> replacing it with a sub that uses qx(). But I'm not sure how reliably
> I could capture every method of creating subprocesses that might be in
> use down deep in some script.

Well, I am probably missing something here, but this is what I would 
have done:

#! /usr/bin/perl
# harness.pl

use strict;
use warnings;

my $oldscript = shift;
$oldscript or die "Please supply the path to script to be run\n";

open my $h, '-|', "perl $oldscript"
    or die "Cannot pipe $oldscript: $!";

while(<$h>) {
    print "FILTERED: $_";
}
__END__

#! /usr/bin/perl
# tada.pl
use strict;
use warnings;

my @commands = (q{cat test.txt}, q{grep use *.pl});

for my $command (@commands) {
   print "Executing $cmd\n";
   system $cmd;
}
__END__

D:\Home> harness tada.pl
FILTERED: Executing cat test.txt
FILTERED: lkdsjflkajdflkn
FILTERED:
FILTERED: safdsdflf;keww;dsf
 ...
FILTERED: Executing grep use *.pl
 ...
FILTERED: z.pl:use Archive::Zip ':ERROR_CODES';
FILTERED: z.pl:use Fcntl ':seek';
FILTERED: z.pl:use File::Temp 'tempfile';

Does this help?

Sinan

-- 
A. Sinan Unur <1usa@llenroc.ude.invalid>
(reverse each component and remove .invalid for email address)

comp.lang.perl.misc guidelines on the WWW:
http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html


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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

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 7956
***************************************


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