[18637] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 805 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Apr 30 18:17:12 2001

Date: Mon, 30 Apr 2001 15:15:16 -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: <988668916-v10-i805@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Mon, 30 Apr 2001     Volume: 10 Number: 805

Today's topics:
        Remove Adult Files with Perl (BUCK NAKED1)
    Re: Remove Adult Files with Perl (Tad McClellan)
        Retrieve source <klammy@hotmail.com>
    Re: Should Perl be first? (Mark Jason Dominus)
    Re: Strange string -> num conversion <mischief@velma.motion.net>
    Re: Strange string -> num conversion (Rudolf Polzer)
    Re: Strange string -> num conversion (Rudolf Polzer)
        System Call within Daemon - TAKE 2 <mxvera@qwest.com>
    Re: System Call within Daemon - TAKE 2 (Anno Siegel)
    Re: What does qw do? <bart.lateur@skynet.be>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Mon, 30 Apr 2001 13:29:41 -0500 (CDT)
From: dennis100@webtv.net (BUCK NAKED1)
Subject: Remove Adult Files with Perl
Message-Id: <11901-3AEDAF15-116@storefull-242.iap.bryant.webtv.net>

I want to remove all files in a subdirectory of "wkdir" IF they include
one of many defined "bad words." I know this is not a complete solution,
as people can name adult files anything they wish; but at least it's a
start. My webhost doesn't allow adult material, and is peculiar. They
search words and if they find certain words on your site, they just
delete your site. Thus, I have to pad the "dirty words" as I've done
below.

Is this a good solution, or is there a "dirty word" filter script
already out there?

$f = "f0u0c0k"; $f =~ s/0//;
$s = "s0e0x"; $s =~ s/0//;
$wkdir = "wkdir/";
# Remove files with bad words 
use File::Find;
find sub {-f; 
if((my $new = $_) =~ $f | $s ) 
{ unlink $_; }  }, $wkdir ; 

I wrote the above for filtering "dirty" words in filenames, but I'd also
like a script for filtering out "certain" words in all files in a
directory too, if anyone has one.

Thanks,
--Dennis



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

Date: Mon, 30 Apr 2001 16:34:02 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Remove Adult Files with Perl
Message-Id: <slrn9erj1q.hej.tadmc@tadmc26.august.net>

BUCK NAKED1 <dennis100@webtv.net> wrote:

>I want to remove all files in a subdirectory of "wkdir" IF they include
>one of many defined "bad words."

>is there a "dirty word" filter script
>already out there?


---------------------
This discussion has been held here dozens and dozens of times
already. Can you just review what was said then instead of doing
it all yet again?


Searching for "bad words"

   http://groups.google.com/groups?q=bad+words+group:comp.lang.perl.misc

finds boatloads of hits. 
---------------------


Should I just save the above text in a file so I can include it
everytime a new question occurs to you?

You have been here long enough by now to know that you should try
at least a little bit to find the answer yourself *before* posting.


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Mon, 30 Apr 2001 23:51:08 +0200
From: "Jimmy" <klammy@hotmail.com>
Subject: Retrieve source
Message-Id: <9ckmv9$hue$1@news.net.uni-c.dk>

 Hi

 I need to make a program that reads the source of a given URL as a command
 line argument and outputs the source of the given URL and the source of
each
 URL that apears in the source of the given URL.

 Text within HTML tags should not appear in the output.


 Can anyone help me??

 Thanks, Jimmy

--
http://mobi.dk   -  Nettets mest brugervenlige SMS




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

Date: Mon, 30 Apr 2001 18:37:36 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: Should Perl be first?
Message-Id: <3aedb0ef.f43$3b2@news.op.net>

In article <slrn9emlu1.73p.tadmc@tadmc26.august.net>,
Tad McClellan <tadmc@augustmail.com> wrote:
>deja/google really sucks bigtime!
>
>Here is the URL (word wrapped) for the article I want to refer
>people to:
>
>http://groups.google.com/groups?q=first+language+group:comp.lang.perl.misc
>   +author:larry%40kiev.wall.org&hl=en&lr=&safe=off&rnum=1&ic=1
>   &selm=703nm3%24o19%40kiev.wall.org
>
>more that 150 characters.
>
>I guess Google is just going to piss away the market that Deja had...

Try this:

http://groups.google.com/groups?ic=1&selm=703nm3%24o19%40kiev.wall.org

