How to thread in Perl?

2002-03-25 Thread Ahmed Moustafa

How can I thread a function in Perl?

Any help will be appreciated so much.

Regards,
-- 
Ahmed Moustafa
http://pobox.com/~amoustafa


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: How to thread in Perl?

2002-04-15 Thread Ahmed Moustafa

> #reap the children to avoid zombies
> waitpid $_ for (@children); 

Do I need to pop the pid's from the stack children?

Thanks,

Ahmed


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: How to thread in Perl?

2002-04-15 Thread Chas Owens

On Mon, 2002-04-15 at 17:31, Ahmed Moustafa wrote:
> > #reap the children to avoid zombies
> > waitpid $_ for (@children); 
> 
> Do I need to pop the pid's from the stack children?
> 
> Thanks,
> 
> Ahmed

You are better off trying 

$SIG{CHLD} = 'IGNORE';

at the top of your program and seeing if zombies are left out there.  If
so then you might want to use pop or shift like this

waitpid shift @children while @children;

-- 
Today is Setting Orange the 32nd day of Discord in the YOLD 3168


Missile Address: 33:48:3.521N  84:23:34.786W


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: How to thread in Perl?

2002-04-15 Thread Ahmed Moustafa

> You are better off trying
>
> $SIG{CHLD} = 'IGNORE';
>
> at the top of your program and seeing if zombies are left out there.

There were no zombies left after the program termination. Then, I don't need
even to push the ids from the children in the stack, right?

> Missile Address: 33:48:3.521N  84:23:34.786W

By the way, what is the Missile Address?


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: How to thread in Perl?

2002-04-15 Thread Ahmed Moustafa

> > You are better off trying
> >
> > $SIG{CHLD} = 'IGNORE';
> >
> > at the top of your program and seeing if zombies are left out there.
>
> There were no zombies left after the program termination. Then, I don't
need
> even to push the ids from the children in the stack, right?

Something happened when I tried $SIG{CHLD} = 'IGNORE';
I don't know if it's a related or not.
When a child is forked, it calls an Java program through system(), it used
to return 0 but with $SIG{CHLD} = 'IGNORE'; it returns -1.
I know that Java application exits normally (exit code = 0).
Does that make sense?

Thanks,

Ahmed



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: How to thread in Perl?

2002-04-17 Thread Ahmed Moustafa

> You are better off trying
>
> $SIG{CHLD} = 'IGNORE';
>
> at the top of your program and seeing if zombies are left out there.  If
> so then you might want to use pop or shift like this
>
> waitpid shift @children while @children;

Do I really need to hold the pid's of the kids process somewhere?
Can't I do something like that my $forked =  fork; waitpid $forked,
&WNOHANG;?
What do you think?

Thanks,

Ahmed


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: How to thread in Perl?

2002-04-18 Thread Chas Owens

On Wed, 2002-04-17 at 19:06, Ahmed Moustafa wrote:
> > You are better off trying
> >
> > $SIG{CHLD} = 'IGNORE';
> >
> > at the top of your program and seeing if zombies are left out there.  If
> > so then you might want to use pop or shift like this
> >
> > waitpid shift @children while @children;
> 
> Do I really need to hold the pid's of the kids process somewhere?
> Can't I do something like that my $forked =  fork; waitpid $forked,
> &WNOHANG;?
> What do you think?
> 
> Thanks,
> 
> Ahmed

I am not an expert


   WNOHANG
  which  means  to return immediately if no child has
  exited.


This says to me that wait returns (after doing nothing) if it cannot
find a child to reap.  If I remember your application correctly you may
want to add a "wait &WNOHANG;" to your main loop removing the PIDs it
returns from your array (which might be better implemented as a hash
now) like this:

until ($terminate) { #main loop
#do stuff that forks off children and stores
#their PIDs in %running

my $child = wait &WNOHANG;

if ($child != -1) { #child just got reaped
#$running{PID} should == 1 if the PID is really a child
unless (delete $running{$child}) {
die "reaped a process I didn't know about";
}
}
}

#the main loop has exited, so we should check to see if there are
#any unreaped children
waitpid $_ for keys %running;  



 
-- 
Today is Pungenday the 35th day of Discord in the YOLD 3168
Hail Eris!

Missile Address: 33:48:3.521N  84:23:34.786W


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: How to thread in Perl?

2002-04-18 Thread Ahmed Moustafa

Chas,

Thanks a lot!

> #the main loop has exited, so we should check to see if there are
> #any unreaped children
> waitpid $_ for keys %running;

My main loop is iterating forever i.e. a daemon; thus, any code after the
main loop will not be executed. So, what do you think?

Once again, thanks.

Ahmed


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: How to thread in Perl?

2002-04-18 Thread drieux


On Thursday, April 18, 2002, at 02:27 , Ahmed Moustafa wrote:

> Chas,
>
> Thanks a lot!
>
>> #the main loop has exited, so we should check to see if there are
>> #any unreaped children
>> waitpid $_ for keys %running;
>
> My main loop is iterating forever i.e. a daemon; thus, any code after the
> main loop will not be executed. So, what do you think?

you might want to have your 'main loop' in

our $still_going = 1;
$SIG{TERM} = sub { $still_going = 0 }; # correcting Chas's Issues... 8-)
while ( $still_going ) {
# the main loop
}

#
# now to close down gracefully
#

ciao
drieux

---


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: How to thread in Perl?

2002-04-19 Thread Chas Owens

