[19565] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1760 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Sep 17 14:05:40 2001

Date: Mon, 17 Sep 2001 11:05:09 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <1000749909-v10-i1760@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Mon, 17 Sep 2001     Volume: 10 Number: 1760

Today's topics:
    Re: Cannot run perl scripts in Apache when file opened  (Jonadab the Unsightly One)
    Re: cd (NT command) on Perl (Malcolm Dew-Jones)
        Client/Server Question <mark.riehl@agilecommunications.com>
    Re: debug CGI script (Joe Chung)
        Easy problem with system cmd "mv"??? <daryl.l.shute@boeing.com>
    Re: Easy problem with system cmd "mv"??? <em@online.no>
    Re: Easy problem with system cmd "mv"??? <bert@scanlaser.nl>
    Re: Easy problem with system cmd "mv"??? <rsherman@ce.gatech.edu>
    Re: Easy problem with system cmd "mv"??? (Martien Verbruggen)
        example for rewinddir (Joachim Ziegler)
    Re: from html to xhtml - reg exp <jan.gruber@primacom.net>
        Getopt::mixed, and setting options for it's ise (Stan Brown)
    Re: Getopt::mixed, and setting options for it's ise <dtweed@acm.org>
    Re: Getopt::mixed, and setting options for it's ise (Stan Brown)
    Re: How can I find the PID's of my children? (Martien Verbruggen)
        Interrupted Server Socket Connections (Lyle Goldman)
    Re: Javadoc alike <sun_tong@users.sourceforge.net>
    Re: killing descendants of a process (Garry Williams)
        local() breaks with imported vars (Exporter bug?) <mjcarman@home.com>
    Re: local() breaks with imported vars (Exporter bug?) <joe+usenet@sunstarsys.com>
        New posters to comp.lang.perl.misc <gbacon@cs.uah.edu>
        Objects and Sockets (Del)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Mon, 17 Sep 2001 15:13:58 GMT
From: jonadab@bright.net (Jonadab the Unsightly One)
Subject: Re: Cannot run perl scripts in Apache when file opened via Samba
Message-Id: <3ba61163.12406803@news.bright.net>

dillon@rm_accessdenied.darktech.org (AcCeSsDeNiEd) wrote:

> I can use any program in Win98 to open the file. 
> The problem is still there.

Probably the programs you have tried all *keep the file open* 
while editing it, rather than the more sensible behavior of 
reading it in once and closing it, then reopening it to write 
your changes later.  Try using an editor that uses the latter
behavior, such as PFE or NTEmacs.  Really, I thought all half
decent text editors handled this properly; are you using 
Notepad or something?  (Repeat this mantra: "dontusenotepad")

Now, if a program opens, reads, and then closes a file
and *then* Apache can't read it, that would have to be
a Samba problem, I think.  But I'm betting that's not
your problem.  I'm betting your editor is keeping the
file open, and it really shouldn't do that.  

- jonadab


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

Date: 17 Sep 2001 10:16:05 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: cd (NT command) on Perl
Message-Id: <3ba62fd5@news.victoria.tc.ca>

Valentin 30IR976 (radiotito@yahoo.com) wrote:
: Hello. I would like to make a cd to a particular directory on NT with my
: perl program. I use ActiveState Perl.

: I have tried to make:

: `cd e:\\mydir`;

Is this the code from inside a perl script? The back ticks run a subshell.
The perl script is not affected.  To make the perl script change its
default directory you need the perl function chdir().  (though as noted
elsewhere, only the perl script is effected). 


: and also

: $dir="e:\\mydir";
: `chdir($dir`);

That can't be what you wrote because its a syntax error.  I tried
something similar, shown below, and my perl script successfuly cd'd itself
to another directory (even on another drive), as proved by the list of
files it displayed.

	chdir("H:\\") or die $!;
	print <*>;

the following also worked (note / instead of \\ , either are ok)

	chdir("H:/") or die $!;
	print <*>;

**Please always test the result**, the chdir may be telling you why it
didn't work. 

As noted elsewhere, none of the above affects the current directory of a
program or batch file that called the perl program.  To do that you need
to do something like

	@echo off
	perl find-the-directory.pl > %TEMP%\temp.bat
	call  %TEMP%\temp.bat

and you create temp.to look like (e.g.)
	H:
	CD H:\


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

Date: Mon, 17 Sep 2001 14:51:26 GMT
From: "Mark Riehl" <mark.riehl@agilecommunications.com>
Subject: Client/Server Question
Message-Id: <O5op7.4973$Na7.1075533@typhoon1.gnilink.net>

All - I've got a client a server, both written in Perl, they connect via
TCP.  I'm sending an XML file from the client to the server.  After sending
the file, I'm using a shutdown(1) from the client side to signal the server
that the client has finished sending the file.

