[24847] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 6998 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Sep 13 18:06:33 2004

Date: Mon, 13 Sep 2004 15:05:07 -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           Mon, 13 Sep 2004     Volume: 10 Number: 6998

Today's topics:
    Re: better way to parse html <emschwar@pobox.com>
        different behaviour when accessing HD or USB storage (PilotMI80)
        extract a column from 2 dimensional array <ec_au_ravi2000@yahoo.com>
    Re: extract a column from 2 dimensional array <noreply@gunnar.cc>
    Re: extract a column from 2 dimensional array (Anno Siegel)
    Re: Get the index of array element (Anno Siegel)
        Help with 'system' seeming to return too soon... <ajamtgaa@cisco.com>
    Re: Help with 'system' seeming to return too soon... <gifford@umich.edu>
    Re: Help with 'system' seeming to return too soon... <ajamtgaa@cisco.com>
    Re: Help with 'system' seeming to return too soon... <1usa@llenroc.ude.invalid>
    Re: Help with 'system' seeming to return too soon... <ajamtgaa@cisco.com>
    Re: Help with 'system' seeming to return too soon... <gifford@umich.edu>
    Re: Help with 'system' seeming to return too soon... <1usa@llenroc.ude.invalid>
        Help with globbing (Mr. Land)
    Re: Help with globbing <miknrene@drizzle.com>
    Re: hv_iterinit has side effects - who cares about PL t (Ozgun Erdogan)
    Re: hv_iterinit has side effects - who cares about PL t (Ozgun Erdogan)
        killing a "nobody's" process and its group <es@yahoo.fedeabascal>
    Re: killing a "nobody's" process and its group <1usa@llenroc.ude.invalid>
        killing a process using its PID <es@yahoo.fedeabascal>
    Re: killing a process using its PID <es@yahoo.fedeabascal>
    Re: parsing UTF-8 chars out of POST data (Aaron Anodide)
    Re: Recursively copying a directory (gumby)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Mon, 13 Sep 2004 09:55:19 -0600
From: Eric Schwartz <emschwar@pobox.com>
Subject: Re: better way to parse html
Message-Id: <eto7jqymae0.fsf@wilson.emschwar>