On Thu, 2002-04-18 at 18:28, drieux wrote:
> 
> On Thursday, April 18, 2002, at 02:27 , Ahmed Moustafa wrote:
> 
> > Chas,
> >
> > Thanks a lot!
> >
> >> #the main loop has exited, so we should check to see if there are
> >> #any unreaped children
> >> waitpid $_ for keys %running;
> >
> > My main loop is iterating forever i.e. a daemon; thus, any code after the
> > main loop will not be executed. So, what do you think?
> 
> you might want to have your 'main loop' in
> 
> our $still_going = 1;
> $SIG{TERM} = sub { $still_going = 0 }; # correcting Chas's Issues... 8-)
> while ( $still_going ) {
>   # the main loop
> }
> 
> #
> # now to close down gracefully
> #
> 
> ciao
> drieux

What issues? I use

my $terminate = 0;
$SIG{TERM} = sub { $terminate = 1 };
until ($terminate) {
#do stuff
}

#cleanup


You should definitely provide some means of cleanly bring down your
daemon.  The alternative is someone killing with a signal 9 (SIGKILL)
and who knows what state that will leave the system.  The two perennial
favorites are shutting down when you receive a signal (usually signal
15: SIGTERM) and the existence (or lack thereof) a file in /var/run. 
Normally I don't invoke and bring down the daemon by hand but rather
provide scripts like these:


#!/bin/sh

BASE=/the/base/directory
BIN=$BASE/bin
LOG=$BASE/log
LOGFILE=$LOG/CASPERII.log

$BIN/daemon.pl >> $LOGFILE 2>> $LOGFILE.err



#!/bin/sh
PID=`ps -ef | grep daemon.pl | grep "/usr/bin/perl" | awk -e '{print
$2}'`

if [ "$PID" != '' ] ; then
kill -15 $PID
else
echo "Could not find daemon.pl, try 'ps -ef'ing yourself"
fi

 
-- 
Today is Prickle-Prickle the 36th day of Discord in the YOLD 3168
This statement is false.

Missile Address: 33:48:3.521N  84:23:34.786W


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: How to thread in Perl?

2002-04-19 Thread drieux


On Friday, April 19, 2002, at 07:03 , Chas Owens wrote:

> On Thu, 2002-04-18 at 18:28, drieux wrote:
[..]
>> you might want to have your 'main loop' in
>>
>> our $still_going = 1;
>> $SIG{TERM} = sub { $still_going = 0 }; # correcting Chas's Issues... 8-)
>> while ( $still_going ) {
>>  # the main loop
>> }
[..]
>
> What issues? I use
>
> my $terminate = 0;
> $SIG{TERM} = sub { $terminate = 1 };
> until ($terminate) {
>   #do stuff
> }
>
> #cleanup

There it is... you use the 'until foo' - I lost track
of the 'loop' - and so it looked 'insane' to me that
the cool oneline sig handler was back end yakward...

besides - while($still_going) is up beat, positive, friendly,
warm, HappyFluffyBunnies..

whereas - until($terminate) - downer, bummer, badly dressed
cyborgs from the future hunting down the terran infestation units...

Therapy Seek Therapy 8-)

[..]

You do get points for remembering to have a 'shutdown' fail safe
solution - but that should be the last knife in your boot. If you
put out a PID_FILE in /tmp - then its an if file exists read pid
send sig, sleep $reasonable_time , check proc table, if still up
- send hard KILL.

> 
> #!/bin/sh
> PID=`ps -ef | grep daemon.pl | grep "/usr/bin/perl" | awk -e '{print
> $2}'`

yes, yes, yes I know that this is not

comp.oldGuys.shell

but two pieces of advice:

1) always run your daemons under a 'special UID' so that
you can use your os's version of

ps -u $UID_FOR_ME | awk '// {print $1}'

{ this form works on solaris, linux and darwin - and is
more portable across the *nix space than ps -ef }

Also - for safety sake you should expect that PID will
be in a 'list context' hence should cope with it in the

for pid in $PID
do
# skank on the puppy
done

2) and remember that awk does regex. and since you
are firing up this with the intention of Doing it with
perl why not DO Perl? Unless you were planning on the
classic 'init script' - at which point - why not just
do the classical and canonical
[..]


#!/bin/sh

BASE=/the/base/directory
BIN=$BASE/bin
LOG=$BASE/log
LOGFILE=$LOG/CASPERII.log

pidGrovel() {
PID=`ps -ef | grep daemon.pl | grep "/usr/bin/perl" | awk -e '{print
$2}'`

if [ "$PID" != '' ] ; then
 kill -15 $PID
else
 echo "Could not find daemon.pl, try 'ps -ef'ing yourself"
fi

}

start() {
$BIN/daemon.pl >> $LOGFILE 2>> $LOGFILE.err
}

stop() {
pidGrovel
}

case "$1" in
   start)
 start
 ;;
   stop)
 stop
 ;;
esac

echo "Bye Bye, So Long, Thanks for all the Fish"


this way if you want to grow out your verb list for things
like reload, status, daemon_act_funky... you isolate those
in their own 'functions'.. but the two canonicals ones
that you will need start/stop are kosher

extra credit to show the 'hey guys we can still get our
perl init script to run with

sh init_script start

ciao
drieux

---

Kids these days, no respect for their elders,
no respect for tradition. not like when I
was growing up - we had the doors and dylan,
and elders you just had to respect

8-)


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: How to thread in Perl?

2002-04-19 Thread Chas Owens

On Fri, 2002-04-19 at 11:53, drieux wrote:
> 
> On Friday, April 19, 2002, at 07:03 , Chas Owens wrote:
> 
> > On Thu, 2002-04-18 at 18:28, drieux wrote:
> [..]
> >> you might want to have your 'main loop' in
> >>
> >> our $still_going = 1;
> >> $SIG{TERM} = sub { $still_going = 0 }; # correcting Chas's Issues... 8-)
> >> while ( $still_going ) {
> >># the main loop
> >> }
> [..]
> >
> > What issues? I use
> >
> > my $terminate = 0;
> > $SIG{TERM} = sub { $terminate = 1 };
> > until ($terminate) {
> > #do stuff
> > }
> >
> > #cleanup
> 
> There it is... you use the 'until foo' - I lost track
> of the 'loop' - and so it looked 'insane' to me that
> the cool oneline sig handler was back end yakward...
> 
> besides - while($still_going) is up beat, positive, friendly,
> warm, HappyFluffyBunnies..
> 
> whereas - until($terminate) - downer, bummer, badly dressed
> cyborgs from the future hunting down the terran infestation units...
> 
> Therapy Seek Therapy 8-)