I'm using the following on the client side:

open (INPUT, "< sql.xml") or
    die "Can't open sql.xml $!\n";

while (<INPUT>) {
  print $socket $_;
}

close (INPUT);


Question - when I count the number of bytes received on the server side, it
is less than the file size.  For some reason, it is one byte less per line.
That is, if the input file is 100 bytes and 10 lines, the server only
receives 90 bytes.

I can print it out on the server side, and it looks fine.

Is this some type of a CRLF issue?  Both scripts are running on the same
machine under Win2k.

Thanks,
Mark




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

Date: Mon, 17 Sep 2001 17:07:12 GMT
From: m_010@yahoo.com (Joe Chung)
Subject: Re: debug CGI script
Message-Id: <3ba62d98.509823@enews.newsguy.com>

then, how you debug your CGI script?  

thanks again.


On Mon, 17 Sep 2001 09:29:16 GMT, Bart Lateur <bart.lateur@skynet.be>
wrote:

>Joe Chung wrote:
>
>>If I want to debug live from web server:
>>
>>#!/usr/bin/perl -d:ptkdb
>>
>>any way I can have the perl debugger GUI pop up when user request
>>comes in (on UNIX)?  I can't think of a way do that.
>
>If this works at all, it would pop up a debugging window on your
>*server*, not on your client.
>
>>In other word, any way I can debug CGI script POST from web client?  I
>>am telnet/ssh to a unix terminal. 
>
>You could try installing a local web server on your own computer.
>Perhaps then it would pop up on your own screen.
>
>Maybe the remote debugging tools available from ActiveState could help.
>Search their site for "Komodo". I've never actually even looked at it,
>so I'm not sure it really does what I think it does.
>
>I don't ever debug perl scripts that way, and most definitely not CGI
>scripts.



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

Date: Mon, 17 Sep 2001 14:15:04 GMT
From: Daryl Shute <daryl.l.shute@boeing.com>
Subject: Easy problem with system cmd "mv"???
Message-Id: <3BA60568.28073F74@boeing.com>

I am trying to move a file from one directory to another, using the
following code snippet,
could someone please explain to me why it isn't working? Thanks in
advance...
============================
#!/usr/local/bin/perl
require('scripts/subroutines/ReadParse.pl');
&ReadParse;
$var = $in{"view"};
$ORIG = "/ondemand/od_requests/";	# Folder holding numbered documents
$ORIG .= $var;				# Original file prior to moving, document number from
webpage goes into $var
$ARCHFILE = "/ondemand/od_archive";	# Folder to move "deleted" documents
to.
$cmd = "mv $ORIG $ARCHFILE";
system($cmd);				# Move the numbered file to the Archive directory
==========================
If I put a print $ORIG .= $var statement in it does print the correct
numbered document.
I also tried using: $ARCHFILE .= $var;  Singel ticks, back ticks...
everything I could think of....
The directory permissions for the od_archive and od_requests folders
are: drw-rw-rw-

Thanks again for the help.

Daryl


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

Date: 17 Sep 2001 16:51:50 +0200
From: Espen Myrland <em@online.no>
Subject: Re: Easy problem with system cmd "mv"???
Message-Id: <87wv2xzx89.fsf@strand.arcanum.net>

Daryl Shute <daryl.l.shute@boeing.com> writes:

> I am trying to move a file from one directory to another, using the
> following code snippet,
> could someone please explain to me why it isn't working? Thanks in
> advance...
> ============================
> #!/usr/local/bin/perl
> $cmd = "mv $ORIG $ARCHFILE";
> system($cmd);				# Move the numbered file to the Archive directory
> ==========================



        system($cmd) == 0 || die "$cmd failed: $?";


--
espen



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

Date: Mon, 17 Sep 2001 17:06:52 +0200
From: Bert IJff <bert@scanlaser.nl>
To: Daryl Shute <daryl.l.shute@boeing.com>
Subject: Re: Easy problem with system cmd "mv"???
Message-Id: <3BA6118C.DB74479B@scanlaser.nl>



Daryl Shute wrote:
> 
> I am trying to move a file from one directory to another, using the
> following code snippet,
> could someone please explain to me why it isn't working? Thanks in
> advance...
> ============================
> #!/usr/local/bin/perl
> require('scripts/subroutines/ReadParse.pl');
> &ReadParse;
> $var = $in{"view"};
> $ORIG = "/ondemand/od_requests/";       # Folder holding numbered documents
> $ORIG .= $var;                          # Original file prior to moving, document number from
> webpage goes into $var
> $ARCHFILE = "/ondemand/od_archive";     # Folder to move "deleted" documents
> to.
> $cmd = "mv $ORIG $ARCHFILE";
> system($cmd);                           # Move the numbered file to the Archive directory
> ==========================
> If I put a print $ORIG .= $var statement in it does print the correct
> numbered document.
> I also tried using: $ARCHFILE .= $var;  Singel ticks, back ticks...
> everything I could think of....
> The directory permissions for the od_archive and od_requests folders
> are: drw-rw-rw-
> 
> Thanks again for the help.
> 
> Daryl

