[17625] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5045 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Dec 6 11:05:34 2000

Date: Wed, 6 Dec 2000 08:05:11 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <976118711-v9-i5045@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Wed, 6 Dec 2000     Volume: 9 Number: 5045

Today's topics:
    Re: A sort of another color -- a Tale, not a question ; (Tad McClellan)
        add a key and its value to a hash <olivier@aersoft.com>
    Re: add a key and its value to a hash (Bernard El-Hagin)
    Re: add a key and its value to a hash <tony_curtis32@yahoo.com>
    Re: add a key and its value to a hash <olivier@aersoft.com>
    Re: array of unique random numbers <iltzu@sci.invalid>
    Re: find function (Tad McClellan)
        getting upper bound of two dimensional arraydimens dts@netkonnect.net
    Re: getting upper bound of two dimensional arraydimens <josef.moellers@fujitsu-siemens.com>
        help reading a "pst" mail file <vino@grapevine.com>
    Re: How can I read a variable without evaluating it ? <jboes@eoexchange.com>
        How do I bring up the printer dialog via perl? <djberg96@my-deja.com>
    Re: How do you convert a Perl script to binary executab (Tad McClellan)
    Re: How do you convert a Perl script to binary executab (Flint Slacker)
    Re: how to check if there is text in an input text fiel (Flint Slacker)
    Re: kill and security (suid) (Anno Siegel)
    Re: Object member variables (Tad McClellan)
    Re: Object member variables (Tad McClellan)
        PERL based Web Application Servers <alavoor@yahoo.com>
    Re: PERL based Web Application Servers <wbrock@owc.net>
        Perl interface to Network Associates PGP SDK? (Ron Newman)
    Re: Problem using Net::FTP (Anno Siegel)
        Problems in embedded perl with LC_NUMERIC <thehobbit@altern.org>
    Re: Profanity Check <tick.toff@spam.com>
    Re: Profanity Check <dontspamme@awdang.com>
    Re: Profanity Check (Tad McClellan)
    Re: Profanity Check <jfeuerst@eecs.tufts.edu>
    Re: random caracters (Tad McClellan)
    Re: Random password generator gls@byu.edu
        Size of a folder <meej@sol.dk>
        Use PERL or Java? Which is faster? <alavoor@yahoo.com>
    Re: Using 'require' and performance gains (Rafael Garcia-Suarez)
    Re: Using 'require' and performance gains <c.manley@chello.nl>
    Re: Willing to review a 90 line Perl program? (Tad McClellan)
        windows scripting components with ActiveState <ray.rizzuto@ulticom.com>
    Re: Your help please <katie.foster@bt.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Wed, 6 Dec 2000 08:05:12 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: A sort of another color -- a Tale, not a question ;)
Message-Id: <slrn92sec8.phs.tadmc@magna.metronet.com>

The WebDragon <nospam@nospam.com> wrote:
>In article <2lcX5.77$T3.170845184@news.frii.net>, 
>cfedde@fedde.littleton.co.us (Chris Fedde) wrote:
>
> | Do you need to sort the 'huge body of data' each time that it is
> | accessed?  If you write out the 'manufactured key' array as a flat
> | file can it be re-loaded faster than it can be regenerated?
> | 


What Chris is suggesting is the standard technique of creating
an "index" into the real data.


>Yes, I need to sort through it each time, 


That (attempts to) answer the first question asked.

How about that second question?

A "test" to see if indexing will help is to compare how long it
takes to read the index to how long it takes to generate the index.
That is the reason for the second question.

(a further consideration is how often the data is changed, or
 how current the data must be, to evaluate how often the index
 would need to be regenerated. That is the reason for the
 first question :-)
)


I do not see anything that precludes you from using an
indexing technique. I wouldn't dismiss the idea just yet.


>for two reasons: 
>
>one, I can't pre-add the sortkey to the datafile 
                                  ^^^^^^^^^^^^^^^

He didn't suggest that.

He suggested making a file containing the index. He didn't say
anything about embedding the indexing info in the real data file.


>in advance simply 
>because (if you look) you will see that the sort key is created 
>differently depending on whether I sort by title or by rating & title.


So you could just create two index files then.


>two, while it currently accesses a flat-file, eventually (one hopes) the 
>script will be used to access a SQL database directly via the DBI 
>modules, thereby rendering the flat-file irrelevant. 