Some people believe that the glass is half empty and some believe the
glass is half full, but I believe some moth**er drank half my
fu* Dr Pepper!

> 
> [..]
> 
> You do get points for remembering to have a 'shutdown' fail safe
> solution - but that should be the last knife in your boot. If you
> put out a PID_FILE in /tmp - then its an if file exists read pid
> send sig, sleep $reasonable_time , check proc table, if still up
> - send hard KILL.
> 
> > 
> > #!/bin/sh
> > PID=`ps -ef | grep daemon.pl | grep "/usr/bin/perl" | awk -e '{print
> > $2}'`
> 
> yes, yes, yes I know that this is not
> 
>   comp.oldGuys.shell
> 
> but two pieces of advice:
> 
> 1) always run your daemons under a 'special UID' so that
> you can use your os's version of
> 
>   ps -u $UID_FOR_ME | awk '// {print $1}'

Yep, that would work.  This is mark two of the script.  The first used
cut to grab the PID, but that failed when the pid was small so I threw
on the awk and didn't refactor the script.

> 
> { this form works on solaris, linux and darwin - and is
> more portable across the *nix space than ps -ef }

Never really had a problem with ps -ef, and I liked being able to tell
the production guys to ps -ef themseleves.

> 
> Also - for safety sake you should expect that PID will
> be in a 'list context' hence should cope with it in the
> 
>   for pid in $PID
>   do
>   # skank on the puppy
>   done
> 

Definitely a must if you want a bullet proof script.  See above and
below why I didn't care enough to make it bullet proof. 

> 2) and remember that awk does regex. 

Probably should refactor the script, but failure to care and desire to
not have to test it again tickle my sense of (little 'l') laziness more
than my (big 'h') Hubris.

> and since you
> are firing up this with the intention of Doing it with
> perl why not DO Perl? Unless you were planning on the
> classic 'init script' - at which point - why not just
> do the classical and canonical


Little l laziness.  I needed to give the production guys something to
work with and didn't really care much.  The other reason is that this is
not a daemon we want to start up with the box.  On boot up we do a
manual inspection of the system and then kick of various daemons.  The
script could benefit from being more robust, but the need is small (for
me at least) and if they dont like it, well, they can put in a change
request .

> 
> this way if you want to grow out your verb list for things
> like reload, status, daemon_act_funky... you isolate those
> in their own 'functions'.. but the two canonicals ones
> that you will need start/stop are kosher
> 
> extra credit to show the 'hey guys we can still get our
> perl init script to run with
> 
>   sh init_script start
> 
> ciao
> drieux
> 
> ---
> 
> Kids these days, no respect for their elders,
> no respect for tradition. not like when I
> was growing up - we had the doors and dylan,
> and elders you just had to respect
> 
> 8-)

Hey, I listen to Dylan (Blond On Blond rules), the Doors, et al. as well
and respect of (local) tradition is why it is two scripts.  That is the
way the old ksh+dbaccess+SPL version worked, so I put the same frontend
on my Perl version.  One of the tings I have learned the hard way is
that sometimes the best way shouldn't be used because it clashes with
the mediocre way and confuses people (consistency can be important so
long as it is not dangerous).

-- 
Today is Prickle-Prickle the 36th day of Discord in the YOLD 3168
Fnord.

Missile Address: 33:48:3.521N  84:23:34.786W


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: How to thread in Perl?

2002-04-19 Thread Ahmed Moustafa

Chas Owens wrote:
> my $terminate = 0;
> $SIG{TERM} = sub { $terminate = 1 };
> until ($terminate) {
>   #do stuff
> }
> 
> #cleanup
> 
> 
> You should definitely provide some means of cleanly bring down your
> daemon.

Cleaning up is application specific, isn't? Or, is there a standard 
procedure?

How can a child process be forced to be killed (in the cleaning up)?

-- 
Ahmed Moustafa
http://pobox.com/~amoustafa


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: How to thread in Perl?

2002-04-21 Thread Chas Owens

On Fri, 2002-04-19 at 21:38, Ahmed Moustafa wrote:
> Chas Owens wrote:
> > my $terminate = 0;
> > $SIG{TERM} = sub { $terminate = 1 };
> > until ($terminate) {
> > #do stuff
> > }
> > 
> > #cleanup
> > 
> > 
> > You should definitely provide some means of cleanly bring down your
> > daemon.
> 
> Cleaning up is application specific, isn't? Or, is there a standard 
> procedure?
> 
> How can a child process be forced to be killed (in the cleaning up)?
> 
> -- 
> Ahmed Moustafa
> http://pobox.com/~amoustafa

The daemon should not come down until all of its children are finished. 
That is why you need intercept SIGTERM.

-- 
Today is Sweetmorn the 38th day of Discord in the YOLD 3168
Kallisti!

Missile Address: 33:48:3.521N  84:23:34.786W


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: How to thread in Perl?

2002-04-21 Thread drieux


On Sunday, April 21, 2002, at 08:09 , Chas Owens wrote:
[..]
> The daemon should not come down until all of its children are finished.
> That is why you need intercept SIGTERM.
[..]

technically the correct structure for RFC compiance is

The daemon MUST NOT come down until all of its children
have finished and exited.

'must not' is more declarative than 'should' as to 'responsibility.

If the coder breeds children - they must be reaped.

SysAdmins are Allowed to Fire Volley's of Shot, and shell,
at coders who fail on this point