Set directory permissions to drwxrwxrwx
drwxrw-rw- will suffice if you are the owner.
If others need to read the files drwxr-xr-x
is a good option.
  man chmod
  man ls
  man 2 chmod
for more info on directory search permission

What message do you get when executing the mv command
from the command line?



Regards,
Bert


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

Date: Mon, 17 Sep 2001 11:03:10 +0500
From: Robert Sherman <rsherman@ce.gatech.edu>
Subject: Re: Easy problem with system cmd "mv"???
Message-Id: <3BA5921E.823E52B4@ce.gatech.edu>

Daryl Shute wrote:
> 
> I am trying to move a file from one directory to another, using the
> following code snippet,
> could someone please explain to me why it isn't working? Thanks in
> advance...
> ============================
> #!/usr/local/bin/perl
> require('scripts/subroutines/ReadParse.pl');
> &ReadParse;
> $var = $in{"view"};
> $ORIG = "/ondemand/od_requests/";       # Folder holding numbered documents
> $ORIG .= $var;                          # Original file prior to moving, document number from
> webpage goes into $var
> $ARCHFILE = "/ondemand/od_archive";     # Folder to move "deleted" documents
> to.
> $cmd = "mv $ORIG $ARCHFILE";
> system($cmd);                           # Move the numbered file to the Archive directory
> ==========================
> If I put a print $ORIG .= $var statement in it does print the correct
> numbered document.
> I also tried using: $ARCHFILE .= $var;  Singel ticks, back ticks...
> everything I could think of....
> The directory permissions for the od_archive and od_requests folders
> are: drw-rw-rw-
> 


possible solutions: 

system takes a list - try:

@cmd = ("mv", "$ORIG", "$ARCHFILE"); 
system(@cmd);

and when trying backticks, make sure you are using backticks (usually on
the same key as the tilde), not single quotes

or just use File::Copy instead. or even rename, if it is on the same
filesystem...

-- 
robert sherman
css, cee
georgia institute of technology
atlanta, ga, usa


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

Date: Tue, 18 Sep 2001 01:16:20 +1000
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Easy problem with system cmd "mv"???
Message-Id: <slrn9qc4u3.tu5.mgjv@martien.heliotrope.home>

[long lines rewrapped, or truncated]

On Mon, 17 Sep 2001 14:15:04 GMT,
	Daryl Shute <daryl.l.shute@boeing.com> wrote:
> I am trying to move a file from one directory to another, using the
> following code snippet,
> could someone please explain to me why it isn't working? Thanks in
> advance...
>============================
> #!/usr/local/bin/perl

This is a CGI script. Always use -T in a CGI script, _especially_ if you
accept user output that is going to end up in a command. Also: enable
warning, and enable strict.

#!/usr/local/bin/perl -wT
use strict;

> require('scripts/subroutines/ReadParse.pl');
> &ReadParse;

ucky. Why aren't you using the CGI module? Is this going to be so often
hit that that would be a performance hit?

> $var = $in{"view"};
> $ORIG = "/ondemand/od_requests/";
> $ORIG .= $var;

Ok, let's assume that I gave you the input

" ; rm -rf /; "

in the "view" text field. Let's see what the command is you'll be
executing.

> $ARCHFILE = "/ondemand/od_archive";
> $cmd = "mv $ORIG $ARCHFILE";

$cmd becomes 

"mv /ondemand/od_requests/ ; rm -rf /; /ondemand/od_archive"

See anything dangerous in there? Are you sure that you want to run this
without a bit more thought?

> system($cmd);

It looks very much like your files are on the same file system. Any
reason you're not using the builtin rename function? it will make it
easier for you to check for errors, and much harder to open yourself up
for giant gaping security holes like the one I showed you. If you need
to move across file systems, you could consider using the mv() function
in File::Copy, which are likely to be a bit safer as well.

At the moment, you don't check at all for errors, which could have maybe
told you why things went wrong. What happens if you try it from the
command line as the user that runs your web server? What happens if you
redirect stdout and stderr from the command you have there into a file,
so you can see what comes out?

> The directory permissions for the od_archive and od_requests folders
> are: drw-rw-rw-

That is not sufficient for directories. You need the execute mode on
there as well.  And what about the directory /ondemand? Can the web
server user get in there at all? And are you sure you want to just open
this directory to the whole world?