I don't know what the 'ic' was for.


-- 
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print


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

Date: Mon, 30 Apr 2001 19:15:29 -0000
From: Chris Stith <mischief@velma.motion.net>
Subject: Re: Strange string -> num conversion
Message-Id: <tereeh7b3t5s0f@corp.supernews.com>

Bart Lateur <bart.lateur@skynet.be> wrote:
> Chris Stith wrote:

>> It's _documented_ that
>>numbers in bases other than decimal will not be seen as such in
>>string literals. If it's _documented_ that you must do step B to attain
>>goal C, then who cares if one platform differs from another when
>>you didn't perform step B? It's _documented_. It's _Perl_.

> Don't get all worked up.

> And no, it's not documented as such. It is documented that "0x12" as a
> string would not be treated differently than "123var". It *should*
> return zero.

Interesting point. Perhaps it should return zero. In that case,
that part is a bug.

Chris

-- 
Even in the worst of times, there is always someone who's
never had it better. Even in the best of times, there is
always someone who's never had it worse.



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

Date: Mon, 30 Apr 2001 22:42:20 +0200
From: eins@durchnull.de (Rudolf Polzer)
Subject: Re: Strange string -> num conversion
Message-Id: <slrn9erjhb.ge4.eins@www42.t-offline.de>

Chris Stith <mischief@velma.motion.net> wrote:
> Bart Lateur <bart.lateur@skynet.be> wrote:
> > Chris Stith wrote:
> 
> >> It's _documented_ that
> >>numbers in bases other than decimal will not be seen as such in
> >>string literals. If it's _documented_ that you must do step B to attain
> >>goal C, then who cares if one platform differs from another when
> >>you didn't perform step B? It's _documented_. It's _Perl_.
> 
> > Don't get all worked up.
> 
> > And no, it's not documented as such. It is documented that "0x12" as a
> > string would not be treated differently than "123var". It *should*
> > return zero.
> 
> Interesting point. Perhaps it should return zero. In that case,
> that part is a bug.

On my system, the 0x part is parsed as hex number. AFAIK perl uses atof
to get the number... yes, looks like.

#include <stdlib.h>
#include <stdio.h>
int main (int argc, char **argv)
{
 char **p;
 for (p = argv + 1; *p; ++p)
 { 
  printf ("%20.20g\n", atof (*p));
 }
}

This C program works like that (not exactly, but the numbers look like this):

$ x 1
              1
$ x 1.2
1.1999999993273
$ x 0x12
             18
$ x NaN
            nan
$ x iNFInItY
            inf

so C's atof has the same behaviour as perl's implicit string->num conversion.
To those who do _not_ get either 18 or 0 on

perl -e 'print 0 + "0x12"'

: what does the C program do? I would guess the bug is not in perl but in the
C library.


-- 
#!/usr/bin/perl -W -- WARNING: This will print 22,307 bytes! <strictsafe!>
use strict;for(my$y=-1;$y<1;$y+=.1){for(my$x=-1.9;$x<.4;$x+=.03){print'+';
my$X=my$Y=0;for(0..99){($X,$Y)=($X*$X-$Y*$Y+$x,2*$X*$Y+$y);print"\b "if$X*
$X+$Y*$Y>9;}}print"\n"};print''.reverse"\nHPAJ \a!rezloP .R yb torblednaM"


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

Date: Mon, 30 Apr 2001 22:47:10 +0200
From: eins@durchnull.de (Rudolf Polzer)
Subject: Re: Strange string -> num conversion
Message-Id: <slrn9erjqe.jrn.eins@www42.t-offline.de>

Rudolf Polzer <eins@durchnull.de> wrote:

(I deleted the < to increase usability of this code)

#include <stdlib.h>
#include <stdio.h>
int main (int argc, char **argv)
{
 char **p;
 for (p = argv + 1; *p; ++p)
 { 
  printf ("%20.20g\n", atof (*p));
 }
}

I forgot to say: to those who do not know how to compile this:

gcc x.c -o x
    ^^^    î
 .c filename|
           |
	   executable to generate
	   


-- 
#!/usr/bin/perl -W -- WARNING: This will print 22,307 bytes! <strictsafe!>
use strict;for(my$y=-1;$y<1;$y+=.1){for(my$x=-1.9;$x<.4;$x+=.03){print'+';
my$X=my$Y=0;for(0..99){($X,$Y)=($X*$X-$Y*$Y+$x,2*$X*$Y+$y);print"\b "if$X*
$X+$Y*$Y>9;}}print"\n"};print''.reverse"\nHPAJ \a!rezloP .R yb torblednaM"


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