ciao
drieux

---


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: How to thread in Perl?

2002-03-25 Thread Matthew Harrison

What exactly do you mean by 'thread'?

On Mon, 25 Mar 2002, Ahmed Moustafa wrote:

> How can I thread a function in Perl?
> 
> Any help will be appreciated so much.
> 
> Regards,
> 

-- 
Matthew Harrison
Internet/Network Services Administrator
Peanut-Butter Cheesecake Hosting Services
Genestate
www.peanutbuttercheesecake.co.uk


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: How to thread in Perl?

2002-03-25 Thread Ahmed Moustafa

Matthew Harrison wrote:
> What exactly do you mean by 'thread'?

I've a loop which scans directories looking for files and processes the 
existing files. I'd like process each file independently (i.e. in 
parallel) rather than sequentially.

> 
> On Mon, 25 Mar 2002, Ahmed Moustafa wrote:
> 
> 
>>How can I thread a function in Perl?
>>
>>Any help will be appreciated so much.
>>
>>Regards,
-- 
Ahmed Moustafa
http://pobox.com/~amoustafa


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: How to thread in Perl?

2002-03-25 Thread Jim Conner

I suck at this kind of topic but the only way I can think of doing such a 
thing is this:

Use IPC.

fork off something like 10 children each child working on a separate file 
and use sysvmsg sysvshem (I do not believe these are functions and I can't 
look the right functions up for you right now but perldoc perlipc might be 
of some use) to pass messages back and forth between the children and the 
parent to follow what each process is doing.


Anyone else?  Im shooting in the dark really.

- Jim


At 19:04 03.25.2002 -0800, Ahmed Moustafa wrote:
>Matthew Harrison wrote:
>>What exactly do you mean by 'thread'?
>
>I've a loop which scans directories looking for files and processes the 
>existing files. I'd like process each file independently (i.e. in 
>parallel) rather than sequentially.
>
>>On Mon, 25 Mar 2002, Ahmed Moustafa wrote:
>>
>>>How can I thread a function in Perl?
>>>
>>>Any help will be appreciated so much.
>>>
>>>Regards,
>--
>Ahmed Moustafa
>http://pobox.com/~amoustafa
>
>
>--
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>

-BEGIN PGP PUBLIC KEY BLOCK-
Version: GnuPG v1.0.6 (MingW32)
Comment: For info see http://www.gnupg.org



- Jim

Philosophy is for those who have nothing better to do than wonder
why philosophy is for those who have nothing better to do than...


mQGiBDxAonQRBACx+sz63XIeo5uTzc5n3Elf7Y13VVZGIM8Pilp3LpBu70/nGQPu
anKYDB3aa1U5cfl+cTK5lOtUxN7Fu0a2Uv0ApIlC1qA8CjDZqlu7PDETFTVrpfGZ
007BHO+y2Y0bVsaMPXdnhbi0LAFSIkNYRhyzNWbAkeMsgA+i2k9hcnhvVwCgor7P
nflXu7xWN9aWt3RJBzqdUR0EAK/1obJFUKQSK39cKTMP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oYkdUtTWM9MGubiFl5B9uH5EHWAlFF8h760U7Xp9m1J3qTyH
EJqjfGj2SP2DK5cisuWOWdPy5aSqT7ZKrcKeSTDUyiHclI1ygFHue8oO0HXqrs+k
KjFdRqIKnzfY9gW/b/6gLHhBDV6BoA9w6+1Y9egOByRcVonE8zY/xMeIRgQYEQIA
BgUCPECjcgAKCRDmnFh04+r7ZcyDAJ4ogYX7W4u8g+QJsksyL4Ld+dObCwCfU7hB
7I3ZgTsYwP6mr5RPjkH5PG8=
=QOu8
-END PGP PUBLIC KEY BLOCK-
__END__


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: How to thread in Perl?

2002-03-25 Thread Ahmed Moustafa

Jim Conner wrote:
> I suck at this kind of topic but the only way I can think of doing such 
> a thing is this:
> 
> Use IPC.
> 
> fork off something like 10 children each child working on a separate 
> file and use sysvmsg sysvshem (I do not believe these are functions and 
> I can't look the right functions up for you right now but perldoc 
> perlipc might be of some use) to pass messages back and forth between 
> the children and the parent to follow what each process is doing.

'fork' spawns a child process of the parent, doesn't it?

> 
> Anyone else?  Im shooting in the dark really.
> 
> - Jim
> 
> 
> At 19:04 03.25.2002 -0800, Ahmed Moustafa wrote:
> 
>> Matthew Harrison wrote:
>>
>>> What exactly do you mean by 'thread'?
>>
>>
>> I've a loop which scans directories looking for files and processes 
>> the existing files. I'd like process each file independently (i.e. in 
>> parallel) rather than sequentially.
>>
>>> On Mon, 25 Mar 2002, Ahmed Moustafa wrote:
>>>
 How can I thread a function in Perl?


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: How to thread in Perl?

2002-03-25 Thread Ahmed Moustafa

> Jim Conner wrote:
> 
>> I suck at this kind of topic but the only way I can think of doing 
>> such a thing is this:
>>
>> Use IPC.
>>
>> fork off something like 10 children each child working on a separate 
>> file and use sysvmsg sysvshem (I do not believe these are functions 
>> and I can't look the right functions up for you right now but perldoc 
>> perlipc might be of some use) to pass messages back and forth between 
>> the children and the parent to follow what each process is doing.
> 
> 
> 'fork' spawns a child process of the parent, doesn't it?

I mean the child is a clone of the parent, isn't?

> 
>>
>> Anyone else?  Im shooting in the dark really.
>>
>> - Jim


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: How to thread in Perl?

2002-03-25 Thread Jim Conner