Now, please, don't come back here with a CGI script that doesn't use -w,
and more importantly, -T. Let perl try to prevent you shooting yourself
in your foot. Read the perlsec documentation.

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | That's not a lie, it's a
Commercial Dynamics Pty. Ltd.   | terminological inexactitude.
NSW, Australia                  | 


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

Date: 17 Sep 2001 09:19:43 -0700
From: ziegler@algorilla.de (Joachim Ziegler)
Subject: example for rewinddir
Message-Id: <93aad7d0.0109170819.2d6414cb@posting.google.com>

can someone give me a good example
for a situation, in which "rewinddir" is useful?

i don't see any!

greetings,
joachim


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

Date: Mon, 17 Sep 2001 18:49:03 +0200
From: Jan Gruber <jan.gruber@primacom.net>
Subject: Re: from html to xhtml - reg exp
Message-Id: <9o59lh$dd6$1@news.primacom.net>

Hi, Tobia,

> $line =~ s#<img(.*)">#<img$1"/>#gi;

Change this to 
  $line =~ s#<img(.*?)">#<img$1"/>#gi

? is for non greedy matching, othwerwise the regex eats the string until 
it doesnt find a "> .

HTH
Jan
-- 
cat /dev/world | perl -e "(/(^.*? \?) 42 \!/) && (print $1))"
errors->(c)
_ 


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

Date: 17 Sep 2001 09:56:13 -0400
From: stanb@panix.com (Stan Brown)
Subject: Getopt::mixed, and setting options for it's ise
Message-Id: <9o4vdt$g3a$1@panix1.panix.com>

I am using Getopt::mixed, and I need to set an option described in it's
documentaion. It's $badOption, and I have read the docs. It will do just
what I need.

However I don't understand how to set it. Would it be something like:

$Getopt::mixed->$badOption(1) ?




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

Date: Mon, 17 Sep 2001 14:41:17 GMT
From: Dave Tweed <dtweed@acm.org>
Subject: Re: Getopt::mixed, and setting options for it's ise
Message-Id: <3BA60A4A.9C5F4DD5@acm.org>

Stan Brown wrote:
> I am using Getopt::mixed, and I need to set an option described in it's
> documentaion. It's $badOption, and I have read the docs. It will do just
> what I need.
> 
> However I don't understand how to set it. Would it be something like:
> 
> $Getopt::mixed->$badOption(1) ?

Use the source, Stan:
 
  #---------------------------------------------------------------------
  # Standard function for handling bad options:
  #
  # Prints an error message and exits.
  #
  # You can override this by setting $Getopt::Mixed::badOption to a
  # function reference.

In other words, you would write something like this:

  $Getopt::Mixed::badOption = sub {
     my ($index, $option, $problem) = @_;
     $problem = 'unrecognized' unless $problem;
     die "$problem option '$option'";
  }

The notation used in the documentation is a bit misleading.

-- Dave Tweed


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

Date: 17 Sep 2001 11:52:12 -0400
From: stanb@panix.com (Stan Brown)
Subject: Re: Getopt::mixed, and setting options for it's ise
Message-Id: <9o567c$7uo$1@panix1.panix.com>

In <3BA60A4A.9C5F4DD5@acm.org> Dave Tweed <dtweed@acm.org> writes:

>Stan Brown wrote:
>> I am using Getopt::mixed, and I need to set an option described in it's
>> documentaion. It's $badOption, and I have read the docs. It will do just
>> what I need.
>> 
>> However I don't understand how to set it. Would it be something like:
>> 
>> $Getopt::mixed->$badOption(1) ?

>Use the source, Stan:
> 
>  #---------------------------------------------------------------------
>  # Standard function for handling bad options:
>  #
>  # Prints an error message and exits.
>  #
>  # You can override this by setting $Getopt::Mixed::badOption to a
>  # function reference.

Cool, Luke :-)

Thanks.


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

Date: Tue, 18 Sep 2001 00:54:47 +1000
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: How can I find the PID's of my children?
Message-Id: <slrn9qc3ln.tu5.mgjv@martien.heliotrope.home>

On Mon, 17 Sep 2001 08:30:47 -0400,
	Bernie Cosell <bernie@fantasyfarm.com> wrote:
> mgjv@tradingpost.com.au (Martien Verbruggen) wrote:
> 
>> ..if you use /proc, you should be prepared to
> } change the code dealing with it for each OS on which it is available.
> 
> Yup.  I would hazard that probably any flavor of Unix that provides /proc
> will have the parent pid *someplace* in the proc info for each process.
> You'd have to dig through the docs, figure it out, and then tweak that part
> of the little loop...

\begin[more]{offtopic}

Off the top of my head, Both Solaris and OpenBSD have a
/proc/PID/status, both with totally different contents. IIRC, for
OpenBSD[1] this contains a space separated list of information, with the
ppid the second or third field. For Solaris, the file contains a C
struct of type pstatus or p_status_t, or similar, with a field ptr_ppid,
or something like that.