RDBMSs do indexing _for you_.

You would get improved performance "for free" when that happens.


>ahhhhhhhhhhhhhhhhhh. But it sucks at the moment since 
>the SQL database is on an NT/2000 hybrid network that has no Perl 
>install (nor do they seem interested. bleh. :P)) which takes forever to 
>deal with manually, but what else can I do? :)
                         ^^^^^^^^^^^^^^^^^^


Polish up your resume?   heh.


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


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

Date: Wed, 06 Dec 2000 15:11:21 GMT
From: Olivier Dupouy <olivier@aersoft.com>
Subject: add a key and its value to a hash
Message-Id: <3A2E580A.97EAC9A9@aersoft.com>

That seems to be very simple but I can't manage who to do it. I would
like to add a key and its value to a hash.
Well, If i create an empty hash, I would like to fill the hash
dynamicly.
Thinks all
Olivier



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

Date: Wed, 6 Dec 2000 15:13:49 +0000 (UTC)
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: add a key and its value to a hash
Message-Id: <slrn92slqr.9v.bernard.el-hagin@gdndev25.lido-tech>

On Wed, 06 Dec 2000 15:11:21 GMT, Olivier Dupouy <olivier@aersoft.com>
wrote:
>That seems to be very simple but I can't manage who to do it. I would
>like to add a key and its value to a hash.
>Well, If i create an empty hash, I would like to fill the hash
>dynamicly.

Why not just:

$hash{'key'} = value;

or

$key = "my key";
$value = "my value";

$hash{$key} = $value;

Cheers,
Bernard
--
perl -le '$#="Just Another Perl Hacker"; print \Bernard'


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

Date: 06 Dec 2000 09:14:55 -0600
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: add a key and its value to a hash
Message-Id: <87r93lbmz4.fsf@limey.hpcc.uh.edu>

>> On Wed, 06 Dec 2000 15:11:21 GMT,
>> Olivier Dupouy <olivier@aersoft.com> said:

> That seems to be very simple but I can't manage who to
> do it. I would like to add a key and its value to a
> hash.  Well, If i create an empty hash, I would like to
> fill the hash dynamicly.

$hash{$key} = $value;

That's all there is to it.  Unless you mean something
else.

hth
t
-- 
Eih bennek, eih blavek.


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

Date: Wed, 06 Dec 2000 15:47:51 GMT
From: Olivier Dupouy <olivier@aersoft.com>
Subject: Re: add a key and its value to a hash
Message-Id: <3A2E6098.C38F52BE@aersoft.com>

That works pretty well
Cheers
Olivier

PS: thinks Tony also

Bernard El-Hagin wrote:

> On Wed, 06 Dec 2000 15:11:21 GMT, Olivier Dupouy <olivier@aersoft.com>
> wrote:
> >That seems to be very simple but I can't manage who to do it. I would
> >like to add a key and its value to a hash.
> >Well, If i create an empty hash, I would like to fill the hash
> >dynamicly.
>
> Why not just:
>
> $hash{'key'} = value;
>
> or
>
> $key = "my key";
> $value = "my value";
>
> $hash{$key} = $value;
>
> Cheers,
> Bernard
> --
> perl -le '$#="Just Another Perl Hacker"; print \Bernard'



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

Date: 6 Dec 2000 14:20:53 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: array of unique random numbers
Message-Id: <976110806.15148@itz.pp.sci.fi>

In article <slrn92s85o.80s.abigail@tsathoggua.rlyeh.net>, Abigail wrote:
>On 5 Dec 2000 19:13:22 GMT, Ilmari Karonen (iltzu@sci.invalid) wrote in comp.lang.perl.misc <URL: news:<976039986.23027@itz.pp.sci.fi>>:
>++ 
>++ I don't see much hope for nonuniform selectors.  The algorithm is
>++ still a Fisher-Yates shuffle underneath, and therefore assumes a
>++ uniform distribution.  I can think of no simple way to change that.
>
>That's the point I was trying to make.

Acknowledged.  One can't have everything.


>++ As for domains other than integer ranges, there are two general cases
>++ in which most situations fall.  If the domain is conceptually finite,
>++ one could just use the algorithm to generate a sequence of integers
>++ and then map them to the desired domain.
>
>Well, the domain of the integers isn't finite. I think you might mean
>countable.