At 20:28 03.25.2002 -0800, Ahmed Moustafa wrote:
>>Jim Conner wrote:
>>
>>>I suck at this kind of topic but the only way I can think of doing such 
>>>a thing is this:
>>>
>>>Use IPC.
>>>
>>>fork off something like 10 children each child working on a separate 
>>>file and use sysvmsg sysvshem (I do not believe these are functions and 
>>>I can't look the right functions up for you right now but perldoc 
>>>perlipc might be of some use) to pass messages back and forth between 
>>>the children and the parent to follow what each process is doing.
>>
>>'fork' spawns a child process of the parent, doesn't it?
>
>I mean the child is a clone of the parent, isn't?

Yes; from the point where the fork occurs.




>>>Anyone else?  Im shooting in the dark really.
>>>
>>>- Jim
>
>
>--
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>

-BEGIN PGP PUBLIC KEY BLOCK-
Version: GnuPG v1.0.6 (MingW32)
Comment: For info see http://www.gnupg.org



- Jim

Philosophy is for those who have nothing better to do than wonder
why philosophy is for those who have nothing better to do than...


mQGiBDxAonQRBACx+sz63XIeo5uTzc5n3Elf7Y13VVZGIM8Pilp3LpBu70/nGQPu
anKYDB3aa1U5cfl+cTK5lOtUxN7Fu0a2Uv0ApIlC1qA8CjDZqlu7PDETFTVrpfGZ
007BHO+y2Y0bVsaMPXdnhbi0LAFSIkNYRhyzNWbAkeMsgA+i2k9hcnhvVwCgor7P
nflXu7xWN9aWt3RJBzqdUR0EAK/1obJFUKQSK39cKTMPQ4u2UPflbS5dJ871naG5
xBAlQAjHAXT+f/fXE2ezrSyoQnlOD4kVbPN3gB5UT5mWoylPuf5W7WmupthVzUUN
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KeSTDUyiHclI1ygFHue8oO0HXqrs+k
KjFdRqIKnzfY9gW/b/6gLHhBDV6BoA9w6+1Y9egOByRcVonE8zY/xMeIRgQYEQIA
BgUCPECjcgAKCRDmnFh04+r7ZcyDAJ4ogYX7W4u8g+QJsksyL4Ld+dObCwCfU7hB
7I3ZgTsYwP6mr5RPjkH5PG8=
=QOu8
-END PGP PUBLIC KEY BLOCK-
__END__


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: How to thread in Perl?

2002-03-25 Thread Ahmed Moustafa

Jim Conner wrote:
> At 20:28 03.25.2002 -0800, Ahmed Moustafa wrote:
> 
>>> Jim Conner wrote:
>>>
 I suck at this kind of topic but the only way I can think of doing 
 such a thing is this:

 Use IPC.

 fork off something like 10 children each child working on a separate 
 file and use sysvmsg sysvshem (I do not believe these are functions 
 and I can't look the right functions up for you right now but 
 perldoc perlipc might be of some use) to pass messages back and 
 forth between the children and the parent to follow what each 
 process is doing.
>>>
>>>
>>> 'fork' spawns a child process of the parent, doesn't it?
>>
>>
>> I mean the child is a clone of the parent, isn't?
> 
> 
> Yes; from the point where the fork occurs.

So, how can a new different process by forked? Or, how a function be 
called and the next step execute without waiting for the previous 
function to terminate?


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: How to thread in Perl?

2002-03-25 Thread Tagore Smith

Ahmed Moustafa wrote:

> So, how can a new different process by forked? Or, how a function be
> called and the next step execute without waiting for the previous
> function to terminate?

   For your original question (threads) see perldoc perlthrtut.

   When you fork a child process the call to fork returns the child pid to
the parent and 0 to the child. So you can write code that tests the return
value and does one thing in the parent process (continue forking children to
deal with the rest of your files) and another in the child process (process
the current file). You can also use exec to execute another process which is
not a "clone" of the parent.

   See perldoc -f fork and perldoc -f exec.

   Out of curiosity, why do you want to do this?

Tagore Smith


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: How to thread in Perl?

2002-03-25 Thread Ahmed Moustafa

Tagore Smith wrote:

> Ahmed Moustafa wrote:
> 
> 
>>So, how can a new different process by forked? Or, how a function be
>>called and the next step execute without waiting for the previous
>>function to terminate?
>>
> 
>For your original question (threads) see perldoc perlthrtut.
> 
>When you fork a child process the call to fork returns the child pid to
> the parent and 0 to the child. So you can write code that tests the return
> value and does one thing in the parent process (continue forking children to
> deal with the rest of your files) and another in the child process (process
> the current file). You can also use exec to execute another process which is
> not a "clone" of the parent.
> 
>See perldoc -f fork and perldoc -f exec.
> 
>Out of curiosity, why do you want to do this?


The main loop looks for files which are sent via FTP. Once a file is on 
the server, it should be encrypted. The encryption process is slow so 
some files stay as plain text waiting for their turns to be found and 
encrypted.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: How to thread in Perl?

2002-03-25 Thread Tagore Smith

Ahmed Moustafa wrote:

> Tagore Smith wrote:
>
> > Ahmed Moustafa wrote:
> >
> >
> >>So, how can a new different process by forked? Or, how a function be
> >>called and the next step execute without waiting for the previous
> >>function to terminate?
> >>
> >
> >For your original question (threads) see perldoc perlthrtut.
> >
> >When you fork a child process the call to fork returns the child pid
to
> > the parent and 0 to the child. So you can write code that tests the
return
> > value and does one thing in the parent process (continue forking
children to
> > deal with the rest of your files) and another in the child process
(process
> > the current file). You can also use exec to execute another process
which is
> > not a "clone" of the parent.
> >
> >See perldoc -f fork and perldoc -f exec.
> >
> >Out of curiosity, why do you want to do this?
>
>
> The main loop looks for files which are sent via FTP. Once a file is on
> the server, it should be encrypted. The encryption process is slow so
> some files stay as plain text waiting for their turns to be found and
> encrypted.

   That's plausible :). I was worried you might be thinking about doing this