I haven't played with any other unix-like OSes with a procfs, but the
only ones which were similar were the *BSDs, unsurprisingly :). 

\end{offtopic}

Of course, CPAN already contains a procfs module for Solaris. That idea
could be carried forward a bit more, and a generic procfs module with
the same interface for various OSes could be provided. It'd need some
thought, and a bit of design, but most of the information in the various
/proc systems is fairly identical.

Martien

[1] I'm pretty sure FreeBSD and NetBSD are identical in this respect.
-- 
Martien Verbruggen              | 
Interactive Media Division      | That's funny, that plane's dustin'
Commercial Dynamics Pty. Ltd.   | crops where there ain't no crops.
NSW, Australia                  | 


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

Date: 17 Sep 2001 09:10:49 -0700
From: Lyle_Goldman@ibi.com (Lyle Goldman)
Subject: Interrupted Server Socket Connections
Message-Id: <ed639144.0109170810.38da4e66@posting.google.com>

-
	Hello. I am trying to write a client-server system using sockets. In the
code that I have written, the client reads lines of text from standard input and
sends them to the server, which prints the lines to standard output. Under
normal situations, it work fine. However, when I interrupt the server process,
the client does not realize that the server has disconnected until it sends
two (not one, but two!) more lines of output. Why is this happening, and how
can I detect when the connection has closed sooner?

	The code follows. I am running under Solaris 5.6. Thank you for any help
you can provide me.


Here is the server code (testserver.pl):

#!/usr/local/bin/perl -w
use strict;

use sigtrap;
use Socket;

$SIG{PIPE} = sub { die "Broken Pipe.\n"; };

$| = 1;

my $port = $ARGV[0] || 2345;
socket SERVER, PF_INET, SOCK_STREAM, getprotobyname 'tcp' or die "socket: $!";
setsockopt SERVER, SOL_SOCKET, SO_REUSEADDR, pack("l", 1)
	or die "setsockopt: $!";
bind SERVER, sockaddr_in($port, INADDR_ANY) or die "bind: $!";
listen SERVER, SOMAXCONN or die "listen: $!";

my $paddr;
while($paddr = accept CLIENT, SERVER) {
	my ($port, $iaddr) = sockaddr_in($paddr);
	my $name = gethostbyaddr($iaddr, AF_INET);

	while(<CLIENT>) {
		print;
	};

	close CLIENT;
};

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

Here is the client code (testclient.pl):

#!/usr/local/bin/perl -w
use strict;

use sigtrap;
use Socket;

my ($remote, $port, $iaddr, $paddr);

$SIG{PIPE} = sub { die "Broken Pipe.\n"; };

$remote = shift || 'localhost';
$port = shift || 2345;  # random port
$port =~ /\D/ and $port = getservbyname($port, 'tcp');
die "No port" unless $port;
$iaddr = inet_aton($remote) or die "No host: $remote";
$paddr = sockaddr_in($port, $iaddr);

socket SOCKET, PF_INET, SOCK_STREAM, getprotobyname 'tcp' or die "socket: $!";
connect SOCKET, $paddr or die "connect: $!";
select SOCKET;
$| = 1;
select STDOUT;

while(<STDIN>) {
	print SOCKET or die "print: $!";
}

close SOCKET or die "close: $!";

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

						- Lyle Goldman


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

Date: 17 Sep 2001 13:29:41 -0300
From: * Tong * <sun_tong@users.sourceforge.net>
Subject: Re: Javadoc alike
Message-Id: <sa8heu17pca.fsf@suntong.personal.users.sourceforge.net>

"B. Caligari" <bcaligari@fireforged.com> writes:

> > Is there any well-known tool for Perl as Javadoc to Java?
> > How popular they are? (I assume there are more than one)
> 
> Check out the "perlpod" documentation.

Oh, sorry I didn't make myself clear. I've been using pod for a long
time. The way I use it is for user manual: how to use the program,
what the switches are, the effects, etc.

When I said Javadoc, I meant for technical document. Things like,
what this subroutine is for, its parameters, returns, scope,
variables, etc. This is for the people that need to understand the
code, not for end user.

Pod can only be one purpose, but not both. Otherwise, it will
confuse both end users and developers. Besides, there is no
universal way for developers to specify subroutine parameters,
returns... that sort of thing as Javadoc does. 

-- 
Tong (remove underscore(s) to reply)
  *niX Power Tools Project: http://xpt.sourceforge.net/
  - All free contribution & collection


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

Date: Mon, 17 Sep 2001 13:45:16 GMT
From: garry@ifr.zvolve.net (Garry Williams)
Subject: Re: killing descendants of a process
Message-Id: <slrn9qbvjb.640.garry@zfw.zvolve.net>