No, I mean finite.  That's why I specified integer _ranges_ (bounded
sets of integers, to state it more precisely), though I seem to have
snipped the paragraph where I dicussed this explicitly.

The algorithm I presented is good for picking a sequence of unique,
uniformly distributed elements from a finite set, even if the set is
too large to be held in memory, in time proportional to the number of
elements picked.  (That's assuming constant time hash access, which
isn't really possible but is a reasonable first approximation.)

It's not good for non-uniform selectors, and the problem it solves
could be considered meaningless for (conceptually) infinite domains.
It also requires prior knowledge of the size of the domain.

-- 
Ilmari Karonen -- http://www.sci.fi/~iltzu/
"Get real!  This is a discussion group, not a helpdesk.  You post
 something, we discuss its implications.  If the discussion happens to
 answer a question you've asked, that's incidental." -- nobull in clpm



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

Date: Wed, 6 Dec 2000 06:22:41 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: find function
Message-Id: <slrn92s8c1.phs.tadmc@magna.metronet.com>

[ Please put your comments *following* the quoted text that
  you are commenting on.
]


ale@skate.mailbr.com.br <ale@skate.mailbr.com.br> wrote:
>
>So I want to know how to do not output directories as result.
>
>how do I eliminate c:\temp
>and all its subdirectories?


Use a file test along with an if() statment:

   perldoc -f -d


[ snip Jeopardy-quoted text ]

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


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

Date: Wed, 06 Dec 2000 15:35:47 GMT
From: dts@netkonnect.net
Subject: getting upper bound of two dimensional arraydimens
Message-Id: <90lmci$bbj$1@nnrp1.deja.com>

I am trying to retrieve both dimensions of a 2D array.

I have read in a Perl book that with the following I can get the
dimension of a 1D array:

@result=(1,2,4);
$rows=$#result;

but I cannot find a way to do it for a 2D array.

any suggestions would be most appreciated

TIA
dan


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Wed, 06 Dec 2000 17:03:40 +0100
From: Josef Moellers <josef.moellers@fujitsu-siemens.com>
Subject: Re: getting upper bound of two dimensional arraydimens
Message-Id: <3A2E635C.F270E280@fujitsu-siemens.com>

dts@netkonnect.net wrote:
> =

> I am trying to retrieve both dimensions of a 2D array.
> =

> I have read in a Perl book that with the following I can get the
> dimension of a 1D array:
> =

> @result=3D(1,2,4);
> $rows=3D$#result;
> =

> but I cannot find a way to do it for a 2D array.
> =

> any suggestions would be most appreciated

My understanding is that all "rows" are independent, i.e. you can have
rows of different lengths.

-- =

Josef M=F6llers (Pinguinpfleger bei FSC)
	If failure had no penalty success would not be a prize (T.  Pratchett)


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

Date: Wed, 06 Dec 2000 15:59:57 GMT
From: "vino" <vino@grapevine.com>
Subject: help reading a "pst" mail file
Message-Id: <1otX5.41877$II2.3779709@newsread2.prod.itd.earthlink.net>

I'm looking for information about reading a mail file of the "outlook" type,
or "pst".  I've looked around 'perlmongers', but am not finding what I need.

I need to read a 'pst' file, and put each email into a seperate file, and
strip the headers/footers and misc junk.  Actually, all I need is the body
of the message in a text format.

OK, I'm a newbie, so flame me if you must, but help me if you can, and
thanks in advance...

Michael

(NOSPAMmwine@portal-connectNOSPAM)




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

Date: Wed, 06 Dec 2000 10:17:51 -0500
From: "Jeff Boes" <jboes@eoexchange.com>
Subject: Re: How can I read a variable without evaluating it ?
Message-Id: <3a2e5922$0$30003$44a10c7e@news.net-link.net>

Unless my newsreader has been taken over by the Illuminati, I think
"Marcelo Montagna" <nospam@me.com> babbled:

> Hello everyone,
> 
> I have a hash like
> 
> MyHash = (
> 	FirstName	=> $FORM{fname}, Email		=> $FORM{email}
> );
> 
> Now, I'd like to know what value is assigned to each key, without
> evaluating it, I mean, something that will return exactely
> "$FORM{email}" (Dollar sign, letter "F",...etc) as a string and not its
> value.
> 
> I'm sure it must be possible, but after hours searching the net, I
> couldn't find a way to do it.
> 

No, not really. I would recommend a different approach, e.g.,

%MyHash = (
   FirstName => 'fname',
   Email => 'email',
   );

Now you can get at the stuff you want using

$foo = '$Form{' . $MyHash{$key} . '}';

and still find the actual values via

$val = $Form{$MyHash{$key}};



-- 
Jeff Boes <jboes@eoexchange.com>          Tel:  (616) 381-9889 x.18
Sr. Software Engineer, EoExchange, Inc.   http://www.eoexchange.com/
Search, Monitor, Notify.                  http://www.eomonitor.com/


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

Date: Wed, 06 Dec 2000 15:11:48 GMT
From: Daniel Berger <djberg96@my-deja.com>
Subject: How do I bring up the printer dialog via perl?
Message-Id: <90lkvd$a52$1@nnrp1.deja.com>

Hi all,

I'm using perl on an NT machine, and I would like to know how to bring
up the 'standard' printer dialog box that comes up whenever a program,
such as Word, selects the "Print" option.

Thanks in advance.

Dan

--
In the immortal words of Socrates, "I drank what?"


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Wed, 6 Dec 2000 06:32:40 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: How do you convert a Perl script to binary executable in Linux?
Message-Id: <slrn92s8uo.phs.tadmc@magna.metronet.com>

Craig Manley <c.manley@chello.nl> wrote:

>I'm looking for a way to convert my Perl CGI scripts to binaries to
>speed up processing time. 


That is likely to be a lot of work for a very small speed gain.


>I've tried converting the Perl scripts to C
>but the C code doesn't compile. 


Perl FAQ, part 3:

   "How can I compile my Perl program into byte code or C?"
   ...
   Merely compiling into C does not in and of itself guarantee that your
   code will run very much faster.


Also, Perl FAQ part 3:

   "How can I make my Perl program run faster?"
   ...
   The best way to do this is to come up with a better algorithm.


Other alternatives to make it "faster":

   use mod_perl and the Apache web server

   profile the code then for the "slow parts" either:

      devise a better algorithm

      write that part in C and call it from Perl



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


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

Date: Wed, 06 Dec 2000 14:45:14 GMT
From: flint@flintslacker.com (Flint Slacker)
Subject: Re: How do you convert a Perl script to binary executable in Linux?
Message-Id: <3a32509c.172084731@news.tcn.net>

>Hi,
>
>I'm looking for a way to convert my Perl CGI scripts to binaries to
>speed up processing time. I've tried converting the Perl scripts to C

perlcc will help compile it, however the speed increase on all the
programs I have tried, haven't convinced me to stop using C.

Flint


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

Date: Wed, 06 Dec 2000 14:36:38 GMT
From: flint@flintslacker.com (Flint Slacker)
Subject: Re: how to check if there is text in an input text field?
Message-Id: <3a2f4e32.171467095@news.tcn.net>

On Tue, 05 Dec 2000 19:09:36 GMT, alazarev1981@my-deja.com wrote:


>$text = cgi->param('text');
>
>Then I want to print that text to a new file if and only if that field
>has text in it. So I wrote the following line:
>if($text != "") {
>  print NEW_FILE "Your new text is here: $text";
>}

You might want to strip away whitespace before testing the field, to
prevent people form just hitting the space bar.

$text =~ s/^\s+//;
$text =~ s/\s+$//;

if(! $text) {
	# Error


Flint


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

Date: 6 Dec 2000 14:55:18 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: kill and security (suid)
Message-Id: <90lk0m$4i7$1@lublin.zrz.tu-berlin.de>

Rick Delaney  <rick.delaney@home.com> wrote in comp.lang.perl.misc:
>
>Anno Siegel wrote:
>> 
>> Rick Delaney  <rick.delaney@home.com> wrote in comp.lang.perl.misc:
>> >
>> >Anno Siegel wrote:
>> >>
>> >> Chris Fedde <cfedde@fedde.littleton.co.us> wrote in comp.lang.perl.misc:
>> >> >In article <87k89ftryb.fsf@nujoma.perrins>,
>> >> >Andrew J. Perrin <aperrin@demog.berkeley.edu> wrote:
>> >> >>
>> >> >>system("/bin/kill $_") foreach (split(/\s+/,$pppds));
>> >> >>
>> >> >    system('/bin/kill', '-TERM', $_);  # called with proper switch
>> >>
>> >> Indeed.  The system() variant couldn't work the way the OP wrote it.
>> >
>> >Why not?  It works for me on a Linux box where SIGTERM is the default
>> >signal for kill.
>
>I suppose I should have written kill(1).

Oh, right.  I had my wires crossed.

Anno


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

Date: Wed, 6 Dec 2000 06:49:21 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Object member variables
Message-Id: <slrn92s9u1.phs.tadmc@magna.metronet.com>

Jan van Mansum <jvm@ysabel.com> wrote:
>
>
>I want to create two instances of the same class and use them like this:
>
>$o1 = MyClass->new("1");
>$o2 = MyClass->new("2");
>$o1->printvalue();
>$o2->printvalue();
>
>In the MyClass pacakage I have defined a variable (which is supposed to
>be a non-static member variable):
>
>package MyClass;
>
>$member; # (my,local, ...???)
>sub new
>{
>    my $class = shift;
>    return bless {}, $class;

>
>The program prints "2" twice, so I suppose $member is a static class
>variable. How can I declare it to be non-static (or fake a non-static
>variable), that is to say make it unique for each instance of MyClass?


Put the instance variable in the hash:

   return bless { member = shift }, $class;



See also perlboot.pod:

=head2 More interesting instances

What if an instance needs more data?  
 ...
  my $bad = bless { Name => "Evil", Color => "black" }, Sheep;

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


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

Date: Wed, 6 Dec 2000 08:27:00 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Object member variables
Message-Id: <slrn92sfl4.prg.tadmc@magna.metronet.com>

I myself <tadmc@metronet.com> wrote:

>   return bless { member = shift }, $class;
                          ^

Doh!

   return bless { member => shift }, $class;


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


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

Date: Wed, 06 Dec 2000 15:52:23 GMT
From: Al Dev <alavoor@yahoo.com>
Subject: PERL based Web Application Servers
Message-Id: <3A2E60D0.D87466A9@yahoo.com>

Can you recommed any PERL based Web Application Servers.
I am planning to use PERL on linux.





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

Date: Wed, 06 Dec 2000 16:00:37 GMT
From: Wally Brock <wbrock@owc.net>
Subject: Re: PERL based Web Application Servers
Message-Id: <3A2E62F9.2996CA23@owc.net>

Mason

http://www.masonhq.com

Al Dev wrote:

> Can you recommed any PERL based Web Application Servers.
> I am planning to use PERL on linux.



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

Date: Wed, 06 Dec 2000 09:35:08 -0500
From: rnewman@thecia.net (Ron Newman)
Subject: Perl interface to Network Associates PGP SDK?
Message-Id: <rnewman-0612000935080001@ppp39-198.thecia.net>

I am looking for a Perl module that interfaces with the
Network Associates PGP Software Development Kit (SDK)'s 
C language API.    Does anyone here know of such a module?

-- 
Ron Newman        rnewman@thecia.net
http://www2.thecia.net/users/rnewman/


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

Date: 6 Dec 2000 15:43:21 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Problem using Net::FTP
Message-Id: <90lmqp$4l5$1@lublin.zrz.tu-berlin.de>

Tadeusz Zwolinski <Tadeusz.Zwolinski@rzeszow.tpsa.pl> wrote in comp.lang.perl.misc:
>I wrote program which gets the file from ftp server.
>If there is a probem during transfer, program exits with error:
>"Timeout at C:/Perl/site/lib/Net/FTP.pm line 382"
>What should I do to made condition  'if(!$ftp->get("file"))'
>works properly and returns program to begining of the loop?

This sounds like a perfect occasion to bring up the rarely used
"redo" operator.  It re-starts the current pass around the loop
without changing the loop variables, so if the loop is written
right it would try to fetch the same file again.  The "redo" operator
is described in perlsyn.

[code snipped]

Anno


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

Date: 06 Dec 2000 15:44:16 +0100
From: Frodo Baggins <thehobbit@altern.org>
Subject: Problems in embedded perl with LC_NUMERIC
Message-Id: <874s0hvccf.fsf@shire.univ-pau.fr>

Hi all,
  I have a funny problem...  If executed with a LANG variable who
forces using comma instead of dot for decimal point, the following
embedded perl program fail, stating that 

Perl lib version (5.00503) doesn't match executable version (5,00503)
at /usr/lib/perl5/5.005/i386-linux/Config.pm line 7.

(note the comma in executable version....) that's weird:) Everithing
goes well if I set LC_NUMERIC to C... Anyone encountred it before?
Should I fill a bug report? 

10x a lot
-- 
Leo "TheHobbit"

I am the "ILOVEGNU" signature virus. Just copy me to your signature.
This email was infected under the terms of the GNU General Public License.


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

Date: Wed, 06 Dec 2000 14:14:54 GMT
From: "SuperGumby" <tick.toff@spam.com>
Subject: Re: Profanity Check
Message-Id: <yRrX5.7009$xW4.58343@news-server.bigpond.net.au>

Teacher Guy may find his heiney in a sling if he doesn't replace his
profanity with less offensive material on his next post.

Teacher Guy wrote in message <90lfst$5k3$1@nnrp1.deja.com>...
>Hello.  I have set up a Perl message board on our school's website and
>I need to add a profanity check to subject and body sections.  I need
>code that will check for all instances of a word.  For example, I need
>to account for mixed upper and lower case possibilites  (ex. BAStard,
>BASTARd, Bastard, etc.).   Here is the code that works so far:
>
># body profanity check





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

Date: Wed, 6 Dec 2000 08:03:58 -0600
From: "LimboStar" <dontspamme@awdang.com>
Subject: Re: Profanity Check
Message-Id: <3a2e4cd3@news.cc.umr.edu>

> if (($FORM{'body'} =~ /fuck/)||($FORM{'body'} =~ /asshole/)||($FORM
> {'body'} =~ /slut/)|
>
> Can I convert all data to uppercase prior to checking for words????

Sure, but better to use a case-insensitive pattern match:

  $text =~ m/badword/i;

Personally, I'd put the words to check for in an array and iterate through
it:

  my @badword = qw(darn shoot dang dork idgit);
  my $flag;
  foreach (@badword)
    { $flag = 1, last if $text =~ m/$_/i; }
  if (defined $flag)
  {
    # bad word found, do something here
  }

HTH,

--sjd;




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

Date: Wed, 6 Dec 2000 08:46:14 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Profanity Check
Message-Id: <slrn92sgp6.prg.tadmc@magna.metronet.com>

Teacher Guy <habfan2@my-deja.com> wrote:

>I need to add a profanity check to subject and body sections. 


This has been discussed here before, even though the central
problem is not related to Perl.

A power search at deja for "bad words" (with the quotes) in
clpmisc finds 2 previous threads.


The "Perl part" of what you want to do is easy, and is, in fact,
a Frequently Asked Question:

   "How do I efficiently match many regular expressions at once?"

Your biggest problem is in deciding what to check for.

The usual approach of maintaining a simple list of bad words is
not completely adequate in the face of such things as:

   f-u-c-k
   f u c k
   phuck
   fuk
   infuckingcredible

The best you can hope for is catching only _some_ of the "bad words".
Along with finding "false hits" where you reject when there isn't
really any profanity.


># body profanity check
>if (($FORM{'body'} =~ /fuck/)||($FORM{'body'} =~ /asshole/)||($FORM
>{'body'} =~ /slut/)|
>
>Can I convert all data to uppercase prior to checking for words????


Yes, but you don't need to.

You can make the pattern match itself ignore case without
altering the data.

You can combine the multiple matches into a single match too:

   if ( $FORM{'body'} =~ /(fuck|asshole|slut)/i )

You should probably put some word boundaries in there too.

Wouldn't want to match just because they mentioned "Joe Verslutten":

   if ( $FORM{'body'} =~ /\b(fuck|asshole|slut)\b/i )



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


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

Date: Wed, 06 Dec 2000 14:57:09 GMT
From: Jozxyqk <jfeuerst@eecs.tufts.edu>
Subject: Re: Profanity Check
Message-Id: <9tsX5.73850$751.1840367@typhoon.ne.mediaone.net>

> Along with finding "false hits" where you reject when there isn't
> really any profanity.

Yeah, especially when youre trying to catch letter combinations like "ass".
Your cl*** won't be able to write alot of normal words. ;)



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

Date: Wed, 6 Dec 2000 08:50:37 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: random caracters
Message-Id: <slrn92sh1d.prg.tadmc@magna.metronet.com>

Per- Fredrik Pollnow <Per-fredrik.Pollnow@epk.ericsson.se> wrote:

>I  search the web bot found nothing.


There is a function for converting numbers to characters 
(ASCII usually):

   perldoc -f chr


>My question is, how to I random characters like [a-zA-Z] ?? I have done the
>rand with the numbers:

   my @chars = ( 'a'..'z', 'A'..'Z' );

Generate a random (integer) index between zero and $#chars inclusive.

Use that to index into the @chars array.


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


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

Date: 06 Dec 2000 08:42:19 -0700
From: gls@byu.edu
Subject: Re: Random password generator
Message-Id: <u66kx8skk.fsf@SNOW.i-did-not-set--mail-host-address--so-shoot-me>

SimBean <schneider@xtewa.de> writes:


> > >I am using WinNT!!!
> > Sorry to hear that.
> > But you have perl, don't you?  :-)
> I even compiled it myself!!! *proud*
> It just took me 4 hours to do so ... :)
> 
> > Write 'grep' in Perl:
> Cool, I'll try that ...

You might also want to check out:
http://language.perl.com/ppt/
For the tools that nobody should be without, and now if they have
Perl, they don't need to.

--
---------------------------------------------------------------------
 Dr. Gregory L. Snow         |  Inertia makes the world go round,
     (Greg)                  |   Love makes the trip worth taking.
   gls@byu.edu               |
---------------------------------------------------------------------


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

Date: Wed, 06 Dec 2000 15:30:06 -0000
From: IJ <meej@sol.dk>
Subject: Size of a folder
Message-Id: <t2smru3am5gfa1@corp.supernews.com>

Hi everybody,

Any body knows how can I get size of a folder, seems to be completely 
different than file handling.
If somebody have a ready script/suggestion for this please drop it to me 
as soon as possible.
meej@sol.dk



--
Posted via CNET Help.com
http://www.help.com/


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

Date: Wed, 06 Dec 2000 15:54:37 GMT
From: Al Dev <alavoor@yahoo.com>
Subject: Use PERL or Java? Which is faster?
Message-Id: <3A2E6155.C2273626@yahoo.com>

I am planning to use either or PERL or Java for a new web application
which will
run on RedHat Linux.

Any suggestions on which runs faster - PERL or Java??
Speed is more important (top priority)



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

Date: Wed, 06 Dec 2000 14:54:12 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: Using 'require' and performance gains
Message-Id: <slrn92skqa.1uh.rgarciasuarez@rafael.kazibao.net>

Craig Manley wrote in comp.lang.perl.misc:
> 
> I've got a CGI script that uses a class that contains 6 different and
> huge action handling functions. Only one action is executed per web
> request. So my thought is: how much performance gain (or maybe loss) can
> I expect if I place these 6 action handling functions each into seperate
> files so that the class will load the correct file at runtime using
> 'require'?

This depends on your script. Does it load a number of other huge
modules? Does it perform heavy computational tasks? Is the compilation
phase of the script the actual bottleneck?

If you don't want to split your library file, you can turn it into a
module and use the SelfLoader module (see the docs). The opertion is
simple and works pretty well.

> Perl must interpret the file loaded at runtime with 'require'. How much
> overhead this causes (if any) I don't know, because I don't know much
> about the internal operating of Perl.

There is no overhead of 'require' vs 'use'.

-- 
# Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/


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

Date: Wed, 06 Dec 2000 16:20:50 +0100
From: Craig Manley <c.manley@chello.nl>
Subject: Re: Using 'require' and performance gains
Message-Id: <3A2E5952.6B6CCF00@chello.nl>

Rafael Garcia-Suarez wrote:
> 
> Craig Manley wrote in comp.lang.perl.misc:
> >
> > I've got a CGI script that uses a class that contains 6 different and
> > huge action handling functions. Only one action is executed per web
> > request. So my thought is: how much performance gain (or maybe loss) can
> > I expect if I place these 6 action handling functions each into seperate
> > files so that the class will load the correct file at runtime using
> > 'require'?
> 
> This depends on your script. Does it load a number of other huge
> modules? Does it perform heavy computational tasks? Is the compilation
> phase of the script the actual bottleneck?

Compilation is the only real bottleneck.


> If you don't want to split your library file, you can turn it into a
> module and use the SelfLoader module (see the docs). The opertion is
> simple and works pretty well.

Thanks for the advice - I just read about SelfLoader and AutoLoader and
will use one of them.


> > Perl must interpret the file loaded at runtime with 'require'. How much
> > overhead this causes (if any) I don't know, because I don't know much
> > about the internal operating of Perl.
> 
> There is no overhead of 'require' vs 'use'.
> 
> --
> # Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/


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

Date: Wed, 6 Dec 2000 07:35:17 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Willing to review a 90 line Perl program?
Message-Id: <slrn92sck5.phs.tadmc@magna.metronet.com>

Philip Garrett <philipg@atl.mediaone.net> wrote:
>----- Original Message -----
>From: Ted <ted_graham@my-deja.com>


>seek( IN, 0, 0 ); # accomplishes the same thing


That _might_ accomplish the same thing.

But you won't know if you do not check the return value!   :-)


>> while( $line = <IN> )
>
>This will work as long as you don't run across an empty line.  
                                                         ^^^^
                                                         ^^^^

There is no such thing as an "empty line". There are "empty strings"
and "blank lines".

If it is to be called a "line", then by definition, it must
contain at least a newline character.

The original will work fine with "blank lines".

It will also work fine with the chunk that evaluates to "false"
(a single zero character at EOF, no newline).


>You may want
>something more like this:
>
>while( defined($line = <IN>) ) {


That doesn't really change anything. perl automatically applies
the defined() test for the original code. If you leave it out,
perl will put it in.

I looked around for quite a while trying to find this in the
standard docs (not counting perldelta*). I could not locate it...


>    if ($line eq '') {


If it is indeed a "line" then that will not work unless
you first chomp() the line :-)

Without a chomp(), you would detect a blank line with:

   if ($line eq "\n") {



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


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

Date: Wed, 6 Dec 2000 10:50:41 -0500
From: "Ray Rizzuto" <ray.rizzuto@ulticom.com>
Subject: windows scripting components with ActiveState
Message-Id: <oftX5.18$104.227@client>

Hello,

I am trying to create a windows scripting component with ActiveState's
version of Perl for windows.  I can get this to work, except for the
fireEvent method.  Here's my component code:

<?xml version="1.0"?>
<component>

<?component error="true" debug="true"?>

<registration
 description="perlcom"
 progid="perlcom.WSC"
 version="1.00"
 classid="{7fde1e70-d281-11d3-958d-00104b951d4b}"
>
</registration>

<public>
 <property name="age">
  <get/>
  <put/>
 </property>
 <method name="birthday">
  <PARAMETER name="years"/>
 </method>
 <event name="retire"/>
</public>

<implements type="ASP" id="ASP"/>

<script language="PerlScript">
<![CDATA[
my $age=41;

sub birthday
{
   my ($years) = @_;
   $_[1];
}

sub get_age
{
    $age;
}

sub put_age
{
    my ($newage) = @_;
    $age = $newage;
    if ($age > 65)
    {
 fireEvent("retire");
    }
}
]]>
</script>


</component>


Here's how I invoke it:

<job>
<object id="test" progid="perlcom.wsc" events="true"/>
<script language="VBScript">
sub test_retire()
msgbox "got here"
end sub
test.age = 66
</script>
</job>


I get this error at the fireEvent call:

c:\WINNT\Profiles\rizzuto\home\test4.wsf(0, 1) Invoking main::put_age:
Undefined subroutine &main::fireEvent called at (eval 5) line 20.

c:\WINNT\Profiles\rizzuto\home\test4.wsf(7, 2) Unspecified error

Has anyone gotten this to work?

Ray




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

Date: Wed, 6 Dec 2000 15:41:33 -0000
From: "Katie Foster" <katie.foster@bt.com>
Subject: Re: Your help please
Message-Id: <90lmqj$rio$1@pheidippides.axion.bt.co.uk>

sorry I should havem put 5.03  sorry
"Peter Sundstrom" <peter.sundstrom@eds.com> wrote in message
news:90jl8p$cnu$1@hermes.nz.eds.com...
>
> Katie Foster <katie.foster@bt.com> wrote in message
> news:90if3b$61i$1@pheidippides.axion.bt.co.uk...
> > I haven't been doing Perl very long, so I was hoping someone on here
could
> > help me, please.
> >
> > My group have upgraded from Perl 3 to Perl 5.05.  Some of our scripts no
> > longer work, I have fixed some of them, but have come accross a problem
> with
> > one particular script.
>
> Are you absolutely sure you had Perl 3?  I would be *very* surprised if
that
> was the case.
>
>
>
>
>




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

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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 V9 Issue 5045
**************************************


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