to large pre-existing directory trees.

   If the parent process is solely devoted to looking for and encrypting
these files you may find that using separate processes to do this doesn't
help much, and may in fact hurt- but I don't know everything about your
situation, so then again it may be warranted. I'd stay away from threads
unless you have a lot of time to devote to this, but using fork should be
pretty straightforward (assuming your platform is Unix-like - process
creation is more expensive under Windows).

Tagore Smith



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: How to thread in Perl?

2002-03-26 Thread Jim Conner

At 22:14 03.25.2002 -0800, Ahmed Moustafa wrote:
>Content-Type: text/plain; charset=us-ascii; format=flowed
>Content-Transfer-Encoding: 7bit
>X-Posted-By: 209.178.174.150
>
>Jim Conner wrote:
> > At 20:28 03.25.2002 -0800, Ahmed Moustafa wrote:
> >
> >>> Jim Conner wrote:
> >>>
>  I suck at this kind of topic but the only way I can think of doing
>  such a thing is this:
> 
>  Use IPC.
> 
>  fork off something like 10 children each child working on a separate
>  file and use sysvmsg sysvshem (I do not believe these are functions
>  and I can't look the right functions up for you right now but
>  perldoc perlipc might be of some use) to pass messages back and
>  forth between the children and the parent to follow what each
>  process is doing.
> >>>
> >>>
> >>> 'fork' spawns a child process of the parent, doesn't it?
> >>
> >>
> >> I mean the child is a clone of the parent, isn't?
> >
> >
> > Yes; from the point where the fork occurs.
>
>So, how can a new different process by forked? Or, how a function be
>called and the next step execute without waiting for the previous
>function to terminate?
>

Thats where the shared mem messages would come into play.  Again, its all 
theoretical but you could, in theory, make your children process talk to 
each other giving each other status of where they are in each process.  At 
least, this is how I envision it.  I don't have specifics and I have never 
actually attempted it.

>--
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]

-BEGIN PGP PUBLIC KEY BLOCK-
Version: GnuPG v1.0.6 (MingW32)
Comment: For info see http://www.gnupg.org



- Jim

Philosophy is for those who have nothing better to do than wonder
why philosophy is for those who have nothing better to do than...


mQGiBDxAonQRBACx+sz63XIeo5uTzc5n3Elf7Y13VVZGIM8Pilp3LpBu70/nGQPu
anKYDB3aa1U5cfl+cTK5lOtUxN7Fu0a2Uv0ApIlC1qA8CjDZqlu7PDETFTVrpfGZ
007BHO+y2Y0bVsaMPXdnhbi0LAFSIkNYRhyzNWbAkeMsgA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EcAMhSflt9LSJETIQQByKKh1e5RvOuApwBFmQq3syRhzqv/
j2b6t3IqAB9WR5TnoYkdUtTWM9MGubiFl5B9uH5EHWAlFF8h760U7Xp9m1J3qTyH
EJqjfGj2SP2DK5cisuWOWdPy5aSqT7ZKrcKeSTDUyiHclI1ygFHue8oO0HXqrs+k
KjFdRqIKnzfY9gW/b/6gLHhBDV6BoA9w6+1Y9egOByRcVonE8zY/xMeIRgQYEQIA
BgUCPECjcgAKCRDmnFh04+r7ZcyDAJ4ogYX7W4u8g+QJsksyL4Ld+dObCwCfU7hB
7I3ZgTsYwP6mr5RPjkH5PG8=
=QOu8
-END PGP PUBLIC KEY BLOCK-
__END__


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: How to thread in Perl?

2002-03-26 Thread Chas Owens

On Tue, 2002-03-26 at 01:14, Ahmed Moustafa wrote:
> Jim Conner wrote:
> > At 20:28 03.25.2002 -0800, Ahmed Moustafa wrote:
> > 
> >>> Jim Conner wrote:
> >>>
>  I suck at this kind of topic but the only way I can think of doing 
>  such a thing is this:
> 
>  Use IPC.
> 
>  fork off something like 10 children each child working on a separate 
>  file and use sysvmsg sysvshem (I do not believe these are functions 
>  and I can't look the right functions up for you right now but 
>  perldoc perlipc might be of some use) to pass messages back and 
>  forth between the children and the parent to follow what each 
>  process is doing.
> >>>
> >>>
> >>> 'fork' spawns a child process of the parent, doesn't it?
> >>
> >>
> >> I mean the child is a clone of the parent, isn't?
> > 
> > 
> > Yes; from the point where the fork occurs.
> 
> So, how can a new different process by forked? Or, how a function be 
> called and the next step execute without waiting for the previous 
> function to terminate?

Fork returns 0 to the child process and the pid of the child process to
the parent.  This allows you to say things like

my @children;
#loop while get_filename retruns a vaild filename
#this could easily be a foreach loop of @filenames
while (my $filename = get_filename()) { 
my $forked = fork; #fork into two processes(parent and child)

#if $forked is undef then fork failed
unless (defined $forked) {
warn "something went wrong with fork";
next;
} 

#push the PID of the child onto a stack
push @children, $forked; #meaningless for child

next if $forked; #parent loops

#only the child can get here 
encrypt_the_file($filename);

#child ends execution here
exit 0;
}

#reap the children to avoid zombies
waitpid $_ for (@children); 


-- 
Today is Setting Orange the 12nd day of Discord in the YOLD 3168
Keep the Lasagna flying!

Missile Address: 33:48:3.521N  84:23:34.786W


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: How to thread in Perl?

2002-03-26 Thread perl

Is there a limit to the number of children in Perl?