On 14 Sep 2001 13:54:44 -0700, Newbie <youradmirer@onebox.com> wrote:
> i'd like to kill all descendants of a process and those of its
> subprocesses (grandchildren etc). I digged through many messages on
> this board which seemed to help out but it didn't work for me. the
> simple example on perlipc man page didn't help either. here's what
> i've tried and failed.
> 
> fork process A 
>    setpgrp(0, 0)
>    fork a number of processes in A 
>        process X execs command xx
>        process Y execs command yy
>        process Z execs command zz
>        .
>        .
>        .
> 
> some time later, i issued a kill -9 => -$pidA which was supposed to
                                   ^^
				   ^^

This isn't a valid signal.  (Plus there's probably no reason to
attempt to send SIGKILL.  A SIGTERM or SIGINT will usually do nicely.)  

I had no problem killing children with this code: 

    #!/usr/bin/perl
    use warnings;
    use strict;
    use POSIX "setsid";

    sub spawn {
	my $sub = shift;
	my $pid = fork;

	die "fork: $!\n" unless defined $pid;
	exit $sub->(@_)  unless $pid;
	return $pid;
    }

    my $sub = sub {
	exec qw(/bin/sleep 30);
    };

    fork && exit;
    my $pgrp = setsid;
    die "can't create session: $!\n" if $pgrp == -1;

    spawn $sub for 1 .. 5;

    kill "INT", -$pgrp;
    exit 0;