Fred <noemail@#$&&!.net> writes:
> On Fri, 10 Sep 2004 23:07:29 -0500, Tad McClellan wrote:
>>    foreach my $i ( 0 .. $#array )  # much easier to understand
>
> I heard at the poker table that foreach's were costly in CPU cycles... I
> always wondered if that was true or not. I guess it wouldn't be much of a
> project to test it but I never have.

perldoc Benchmark

Also, don't forget that you're taking a fairly large performance hit
by using Perl at all-- the difference of a few milliseconds between
for and foreach is hardly worth worrying about, and it will make your
code easier to read, which is a much larger win, relatively speaking.

-=Eric
-- 
Come to think of it, there are already a million monkeys on a million
typewriters, and Usenet is NOTHING like Shakespeare.
		-- Blair Houghton.


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

Date: 13 Sep 2004 07:04:36 -0700
From: pilotmi80@hotmail.com (PilotMI80)
Subject: different behaviour when accessing HD or USB storage
Message-Id: <9b14a223.0409130604.1b11030e@posting.google.com>

Hi all,

When trying to access a USB key with : 

foreach(<$path/*>)
(or any combination of quotes )

it seems nothing is found.
The same actually works if $path is on my hard disk.

So, by now, I replaced this construction with :

  opendir(DH, "$SourceFolder") or die "msg";
  my @FolderContents = readdir DH;
  closedir DH;
  foreach(@FolderContents)

and it works perfectly (on both file systems)

My question is : is there a kind of flush mechanism that I missed ? or
will I have to use the workaround ?
Anyone got this kind of behaviour ?


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

Date: 13 Sep 2004 06:31:21 -0700
From: "ravi" <ec_au_ravi2000@yahoo.com>
Subject: extract a column from 2 dimensional array
Message-Id: <ci47f9$ild@odak26.prod.google.com>

How to pick a column into a seperate 1-D array, from a 2-D array.  Is
there an efficient way to do this or we have to only iterate each
elements



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

Date: Mon, 13 Sep 2004 16:16:30 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: extract a column from 2 dimensional array
Message-Id: <2qlocaFvlmr8U1@uni-berlin.de>

ravi wrote:
> How to pick a column into a seperate 1-D array, from a 2-D array.
> Is there an efficient way to do this or we have to only iterate
> each elements

Illustrate what you mean by posting a simple example.

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl


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

Date: 13 Sep 2004 14:58:09 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: extract a column from 2 dimensional array
Message-Id: <ci4ci1$hhr$1@mamenchi.zrz.TU-Berlin.DE>

ravi <ec_au_ravi2000@yahoo.com> wrote in comp.lang.perl.misc:
> How to pick a column into a seperate 1-D array, from a 2-D array.  Is
> there an efficient way to do this or we have to only iterate each
> elements

Unless your array is stored by columns (the specification "2-D array"
is ambiguous), you will have to loop:

    map $array->[ $_]->[ $column], 0 .. $#array;

Perl 6 will have multidimensional slices, one hears.  Perl 5 doesn't.

Anno


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

Date: 13 Sep 2004 13:09:48 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Get the index of array element
Message-Id: <ci466s$cqc$1@mamenchi.zrz.TU-Berlin.DE>

Bart Lateur  <bart.lateur@pandora.be> wrote in comp.lang.perl.misc:
> Anno Siegel wrote:
> 
> >    my $i = 0;
> >    foreach $element ( @array ) {
> >        # index in $i
> >        $i ++;
> >    }
> 
> If I use that kind of code structure, I always put the last statement in
> a "continue" block, even if it doesn't sever any other particular
> practical  purpose.

On the contrary!  "next" would sever the increment from control flow
if it were otherwise :)

>     my $i = 0;
>     foreach $element ( @array ) {
>         # index in $i
>     } continue {
>         $i ++;
>     }
> 
> At least it'll behave properly if even if at one point you choose to
> insert a "next" statement in there.

Either that, or arrange things so that the increment is the first thing
in the loop.  Sometimes it's "my $i = -1;" for that reason.

Anno


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

Date: Mon, 13 Sep 2004 13:08:06 -0600
From: Arne Jamtgaard <ajamtgaa@cisco.com>
Subject: Help with 'system' seeming to return too soon...
Message-Id: <1095102344.586759@sj-nntpcache-5>

I know system is supposed to wait until the command is done before
returning, but I seem to be seeing a different behavior.

I've got a script that, among other things, needs to source a
file to set a bunch of environment variables before it runs an
install script.  Once the install is complete, the script uses
the installed files to do some more configuration steps.

The behavior that I am seeing is the program seems to be going
on to the second step before the install step has finished
copying the files over.  So it fails, and goes on to step 3,
which also fails, etc.

The file copy step takes quite a while.  Does system have a time
out?

Here's a cut-n-paste of relevant sections of my code:

my @cmd = (
            "cd $v{'buildhome'}/$v{'builddir'} ; ./install.sh $v{'destdir'}
master $v{'owner'} >> /tmp/install.log",
            ". $v{'destdir'}/bin/vpnenv.sh; cd $v{'buildhome'}/$v{'builddir'}/fixes ;
 ./runme.sh >> /tmp/runme.log",
            ". $v{'destdir'}/bin/vpnenv.sh; cd /opt/tests/LicenseStuff ;
 ./license.sh >> /tmp/licenseStuff.log",
           );

foreach $command  (@cmd) {

     logit("Processing command: \"$command\"\n");
     $res = system("$command");

}

Any glaring problems with my code?  Which of my assumptions are way
off base?

Thanks

Arne



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

Date: Mon, 13 Sep 2004 15:27:31 -0400
From: Scott W Gifford <gifford@umich.edu>
Subject: Re: Help with 'system' seeming to return too soon...
Message-Id: <qszy8jex93w.fsf@tetris.gpcc.itd.umich.edu>

Arne Jamtgaard <ajamtgaa@cisco.com> writes:

[...]

> I've got a script that, among other things, needs to source a
> file to set a bunch of environment variables before it runs an
> install script.  Once the install is complete, the script uses
> the installed files to do some more configuration steps.

That's likely to be part of your problem.  Each system() command is
executed in a new process, so when you do system(". file"), it creates
a new process, sets the environment variables in that process, then
that process exits; the environment in your program is unaffected, and
the environment in all future system calls is unaffected.  To fix
this, You can either turn this into one shell command or shell script,
or else parse vpnenv.sh yourself and set %ENV appropriately.

> The file copy step takes quite a while.  Does system have a time
> out?

No.

---ScottG.


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

Date: Mon, 13 Sep 2004 13:45:43 -0600
From: Arne Jamtgaard <ajamtgaa@cisco.com>
Subject: Re: Help with 'system' seeming to return too soon...
Message-Id: <1095104602.50673@sj-nntpcache-5>

Scott W Gifford wrote:

> Arne Jamtgaard <ajamtgaa@cisco.com> writes:
>>I've got a script that, among other things, needs to source a
>>file to set a bunch of environment variables before it runs an
>>install script.  Once the install is complete, the script uses
>>the installed files to do some more configuration steps.

> That's likely to be part of your problem.  Each system() command is
> executed in a new process, so when you do system(". file"), it creates
> a new process, sets the environment variables in that process, then
> that process exits; the environment in your program is unaffected, and
> the environment in all future system calls is unaffected.  To fix
> this, You can either turn this into one shell command or shell script,
> or else parse vpnenv.sh yourself and set %ENV appropriately.

I had hoped by stringing the commands together with semicolons (like
I can on the command line) that I could get around this problem.  So
even though they are all quoted together, 'system' will pull each
command off separately and run them in individual shells?  Dang.

That's why I kept tacking on the source command - one shell per
quoted line, as opposed to one per command.

This has got to be a problem that others have surmounted - how can
you use 'system' to run a command with a bunch of environment
variables already set?

Arne



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

Date: 13 Sep 2004 20:12:22 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Help with 'system' seeming to return too soon...
Message-Id: <Xns9563A4DCD3FEAasu1cornelledu@132.236.56.8>

Arne Jamtgaard <ajamtgaa@cisco.com> wrote in news:1095104602.50673@sj-
nntpcache-5:

> Scott W Gifford wrote:

>> or else parse vpnenv.sh yourself and set %ENV appropriately.

> how can you use 'system' to run a command with a bunch of 
> environment variables already set?

Reading responses helps.

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



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

Date: Mon, 13 Sep 2004 14:41:46 -0600
From: Arne Jamtgaard <ajamtgaa@cisco.com>
Subject: Re: Help with 'system' seeming to return too soon...
Message-Id: <1095108347.96728@sj-nntpcache-3>

A. Sinan Unur wrote:

> Arne Jamtgaard <ajamtgaa@cisco.com> wrote in news:1095104602.50673@sj-
> nntpcache-5:
> 
> 
>>Scott W Gifford wrote:
> 
> 
>>>or else parse vpnenv.sh yourself and set %ENV appropriately.
> 
> 
>>how can you use 'system' to run a command with a bunch of 
>>environment variables already set?
> 
> 
> Reading responses helps.

So to solve this problem I have to parse the vpnenv.sh script to
extract all the environment variables that are being set?  Do you
have a parser that can do that that you'd like to share with me?
(FYI - vpnenv.sh is not simply a bunch of name=value pairs.)

Since neither the install script, nor any of the installed files
are mine, I don't see how the other possibility (turn it all into
one shell script) is a viable option, either.

Sorry if I hadn't made that clear before.

To get back to the main question - why is system returning before
the command is finished?  Does it do the first part of the string,
then return while continuing to run subsequent parts of the string?

Arne



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

Date: Mon, 13 Sep 2004 17:43:23 -0400
From: Scott W Gifford <gifford@umich.edu>
Subject: Re: Help with 'system' seeming to return too soon...
Message-Id: <qsz8ybdyhdw.fsf@tetris.gpcc.itd.umich.edu>

Arne Jamtgaard <ajamtgaa@cisco.com> writes:

> Scott W Gifford wrote:
>
>> Arne Jamtgaard <ajamtgaa@cisco.com> writes:
>>>I've got a script that, among other things, needs to source a
>>>file to set a bunch of environment variables before it runs an
>>>install script.  Once the install is complete, the script uses
>>>the installed files to do some more configuration steps.
>
>> That's likely to be part of your problem.  Each system() command is
>> executed in a new process, so when you do system(". file"), it creates
>> a new process, sets the environment variables in that process, then
>> that process exits; the environment in your program is unaffected, and
>> the environment in all future system calls is unaffected.  To fix
>> this, You can either turn this into one shell command or shell script,
>> or else parse vpnenv.sh yourself and set %ENV appropriately.
>
> I had hoped by stringing the commands together with semicolons (like
> I can on the command line) that I could get around this problem.  So
> even though they are all quoted together, 'system' will pull each
> command off separately and run them in individual shells?  Dang.

Ahh, I see.  No, what you did should work; I somehow didn't notice you
had included the environment variables for each command.  You can
verify this is working by adding something like:

    ; env >/tmp/env.test

and making sure the right variables show up there.

So now you're back to your original problem.  It's possible that
install.sh is doing some things in the background, causing it to
return before those things are done, but that would be a strange thing
for an install script to do.

I think what you'll want to do next is figure out exactly what's going
on.  Why do you think that the second command is running before the
first has completed?  Can you think of something to do to test this
theory, like changing the second command to:

    "echo 'Second script started!'; tail -f /tmp/install.log"

to see if lines are showing up in the log after the first script has
supposedly finished, or seeing what files are in your install
directory when the second command starts:

    "echo 'Second script started!'; find $v{destdir} -ls >/tmp/destdir.find

then seeing if anything has changed later, or even just

    "echo 'Second script started, ps says:'; ps -f"

to see if any unexpected processes are still running.

Do you see anything in install.sh that would indicate that it's
running things in the background (like a & that's not part of a &&)?


Good luck,

----ScottG.


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

Date: 13 Sep 2004 21:49:08 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Help with 'system' seeming to return too soon...
Message-Id: <Xns9563B545113D4asu1cornelledu@132.236.56.8>

Arne Jamtgaard <ajamtgaa@cisco.com> wrote in news:1095108347.96728@sj-
nntpcache-3:

> A. Sinan Unur wrote:
> 
>> Arne Jamtgaard <ajamtgaa@cisco.com> wrote in news:1095104602.50673@sj-
>> nntpcache-5:
>> 
>>>Scott W Gifford wrote:
>> 
>>>>or else parse vpnenv.sh yourself and set %ENV appropriately.
>> 
>> 
>>>how can you use 'system' to run a command with a bunch of 
>>>environment variables already set?
>> 
>> Reading responses helps.
> 
> So to solve this problem I have to parse the vpnenv.sh script to
> extract all the environment variables that are being set?  Do you
> have a parser that can do that that you'd like to share with me?
> (FYI - vpnenv.sh is not simply a bunch of name=value pairs.)

On the other hand, it should not be too hard to write a shell script that 
simply runs vpnenv.sh and then echos the environment. I am typing this on 
an XP machine and I don't know for sure but something like the following 
ought to work

#! /bin/sh
 ./vpnenv.sh
set

you can then parse the output of this mini-script to set %ENV.

I am not sure why system is "returning early" or if that is indeed what's 
happening, but this is an easy thing to try.

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



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

Date: 13 Sep 2004 10:45:38 -0700
From: graftonfot@yahoo.com (Mr. Land)
Subject: Help with globbing
Message-Id: <3a81cd7b.0409130945.55d2cb57@posting.google.com>

Hello.

I've read what I could find on filename globbing and can't seem to get
an answer for the following:

I have  directory containing files like:

	File One.red
	File One.blue
	File One.green3
	File One.Green4
	File One.Gray4
	SecondFile.red
	SecondFile.blue
	SecondFile.green4

I have built an array containing the "basenames" (everything up to but
not including the last ".") of
all files in the directory.  For my example above, my array would
contain 2 elements:

	"File One"
	"SecondFile"

Now, for each such array entry I am trying to get an array of
filenames which match a certain pattern,
that pattern being based on the entry.  For example to get a list of
all files having the basename
and having an extension that begins with either "g" or "G" and ends in
"4":

foreach $basename (@TheArray) {
	
	@fileList = <$basename*[gG]*4>;

This worked as shown for "SecondFile" but failed with "File One" due
to the embedded space.  I tried
various forms of quoting, such as:

	@fileList = <'$basename'*[gG]*4>;

	@fileList = <'$basename*[gG]*4'>;

	@fileList = <"$basename*[gG]*4">;

but none of these seem to handle BOTH cases (with and without embedded
spaces in the basename).

Is there at least one way to do this and what would that look like?

Thanks.


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

Date: Mon, 13 Sep 2004 11:29:57 -0700
From: Michael Slass <miknrene@drizzle.com>
Subject: Re: Help with globbing
Message-Id: <m38ybeauoq.fsf@eric.rossnet.com>

graftonfot@yahoo.com (Mr. Land) writes:

>Hello.
>
>I've read what I could find on filename globbing and can't seem to get
>an answer for the following:
>
>I have  directory containing files like:
>
>	File One.red
>	File One.blue
>	File One.green3
>	File One.Green4
>	File One.Gray4
>	SecondFile.red
>	SecondFile.blue
>	SecondFile.green4
>
>I have built an array containing the "basenames" (everything up to but
>not including the last ".") of
>all files in the directory.  For my example above, my array would
>contain 2 elements:
>
>	"File One"
>	"SecondFile"
>
>Now, for each such array entry I am trying to get an array of
>filenames which match a certain pattern,
>that pattern being based on the entry.  For example to get a list of
>all files having the basename
>and having an extension that begins with either "g" or "G" and ends in
>"4":
>
>foreach $basename (@TheArray) {
>	
>	@fileList = <$basename*[gG]*4>;
>
>This worked as shown for "SecondFile" but failed with "File One" due
>to the embedded space.  I tried
>various forms of quoting, such as:
>
>	@fileList = <'$basename'*[gG]*4>;
>
>	@fileList = <'$basename*[gG]*4'>;
>
>	@fileList = <"$basename*[gG]*4">;
>
>but none of these seem to handle BOTH cases (with and without embedded
>spaces in the basename).
>
>Is there at least one way to do this and what would that look like?
>
>Thanks.

I think you'd have more success using perl's full regular expressions
than with globbing, which is designed to be like the UNIX shells' *
operator, and is a fairly blunt tool.

The canonical perl way to do this is by opening a directory handle,
and then iterating over the files in the directory, processing each
one.

------------------------------ cut here ------------------------------
#!/bin/perl/bin/perl -w
use strict;

my $fileName;
opendir(DIR, "/path/to/directory");

foreach $fileName (readdir DIR)
{
  # match File One.[gG]<anything>4
  if ( $fileName =~ m/File One\.[gG].*4/ ) {
    # do something, like add it to a list for later processing
    # push @someListVar, $fileName
    ;
 # match SecondFile.[bB]
  } elsif ( $fileName =~ m/SecondFile\.[bB]/ ) {
    # do something with this file anem
  }
  # and so on
}

closedir(ETC);
------------------------------ cut here ------------------------------

You should read about dirhandles and regular expressions in the perl
docs:

perldoc -f opendir
perldoc -f readdir
perldoc -f closedir

perldoc perlre
(this last one is the page for how perl regular expressions work, and
it's big)


-- 
Mike Slass


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

Date: 13 Sep 2004 13:06:38 -0700
From: ozgune@gmail.com (Ozgun Erdogan)
Subject: Re: hv_iterinit has side effects - who cares about PL theory
Message-Id: <48b43181.0409131206.26039fc3@posting.google.com>

> I don't believe you.  Show us some real code, and I bet that we can
> show you how it can be done correctly.  Perl programmers read the
> values of a hash all the time without modifying other values in the hash.

What I meant in here is that, the iterator is part of the hash
structure itself. From what gdb shows me, the hash structure in Perl
has RITER and EITER in it that are used for iterating over the hash.

> > 
> > $x = 4;
> > Print $x;
> > (now $x is 10). 
> 
> Yes, that is expected behavior if Print() is explicitly defined to
> alter its arguments.  Like this:

I see your point, but that's not what I meant. What I tried to say is,
I'm doing a variable read, and it's modifying the values (RITER and
EITER) in the hash data structure. So, when you read $x, the value of
$x (maybe not the part of the structure that stores the value 4, but
some other value in the data structure) changes.

> > Take CPAN module Data::Structure::Util, which detects circular
> > references, but goes into infinite recursion

Data::Structure::Util never does a hash write. It only iterates over
the values of the hash.


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

Date: 13 Sep 2004 13:25:07 -0700
From: ozgune@gmail.com (Ozgun Erdogan)
Subject: Re: hv_iterinit has side effects - who cares about PL theory
Message-Id: <48b43181.0409131225.317449d7@posting.google.com>

> Clearly, this will end in an infinite recursion. But is this a bug in
> perl? One has to keep track of the references to make sure that circular
> ones are detected correctly.
> 

I think another example will make it clear why I think Perl's
hv_iterinit()/hv_iternext() functions are not implemented as expected.
Technically, these functions are doing reads. Say, you have two
threads:

T1
----
grab_read_lock(hash1);
hv_iterinit(hash1);
while (not_endof_hash(hash1));
{
  hv_iternext(hash1);
  print(value(hash1));
}
release_read_lock(hash1);

T2
----
grab_read_lock(hash1);
hv_iterinit(hash1);
while (not_endof_hash(hash1));
{
  hv_iternext(hash1);
  print(value(hash1));
}
release_read_lock(hash1);

Technically, independent of scheduling, you should see each of hash1's
elements printed twice. This is because hv_iterinit()/hv_iternext()
are supposed to do reads. Honestly, I haven't tried this, but am
pretty sure it'll mess up in Perl. On the other hand, in C, you can
do:

HE *curr_it = get_hv_head(hash1);
 .. and walk over the hash with your own C functions ...

> You aren't modifying a hash's values when iterating over it. You are
> however modifying the internal state of the iterator. There is no other
> way to do it in any language.

No, the problem is, the value of the iterator is in the hash structure
itself. And yes, you can easily do it in any other language, C++ STL
libraries provide you a data structure (like <vector>) and an iterator
that's independent of the data structure. Try the above example with
STL, and it'll give you what you want (or what I expect).

> So the bug is in the module and not in perl. You should report this to
> its author.

No, that depends on your perspective. I'm aware that implementing
hashes in a different way would break Perl's lazy deletion idea.
However, implementing it this way breaks one of the fundamental rules
of programming language theory: A read is supposed to do a read.

Ozgun.


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

Date: Mon, 13 Sep 2004 17:39:27 +0200
From: Federico <es@yahoo.fedeabascal>
Subject: killing a "nobody's" process and its group
Message-Id: <ci4f36$cgr$1@nsnmrro2-gest.nuria.telefonica-data.net>

Hello, again

I have problems with a cgi (running as nobody user). The problem is that 
none kill -9, $cgi_pid or kill $cgi_pid, or kill... whatever is able to 
kill the processes. But if I run as root user a simple perl -e 'kill(-9, 
PID)' it is able to kill it.

Anybody knows what could be happening?

thanks!
Federico
(I'm using Mac OsX with apache2 server)


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

Date: 13 Sep 2004 17:03:16 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: killing a "nobody's" process and its group
Message-Id: <Xns956384CD37151asu1cornelledu@132.236.56.8>

Federico <es@yahoo.fedeabascal> wrote in
news:ci4f36$cgr$1@nsnmrro2-gest.nuria.telefonica-data.net: 

> I have problems with a cgi (running as nobody user). The problem is
> that none kill -9, $cgi_pid or kill $cgi_pid, or kill... whatever is
> able to kill the processes. But if I run as root user a simple perl -e
> 'kill(-9, PID)' it is able to kill it.

That is gibberish.

Your problem (whatever it is) is not a Perl problem. 

> (I'm using Mac OsX with apache2 server)

Learn to partition your problem. Process management is done by the OS, so 
you should be asking the question (in a more intelligible manner) in the 
appropriate forum.


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



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

Date: Mon, 13 Sep 2004 15:51:08 +0200
From: Federico <es@yahoo.fedeabascal>
Subject: killing a process using its PID
Message-Id: <ci48o1$og6$1@nsnmrro2-gest.nuria.telefonica-data.net>

Hello,

I want my perl script to be able to kill a process given its pid. I 
could invoque the UNIX kill -9, but I would prefer something provided by 
the perl language.
Is there something in perl for this?

Thanks a lot!,
Federico


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

Date: Mon, 13 Sep 2004 15:53:24 +0200
From: Federico <es@yahoo.fedeabascal>
Subject: Re: killing a process using its PID
Message-Id: <ci48s9$og6$2@nsnmrro2-gest.nuria.telefonica-data.net>

sorry, I found it immediately after sending the message.
It is the "kill" function.



Federico wrote:

> Hello,
> 
> I want my perl script to be able to kill a process given its pid. I 
> could invoque the UNIX kill -9, but I would prefer something provided by 
> the perl language.
> Is there something in perl for this?
> 
> Thanks a lot!,
> Federico


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

Date: 13 Sep 2004 07:41:06 -0700
From: anodide@hotmail.com (Aaron Anodide)
Subject: Re: parsing UTF-8 chars out of POST data
Message-Id: <2db1147f.0409130641.41bbd4e4@posting.google.com>

"Alan J. Flavell" <flavell@ph.gla.ac.uk> wrote in message news:<Pine.LNX.4.61.0409092103510.25101@ppepc56.ph.gla.ac.uk>...
> On Thu, 9 Sep 2004, Aaron Anodide wrote:
> 
> > Well, I answered by own question:
> 
> That's as may be, but your answer is good only for a relatively narrow 
> range of problems.
> 
> That fact is (I'm sorry to say) that processing i18n form submissions 
> is a nontrivial matter, not made any easier by numerous anomalies and 
> oddities in browsers.  But all of that part of the problem is on-topic 
> in a WWW authoring group (e.g comp.infosystems.www.authoring.cgi - 
> beware the automoderation bot), and the locals around here don't like 
> to see their group misused for discussing that.  (Because they've got 
> enough to worry about with the i18n implementations in Perl - no 
> offence meant).
> 
> I'm afraid the only genuine advice I can offer at this point is to
> hone your expertise in the matter of partitioning a problem into its
> components - where necessary, instrumenting the interfaces between 
> them so that you can see clearly what is going on - and seeking 
> advice on each of the problem domains in its appropriate place.
> 
> > The content-type of the page collecting the password was set to utf-8,
> 
> Which is actually a good solution, if you need to handle a wide 
> character repertoire, and don't need to worry about antique browsers
> up to and including Netscape 4.  But I'm wandering into areas that are 
> off-topic for this group.
> 
> > so the ALT+156 was put into the post data as two bytes, %C2%A3.
> 
> That was obvious (which is a way of trying, and failing, to say 
> politely that if it wasn't evident to you, then you're a bit out of 
> your depth; but that can be remedied if you're willing to put in a 
> bit of effort).
> 
> >  When I set the content-type to charset=ISO-8859-1, then ALT-156 was 
> > put into the post data as one byte, %A3, which in turn was correctly 
> > parsed by CGI::unescape.
> 
> Indeed.  But now what happens if they type-in a character that isn't
> representable in the iso-8859-1 encoding?  There's no way that you can 
> stop them doing so, and so, I'd say, your server-side process needs to 
> be able to cope with the consequences, even if only by politely 
> telling them they provided invalid input and please to try again.
> 
> At risk of blowing my own trumpet for a part of the problem domain 
> that really is the off-topic part of your question here, see: 
> http://ppewww.ph.gla.ac.uk/~flavell/charset/form-i18n.html - but 
> please, I beg you, don't try to discuss the contents here, or the 
> regulars will bite.
> 
> good luck

Thanks for the insightful response to my off-topic post.  And I
appreciate the pointers to the other newsgroups as well.

Thanks again,
Aaron Anodide


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

Date: 13 Sep 2004 07:25:15 -0700
From: georgeziv@hotmail.com (gumby)
Subject: Re: Recursively copying a directory
Message-Id: <878baabf.0409130625.11a2a255@posting.google.com>

Lénaïc Huard <lenaic.huard@laposte.net> wrote in message news:<41285a53$0$29675$636a15ce@news.free.fr>...
> -----BEGIN xxx SIGNED MESSAGE-----
> Hash: SHA1
> 
> Hello,
> 
> I'm looking for a way to copy a directory and all its content with perl ;
> that is to say the perl function equivalent to the "cp -R" Unix command.
> 
> I've looked the 'File::Copy' package, but I only managed to copy regular
> files and not directories.
> 
> If toto is a directory, the following lines create an empty regular file
> named tata, whereas I expected tata to be new directory containing a copy
> of toto's content.
> 
>   use File::Copy;
>   copy( "toto", "tata" );
> 
> Does anybody have a nicer idea than a
>   system( "cp -R toto tata" );
> which is not very portable...
> 
> Thanks,
> Lénaïc.
> - -- 
> (o_       Lénaïc HUARD
> //\ Lenaic.Huard@laposte.net
> V_/_    KeyID: 0x04D2E818
> -----BEGIN xxx SIGNATURE-----
> Version: GnuPG v1.2.4 (GNU/Linux)
> 
> iD8DBQFBKFnIjYEjJATS6BgRAsaCAKCHuCyqllVr59P1cnxID9NyONEDJACgqOVn
> hCEkKvRqSQwQ+hTiTI/14bQ=
> =85pH
> -----END PGP SIGNATURE-----


I needed to copy a directory with all the subs as well and tried to
import Ncopy and found that the company i work for doesnt have a
version of perl installed that has Ncopy.  After asking they told me i
would have better luck winning the lottery than getting a version
installed on the diffrent sites we have.  So i use these two subs that
could easily be combined into one if you wanted to (I know there is
room for improvement but it is something that works well for people
who cant get Ncopy).

sub copyFile
{
    my ($copyFile, $path) = @_;

    unless(copy($copyFile, $path))
    {
	failedToCopy($copyFile, $path);
    }
}

sub failedToCopy
{
    my ($copyFile, $path) = @_;
    $copyFile =~ /\/(\w+)+$/;
    my $dir = $path.$1.'/';
   
    if(!-e $dir)
    {
	unless(mkdir($dir))
	{
	    infoWindow($mw, "Error in CreateHdlProject, Failed to create
$dir.  Please contact $programmer for support.", '650x200+0+0',
'red');
	    return;
	}
    }

    my @subdirectoryFiles = <$copyFile/* >;

    foreach(@subdirectoryFiles)
    {
	copyFile($_, $dir);
    }
}


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

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


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