"Ahmed Moustafa" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Tagore Smith wrote:
>
> > Ahmed Moustafa wrote:
> >
> >
> >>So, how can a new different process by forked? Or, how a function be
> >>called and the next step execute without waiting for the previous
> >>function to terminate?
> >>
> >
> >For your original question (threads) see perldoc perlthrtut.
> >
> >When you fork a child process the call to fork returns the child pid
to
> > the parent and 0 to the child. So you can write code that tests the
return
> > value and does one thing in the parent process (continue forking
children to
> > deal with the rest of your files) and another in the child process
(process
> > the current file). You can also use exec to execute another process
which is
> > not a "clone" of the parent.
> >
> >See perldoc -f fork and perldoc -f exec.
> >
> >Out of curiosity, why do you want to do this?
>
>
> The main loop looks for files which are sent via FTP. Once a file is on
> the server, it should be encrypted. The encryption process is slow so
> some files stay as plain text waiting for their turns to be found and
> encrypted.
>



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: How to thread in Perl?

2002-03-26 Thread Chas Owens

To my knowledge the only limit is what your OS can handle.

On Tue, 2002-03-26 at 14:53, perl wrote:
> Is there a limit to the number of children in Perl?
> 
> 
> "Ahmed Moustafa" <[EMAIL PROTECTED]> wrote in message
> [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> > Tagore Smith wrote:
> >
> > > Ahmed Moustafa wrote:
> > >
> > >
> > >>So, how can a new different process by forked? Or, how a function be
> > >>called and the next step execute without waiting for the previous
> > >>function to terminate?
> > >>
> > >
> > >For your original question (threads) see perldoc perlthrtut.
> > >
> > >When you fork a child process the call to fork returns the child pid
> to
> > > the parent and 0 to the child. So you can write code that tests the
> return
> > > value and does one thing in the parent process (continue forking
> children to
> > > deal with the rest of your files) and another in the child process
> (process
> > > the current file). You can also use exec to execute another process
> which is
> > > not a "clone" of the parent.
> > >
> > >See perldoc -f fork and perldoc -f exec.
> > >
> > >Out of curiosity, why do you want to do this?
> >
> >
> > The main loop looks for files which are sent via FTP. Once a file is on
> > the server, it should be encrypted. The encryption process is slow so
> > some files stay as plain text waiting for their turns to be found and
> > encrypted.
> >
> 
> 
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
-- 
Today is Setting Orange the 12nd day of Discord in the YOLD 3168
Grudnuk demand sustenance!

Missile Address: 33:48:3.521N  84:23:34.786W


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: How to thread in Perl?

2002-03-26 Thread Ahmed Moustafa

Chas, thanks a lot for your example.

if the while loop is inside a main infinite loop (as if it was a 
daemon), do I still need to have the waitpid function? and if yes, where 
should be located?

Once again, thanks a lot!


Chas Owens wrote:
> On Tue, 2002-03-26 at 01:14, Ahmed Moustafa wrote:
> Fork returns 0 to the child process and the pid of the child process to
> the parent.  This allows you to say things like
> 
> my @children;
> #loop while get_filename retruns a vaild filename
> #this could easily be a foreach loop of @filenames
> while (my $filename = get_filename()) { 
>   my $forked = fork; #fork into two processes(parent and child)
> 
>   #if $forked is undef then fork failed
>   unless (defined $forked) {
>   warn "something went wrong with fork";
>   next;
>   } 
> 
>   #push the PID of the child onto a stack
>   push @children, $forked; #meaningless for child
>   
>   next if $forked; #parent loops
> 
>   #only the child can get here 
>   encrypt_the_file($filename);
> 
>   #child ends execution here
>   exit 0;
> }
> 
> #reap the children to avoid zombies
> waitpid $_ for (@children);


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: How to thread in Perl?

2002-03-26 Thread Chas Owens

I wrote some experimental code and it looks like you don't have to reap
the children (maybe this is just a C thing).

On Tue, 2002-03-26 at 15:56, Ahmed Moustafa wrote:
> Chas, thanks a lot for your example.
> 
> if the while loop is inside a main infinite loop (as if it was a 
> daemon), do I still need to have the waitpid function? and if yes, where 
> should be located?
> 
> Once again, thanks a lot!

-- 
Today is Setting Orange the 12nd day of Discord in the YOLD 3168
Kallisti!

Missile Address: 33:48:3.521N  84:23:34.786W


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




FW: How to thread in Perl?

2002-03-27 Thread Richard Smith


Actually, it is a *NIX thing.  There are non-blocking ways to reap 
children, at least in most modern *NIX systems. You probably also want to 
look at the documentation for the wait() function.  It may explain why your 
experiment appeared to work.  Anybody know how to do non-blocking waits in 
perl?  I couldn't find anything, unless system() is used somehow.
Thanx,
Smiddy

-Original Message-
From:   Chas Owens [SMTP:[EMAIL PROTECTED]]
Sent:   Tuesday, March 26, 2002 5:08 PM
To: Ahmed Moustafa
Cc: [EMAIL PROTECTED]
Subject:    Re: How to thread in Perl?

I wrote some experimental code and it looks like you don't have to reap
the children (maybe this is just a C thing).



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: How to thread in Perl?

2002-03-27 Thread Ahmed Moustafa

Chas Owens wrote:
> I wrote some experimental code and it looks like you don't have to reap
> the children (maybe this is just a C thing).

So, is it OK to fork processes without using waitpid?

In general, how are the servers (from the fork perspective - 
multithreading handling -) implemented in Perl?

> 
> On Tue, 2002-03-26 at 15:56, Ahmed Moustafa wrote:
> 
>>Chas, thanks a lot for your example.
>>
>>if the while loop is inside a main infinite loop (as if it was a 
>>daemon), do I still need to have the waitpid function? and if yes, where 
>>should be located?


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: How to thread in Perl?

2002-03-28 Thread Chas Owens

On Wed, 2002-03-27 at 20:40, Ahmed Moustafa wrote:
> Chas Owens wrote:
> > I wrote some experimental code and it looks like you don't have to reap
> > the children (maybe this is just a C thing).
> 
> So, is it OK to fork processes without using waitpid?
> 
> In general, how are the servers (from the fork perspective - 
> multithreading handling -) implemented in Perl?
> 



If you "fork" without ever waiting on your children, 
you will accumulate zombies.  On some systems, you 
can avoid this by setting "$SIG{CHLD}" to ""IGNORE"".
See also the perlipc manpage for more examples of forking 
and reaping moribund children.


Given the above statement I would first try and see 
if setting $SIG{CHLD} to 'IGNORE' keeps anything bad
from happening.  Barring that I would keep a list of 
all forked children and wait on them during idle time.

Another possible solution would be to use the POE
modules.  I have tried to use the once for a Gtk/Gnome
based application that I wanted to be multi-threaded, 
but ran into errors with the Gnome module (and subsequently
found a different way to get around the problem I wanted
multi-threading for).  I know there was someone on this 
list with much more experience with POE than I; maybe he
will speak up.

-- 
Today is Boomtime the 14th day of Discord in the YOLD 3168
You are what you see.

Missile Address: 33:48:3.521N  84:23:34.786W


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




OT: Old uunet gag was Re: How to thread in Perl?

2002-04-15 Thread drieux


On Monday, April 15, 2002, at 03:56 , Ahmed Moustafa wrote:
[..]
>> Missile Address: 33:48:3.521N  84:23:34.786W
>
> By the way, what is the Missile Address?


that is the lattitude and longitude of where the server
is suppose to be located - an old habit from the UUNET
entries into the UUMAPS - that has held on by some

in essence, if you really want to 'do me in' this is
the general area to target the missile.

ciao
drieux

---


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: OT: Old uunet gag was Re: How to thread in Perl?

2002-04-16 Thread Chas Owens

On Mon, 2002-04-15 at 19:32, drieux wrote:
> 
> On Monday, April 15, 2002, at 03:56 , Ahmed Moustafa wrote:
> [..]
> >> Missile Address: 33:48:3.521N  84:23:34.786W
> >
> > By the way, what is the Missile Address?
> 
> 
> that is the lattitude and longitude of where the server
> is suppose to be located - an old habit from the UUNET
> entries into the UUMAPS - that has held on by some
> 
> in essence, if you really want to 'do me in' this is
> the general area to target the missile.
> 
> ciao
> drieux
> 

One of these days I am going to figure out the correct elevation (5th
floor).
 
-- 
Today is Sweetmorn the 33rd day of Discord in the YOLD 3168
This statement is false.

Missile Address: 33:48:3.521N  84:23:34.786W


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: OT: Old uunet gag was Re: How to thread in Perl?

2002-04-16 Thread Jonathan E. Paton

> [..]
> >> Missile Address: 33:48:3.521N  84:23:34.786W
> >
> > By the way, what is the Missile Address?
> 
> that is the lattitude and longitude of where the server
> is suppose to be located - an old habit from the UUNET
> entries into the UUMAPS - that has held on by some
> 
> in essence, if you really want to 'do me in' this is
> the general area to target the missile.

In those days of handheld GPS systems, you could easily
find someone's neighbourhood using missile addresses.
Try this:

http://www.mapquest.com/maps/latlong.adp

or more precisely:

http://www.mapquest.com/maps/map.adp?latlongtype=degrees&latdeg=33&latmin=48&latsec=3&longdeg=-84&longmin=23&longsec=34

Mental note:  Must try this sometime to drop in unexpected
to visit somebody you've never met outside of the virtual
world :)