Comment out the `kill "INT", -$pgrp;' statement to see the running
children in the process table after the parent has exited.  

The use of setpgrp(0, 0) is probably equivalent and just as portable,
although Solaris has deprecated that system call in favor of setsid(): 

    man -s 2 setpgrp
    ...
    NOTES
	 The setpgrp() function will be phased out in favor of the
	 setsid(2) function.

-- 
Garry Williams


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

Date: Mon, 17 Sep 2001 09:10:17 -0500
From: Michael Carman <mjcarman@home.com>
Subject: local() breaks with imported vars (Exporter bug?)
Message-Id: <3BA60449.9CB4A70E@home.com>

Yes, that's right, I think I found a bug. Normally when this happens I
do a little digging in the docs and discover that the problem is in my
understanding, but in this case I don't think so.

While using Test.pm to develop test cases for a module, I tried to
local()ize an imported variable and then call a subroutine which used
that variable. (I wanted to give each group of tests it's own scope to
eliminate interaction between sets.)

Before anyone gets started on local() vs my() and why you shouldn't
reference globals from subroutines: Don't. I know what I'm doing. :)

Here's the gutted sample that exhibits the problem:

file Foo.pm:

package Foo;
use strict;

use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
require Exporter;

@ISA         = qw(Exporter);
@EXPORT      = qw($FOO foo_is);
%EXPORT_TAGS = ();
@EXPORT_OK   = qw();

use vars qw($FOO);

$FOO = 1;

sub foo_is {
    print "Foo  - $FOO\n";
}

1;	

__END__

And the script which uses it:

#!/usr/bin/perl -w
use strict;
use Foo;

foo_is();

{
    local $FOO = 2;
    print "main - $FOO\n";
    foo_is();
}

foo_is();

__END__
Foo  - 1
main - 2
Foo  - 1
Foo  - 1

As you can see, local() only changed the value of $FOO when referenced
from within the current package. More precisely, it would appear that
local() only affected $main::FOO and not $Foo::FOO -- two things which
are supposed to be synonymous. What I'm trying to figure out is whether
the problem is with local() or with Exporter? (i.e. Where does it get
reported?)

-mjc


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

Date: 17 Sep 2001 13:56:45 -0400
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: local() breaks with imported vars (Exporter bug?)
Message-Id: <m3lmjd3dlu.fsf@mumonkan.sunstarsys.com>


[ clp.moderated removed from Newsgroups ]

Michael Carman <mjcarman@home.com> writes:

> @ISA         = qw(Exporter);
> @EXPORT      = qw($FOO foo_is);
                    ^

I think you should export *FOO here instead.  When you are
aliasing, there is an important difference between

  *var = *FOO;  # *FOO and *var point to _same_ typeglob
                # same as *var = \*FOO ?

and something like

  *var = \$FOO; # *FOO and *var remain distinct, but the
                # scalar slot for *var is aliased to *FOO's.
                # All other slots in *var remain unaffected!

> As you can see, local() only changed the value of $FOO when referenced
> from within the current package. More precisely, it would appear that
> local() only affected $main::FOO and not $Foo::FOO -- two things which
> are supposed to be synonymous. 

$main::FOO and $Foo::FOO are distinct Perl variables that (when aliased)
share a common value.  Localizing $main::FOO breaks the alias, since it
provides $main::FOO with a new temporary value to use in place of 
$Foo::FOO 's value.

If you want them to be truly "synonymous", I think you'll need to
alias the globs themselves.  ( Alternatively you could simply localize
$Foo::FOO instead of $main::FOO, but I assume that's not what you want. )

-- 
Joe Schaefer    "When the end of the world comes, I want to be in Cincinnati.
                          Everything happens ten years later there."
                                               --Mark Twain



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

Date: Mon, 17 Sep 2001 16:01:31 -0000
From: Greg Bacon <gbacon@cs.uah.edu>
Subject: New posters to comp.lang.perl.misc
Message-Id: <tqc7irh7klih35@corp.supernews.com>

Following is a summary of articles from new posters spanning a 7 day
period, beginning at 10 Sep 2001 16:41:10 GMT and ending at
17 Sep 2001 15:24:52 GMT.

Notes
=====

    - A line in the body of a post is considered to be original if it
      does *not* match the regular expression /^\s{0,3}(?:>|:|\S+>|\+\+)/.
    - All text after the last cut line (/^-- $/) in the body is
      considered to be the author's signature.
    - The scanner prefers the Reply-To: header over the From: header
      in determining the "real" email address and name.
    - Original Content Rating (OCR) is the ratio of the original content
      volume to the total body volume.
    - Find the News-Scan distribution on the CPAN!
      <URL:http://www.perl.com/CPAN/modules/by-module/News/>
    - Please send all comments to Greg Bacon <gbacon@cs.uah.edu>.
    - Copyright (c) 2001 Greg Bacon.
      Verbatim copying and redistribution is permitted without royalty;
      alteration is not permitted.  Redistribution and/or use for any
      commercial purpose is prohibited.

Totals
======

Posters:  76 (27.6% of all posters)
Articles: 128 (15.3% of all articles)
Volume generated: 221.0 kb (14.3% of total volume)
    - headers:    100.5 kb (2,043 lines)
    - bodies:     116.3 kb (3,848 lines)
    - original:   79.0 kb (2,703 lines)
    - signatures: 4.0 kb (76 lines)

Original Content Rating: 0.679

Averages
========

Posts per poster: 1.7
    median: 1.0 post
    mode:   1 post - 50 posters
    s:      1.8 posts
Message size: 1767.7 bytes
    - header:     804.4 bytes (16.0 lines)
    - body:       930.7 bytes (30.1 lines)
    - original:   632.2 bytes (21.1 lines)
    - signature:  31.6 bytes (0.6 lines)

Top 10 Posters by Number of Posts
=================================

         (kb)   (kb)  (kb)  (kb)
Posts  Volume (  hdr/ body/ orig)  Address
-----  --------------------------  -------

    9    13.4 (  6.6/  6.7/  3.6)  "Simon Oliver" <simon.oliver@umist.ac.uk>
    9    18.6 (  8.3/  7.9/  5.0)  Ilmari Karonen <usenet11576@itz.pp.sci.fi>
    5     7.5 (  3.8/  3.7/  2.7)  Bravan Dahn <unspecified@location.com>
    4     7.4 (  2.9/  4.5/  2.2)  "Anupam" <anpandey@cisco.com>
    4     7.4 (  4.0/  3.4/  3.3)  "Kalle Anka" <KalleAnka@markisspecialisten.com>
    3     8.1 (  3.0/  5.1/  4.3)  "Patrik Birgersson" <nobody@no_where.net>
    3     6.2 (  2.4/  3.8/  2.0)  "Fiendy" <fiendy@claraNO-SPAM.co.uk>
    3     5.0 (  1.7/  3.3/  1.5)  "kyi" <kyi@psnw.com>
    3     6.6 (  2.1/  4.5/  1.9)  "Jeff Gruen" <gruen.lab@yale.edu>
    3     8.2 (  2.7/  5.5/  2.7)  asif <whatever@nevermind.invalid>

These posters accounted for 5.5% of all articles.

Top 10 Posters by Volume
========================

  (kb)   (kb)  (kb)  (kb)
Volume (  hdr/ body/ orig)  Posts  Address
--------------------------  -----  -------

  18.6 (  8.3/  7.9/  5.0)      9  Ilmari Karonen <usenet11576@itz.pp.sci.fi>
  13.4 (  6.6/  6.7/  3.6)      9  "Simon Oliver" <simon.oliver@umist.ac.uk>
   8.2 (  2.7/  5.5/  2.7)      3  asif <whatever@nevermind.invalid>
   8.1 (  3.0/  5.1/  4.3)      3  "Patrik Birgersson" <nobody@no_where.net>
   7.5 (  3.8/  3.7/  2.7)      5  Bravan Dahn <unspecified@location.com>
   7.4 (  4.0/  3.4/  3.3)      4  "Kalle Anka" <KalleAnka@markisspecialisten.com>
   7.4 (  2.9/  4.5/  2.2)      4  "Anupam" <anpandey@cisco.com>
   6.6 (  2.1/  4.5/  1.9)      3  "Jeff Gruen" <gruen.lab@yale.edu>
   6.2 (  2.4/  3.8/  2.0)      3  "Fiendy" <fiendy@claraNO-SPAM.co.uk>
   5.7 (  0.7/  5.0/  2.8)      1  "Wee" <kekwee@cwasia.net.sg>

These posters accounted for 5.8% of the total volume.

Top 10 Posters by OCR (minimum of three posts)
==============================================

         (kb)    (kb)
OCR      orig /  body  Posts  Address
-----  --------------  -----  -------

0.989  (  3.3 /  3.4)      4  "Kalle Anka" <KalleAnka@markisspecialisten.com>
0.831  (  4.3 /  5.1)      3  "Patrik Birgersson" <nobody@no_where.net>
0.738  (  2.7 /  3.7)      5  Bravan Dahn <unspecified@location.com>
0.637  (  5.0 /  7.9)      9  Ilmari Karonen <usenet11576@itz.pp.sci.fi>
0.535  (  3.6 /  6.7)      9  "Simon Oliver" <simon.oliver@umist.ac.uk>
0.516  (  2.0 /  3.8)      3  "Fiendy" <fiendy@claraNO-SPAM.co.uk>
0.496  (  2.2 /  4.5)      4  "Anupam" <anpandey@cisco.com>
0.490  (  2.7 /  5.5)      3  asif <whatever@nevermind.invalid>
0.470  (  1.5 /  3.3)      3  "kyi" <kyi@psnw.com>
0.431  (  1.9 /  4.5)      3  "Jeff Gruen" <gruen.lab@yale.edu>

Bottom 10 Posters by OCR (minimum of three posts)
=================================================

         (kb)    (kb)
OCR      orig /  body  Posts  Address
-----  --------------  -----  -------

0.989  (  3.3 /  3.4)      4  "Kalle Anka" <KalleAnka@markisspecialisten.com>
0.831  (  4.3 /  5.1)      3  "Patrik Birgersson" <nobody@no_where.net>
0.738  (  2.7 /  3.7)      5  Bravan Dahn <unspecified@location.com>
0.637  (  5.0 /  7.9)      9  Ilmari Karonen <usenet11576@itz.pp.sci.fi>
0.535  (  3.6 /  6.7)      9  "Simon Oliver" <simon.oliver@umist.ac.uk>
0.516  (  2.0 /  3.8)      3  "Fiendy" <fiendy@claraNO-SPAM.co.uk>
0.496  (  2.2 /  4.5)      4  "Anupam" <anpandey@cisco.com>
0.490  (  2.7 /  5.5)      3  asif <whatever@nevermind.invalid>
0.470  (  1.5 /  3.3)      3  "kyi" <kyi@psnw.com>
0.431  (  1.9 /  4.5)      3  "Jeff Gruen" <gruen.lab@yale.edu>

10 posters (13%) had at least three posts.

Top 10 Targets for Crossposts
=============================

Articles  Newsgroup
--------  ---------

      14  alt.perl
       9  comp.unix.programmer
       6  comp.lang.c
       6  comp.lang.perl.modules
       5  alt.perl.sockets
       4  comp.security.misc
       4  de.comp.lang.perl.misc
       4  comp.lang.java.programmer
       4  alt.ecommerce
       4  alt.www.webmaster

Top 10 Crossposters
===================

Articles  Address
--------  -------

       4  "Gerry White" <ultradevusegrp@dergal.com>
       4  "Paul" <whamera@home.com>
       4  Hanno Böhm <hanno_b@web.de>
       1  "Patrik Birgersson" <nobody@no_where.net>
       1  Ilmari Karonen <usenet11581@itz.pp.sci.fi>
       1  Geoff Rothman <rothman@pobox.com>
       0  shan <shan_shetty@yahoo.com>
       0  "[per media] Wolfgang Nagele" <w.nagele@permedia.at>
       0  Murali Chari <muchari@cisco.com>
       0  uma shanker <asdf834@yahoo.com>


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

Date: 17 Sep 2001 10:01:52 -0700
From: delanthear@yahoo.com (Del)
Subject: Objects and Sockets
Message-Id: <999063fd.0109170901.74e21070@posting.google.com>

I'm after a decent example of a perl object, created to handle a
connection via a socket to a server.

I'm unsure how to create the socket and have it accessable by many of
the methods of the object.

Very Basic eg.

$connectOb = new connectOb;

# object opens connection to server
$connectob->connectserver($serveraddress);  
$connectob->sendmessage($message);

Thanks for any help!


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

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.  

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


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