Date: Mon, 30 Apr 2001 16:51:29 -0500
From: Michael Vera <mxvera@qwest.com>
Subject: System Call within Daemon - TAKE 2
Message-Id: <3AEDDE61.94F46311@qwest.com>


--------------06C1E6A50121571AF123B367
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Ok, my question didn't get answered, so please let me try again.

What I need to do is simply fork and exec a system call withOUT the
child inheriting ownership of the socket.

The problem is, within my socket server, if I start a system daemon, the
system daemon takes on ownership of my socket. If my socket server
quits, the system daemon controls the socket, and I can't start the
socket server due to the fact that the socket is already open.

Does anyone know how to solve this? Or can you please point me in the
right direction? What the 'fork'? :)

Thanks!
Mike

P.S. The original message is below:


> Greetings,
>
> I have written a forking socket server, but I need to start other
> daemonized programs with it. The programs are usually started with a
> little script which calls the main daemon, then the little script exits.
>
> The problem I have is that the daemon takes on the properties of my
> socket server such that if I kill the socket server, the socket is still
> in use by the program started by the original socket server. This is bad
> because to start the socket server again, I would need to kill the
> system call to free up the socket.
>
> I believe using exec() would solve this, however, I need to do more
> within the server after the system call, and it seems that exec()
> performs the system call, then skips anything following. I am fairly
> certain I don't know the proper way to implemet exec().
>
> Would anyone have any ideas for me?
>
> Thanks!
> Mike V
>

--------------06C1E6A50121571AF123B367
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
Ok, my question didn't get answered, so please let me try again.
<p><i>What I need to do is simply fork and exec a system call withOUT the
child inheriting ownership of the socket.</i>
<p>The problem is, within my socket server, if I start a system daemon,
the system daemon takes on ownership of my socket. If my socket server
quits, the system daemon controls the socket, and I can't start the socket
server due to the fact that the socket is already open.
<p>Does anyone know how to solve this? Or can you please point me in the
right direction? What the 'fork'? :)
<p>Thanks!
<br>Mike
<p>P.S. The original message is below:
<br>&nbsp;
<blockquote TYPE=CITE>
<pre>Greetings,

I have written a forking socket server, but I need to start other
daemonized programs with it. The programs are usually started with a
little script which calls the main daemon, then the little script exits.

The problem I have is that the daemon takes on the properties of my
socket server such that if I kill the socket server, the socket is still
in use by the program started by the original socket server. This is bad
because to start the socket server again, I would need to kill the
system call to free up the socket.

I believe using exec() would solve this, however, I need to do more
within the server after the system call, and it seems that exec()
performs the system call, then skips anything following. I am fairly
certain I don't know the proper way to implemet exec().

Would anyone have any ideas for me?

Thanks!
Mike V</pre>
</blockquote>
</html>

--------------06C1E6A50121571AF123B367--



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

Date: 30 Apr 2001 21:59:06 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: System Call within Daemon - TAKE 2
Message-Id: <9ckn7a$2t6$4@mamenchi.zrz.TU-Berlin.DE>

According to Michael Vera  <mxvera@qwest.com>:
> -=-=-=-=-=-
> 
> Ok, my question didn't get answered, so please let me try again.

It's not a Perl question.  Maybe that's why.

> What I need to do is simply fork and exec a system call withOUT the
> child inheriting ownership of the socket.

[...]

Close the socket in the child.  It's a good habit to close un-needed
filehandles of any sort after a fork.

Anno


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

Date: Mon, 30 Apr 2001 20:24:03 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: What does qw do?
Message-Id: <sciretkaa4bp3ejhtuta3utbbectnhpnsg@4ax.com>

J. Cooper wrote:

>I'm trying to understand some Perl code, and have come across
>qw(http:// ....).  I can't seem to find any reference to qw, can
>anyone tell me what it does?

Quote a string and split into words (i.e. split on whitespace). No
interpolation. Warns if the string includes a comma.

	@ary = qw($foo bar @baz);

is like

	@ary = ('$foo', 'bar', '@baz');


The documentation is mainly in perlop.

-- 
	Bart.


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

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


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