Jonathan Paton

__
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: OT: Old uunet gag was Re: How to thread in Perl?

2002-04-16 Thread Chas Owens

On Tue, 2002-04-16 at 11:38, Jonathan E. Paton wrote:
> > [..]
> > >> Missile Address: 33:48:3.521N  84:23:34.786W
> > >
> > > By the way, what is the Missile Address?
> > 
> > that is the lattitude and longitude of where the server
> > is suppose to be located - an old habit from the UUNET
> > entries into the UUMAPS - that has held on by some
> > 
> > in essence, if you really want to 'do me in' this is
> > the general area to target the missile.
> 
> In those days of handheld GPS systems, you could easily
> find someone's neighbourhood using missile addresses.
> Try this:
> 
> http://www.mapquest.com/maps/latlong.adp
> 
> or more precisely:
> 
> 
>http://www.mapquest.com/maps/map.adp?latlongtype=degrees&latdeg=33&latmin=48&latsec=3&longdeg=-84&longmin=23&longsec=34
> 
> Mental note:  Must try this sometime to drop in unexpected
> to visit somebody you've never met outside of the virtual
> world :)
> 
> Jonathan Paton

It is amazing what a difference a few tenths of a second make.  Your URL
is about 60 miles off the mark.  This is a better link (uses decimal
long./lat. instead of degrees:minutes:seconds).

http://www.mapquest.com/maps/map.adp?latlongtype=decimal&latitude=33.80097&longitude=-084.3929

Zoom all the way in and flip to the aerial photo for a nice shot of my
office's roof.  The photo appears to be about a year to a year and a
half old (they built some buildings across the street).  Hit south 6
times and you can see my apartment building.

-- 
Today is Sweetmorn the 33rd day of Discord in the YOLD 3168
Or not.

Missile Address: 33:48:3.521N  84:23:34.786W


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: OT: Old uunet gag was Re: How to thread in Perl?

2002-04-16 Thread Ahmed Moustafa

Is there a way to know the Missile Address from an IP address?
--
Ahmed Moustafa
http://pobox.com/~amoustafa


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]