[16508] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3920 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Aug 4 21:05:26 2000

Date: Fri, 4 Aug 2000 18:05:09 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <965437509-v9-i3920@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Fri, 4 Aug 2000     Volume: 9 Number: 3920

Today's topics:
        Dereferencing correctly in regular expressions <smcmurr@xmission.com>
    Re: Dereferencing correctly in regular expressions <lr@hpl.hp.com>
    Re: Dereferencing correctly in regular expressions (Clinton A. Pierce)
        Dreaded 500 message <dave@htxtech.com>
    Re: Dreaded 500 message <tony_curtis32@yahoo.com>
    Re: execute a Perl script in another Perlscript <bean@agentkhaki.com>
        File Manager Utility superfly19@my-deja.com
    Re: File Manager Utility <VTAM_203@email.msn.com>
        Form to Email on NT <james@jborden.freeserve.co.uk>
        Game programming in perl...? <spragg@cs.ucdavis.edu>
        Help with Apache & Perl <rblundon@ameritech.net>
    Re: Help with Apache & Perl <tony_curtis32@yahoo.com>
    Re: I need a Perl developer (David H. Adler)
    Re: Is "exit()" really necessary? (Richard J. Rauenzahn)
    Re: matching *.h <tony_curtis32@yahoo.com>
    Re: matching *.h (Abigail)
    Re: my what? (Andrew J. Perrin)
    Re: negative zero? <sternberg@phys.uni-paderborn.de>
    Re: newb Q, Our perl guy left!! <smerr612@mailandnews.com>
        passing spaces in URL <mragsdal@utk.edu>
        Programming Ethics jthornton@my-deja.com
    Re: Programming Ethics <lr@hpl.hp.com>
    Re: Programming Ethics (Clinton A. Pierce)
    Re: semijoin() - a better way? (Tim)
    Re: Sendmail and ACTIVEPERL <wyzelli@yahoo.com>
    Re: split strings by number <lr@hpl.hp.com>
    Re: very cool routine <spragg@cs.ucdavis.edu>
        voting <terjej@my-deja.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Fri, 04 Aug 2000 16:10:54 -0700
From: Sean McMurray <smcmurr@xmission.com>
Subject: Dereferencing correctly in regular expressions
Message-Id: <398B4D7E.3DBEE30E@xmission.com>

I have a code snippet that looks like this:
    use CGI;
    $req = new CGI;
    ...
    $JSP =~ s/<%=\$(\w+)>/$req->param($1)/g;

When it does the replace, it dereferences $req to some wierd address or
something, then adds the string "->param(" then does the $1 correctly
and finishes with the string ")".

How can I get it to not dereference $req prematurely?
Perl does the same thing if I have a line like this:

print qq{$req->param("MyParam")};

It derefs $req before following the ->.



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

Date: Fri, 4 Aug 2000 17:28:33 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Dereferencing correctly in regular expressions
Message-Id: <MPG.13f4ff899816015a98ac39@nntp.hpl.hp.com>

In article <398B4D7E.3DBEE30E@xmission.com> on Fri, 04 Aug 2000 16:10:54 
-0700, Sean McMurray <smcmurr@xmission.com> says...
> I have a code snippet that looks like this:
>     use CGI;
>     $req = new CGI;
>     ...
>     $JSP =~ s/<%=\$(\w+)>/$req->param($1)/g;
> 
> When it does the replace, it dereferences $req to some wierd address or
> something, then adds the string "->param(" then does the $1 correctly
> and finishes with the string ")".
> 
> How can I get it to not dereference $req prematurely?
> Perl does the same thing if I have a line like this:
> 
> print qq{$req->param("MyParam")};
> 
> It derefs $req before following the ->.

It is surprising that, when Perl interpolates a scalar into a double-
quotish context, function calls or method invocations () are not 
evaluated, but array indexes [] or hash keys {} are evaluated (no matter 
how complicated they may be).  Even there, whitespace between tokens, 
which would be ignored in an ordinary expression, inhibits the 
evaluation of the suffix [] or {} as other than a simple string.  The 
same approach could have been used to disambiguate the () suffix.

Perhaps someone can provide a rationale for this inconsistent situation, 
other than "that's the way it is".

In any event, that's the way it is, so you have to deal with it.  The 
simplest way is to add the /e modifier to your substitution statement, 
causing the replacement string to be evaluated as a Perl expression.  
There are other ways to interpolate arbitrary expressions, which are 
wordier:  @{[ expr ]} or ${\ expr }

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Sat, 05 Aug 2000 00:43:56 GMT
From: clintp@geeksalad.org (Clinton A. Pierce)
Subject: Re: Dereferencing correctly in regular expressions
Message-Id: <grJi5.57985$fR2.589777@news1.rdc1.mi.home.com>

[Posted and mailed]

In article <398B4D7E.3DBEE30E@xmission.com>,
	Sean McMurray <smcmurr@xmission.com> writes:
> I have a code snippet that looks like this:
>     use CGI;
>     $req = new CGI;
>     ...
>     $JSP =~ s/<%=\$(\w+)>/$req->param($1)/g;
> 
> When it does the replace, it dereferences $req to some wierd address or
> something, then adds the string "->param(" then does the $1 correctly
> and finishes with the string ")".
> 
> How can I get it to not dereference $req prematurely?
> Perl does the same thing if I have a line like this:
> 
> print qq{$req->param("MyParam")};
> 
> It derefs $req before following the ->.

Wrong word, cowboy!  It's not "dereferencing" anything.  What's happening
is that $req is being _interpolated_.  In regexps and in double-quoted
strings scalars get replaced with their values.  This is called 
interpolation.  So when perl sees:

	print "$req->param(Myparam)";

It interpolates the $req back into its value.  In this case, an blessed
reference (an object--the request object!).  So you're seeing:

	CGI=HASH(0x00000)->param(Myparam)

Or something like that.  Perl won't run code inside of double quotes[1].
You don't want that code in quotes, you want that as just code:

	print $req->param("Myparam");

Now in your regexp, to get the right-hand-side of a substitution to evaluate
you want the /e modifier.  perldoc perlop for information on how that
works.


[1] Well, it can but only with some trickery.  See "perlref" for details.
-- 
    Clinton A. Pierce              Teach Yourself Perl in 24 Hours! 
  clintp@geeksalad.org         for details see http://www.geeksalad.org
"If you rush a Miracle Man, 
	you get rotten Miracles." --Miracle Max, The Princess Bride


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

Date: Fri, 04 Aug 2000 18:26:21 -0400
From: David Somner <dave@htxtech.com>
Subject: Dreaded 500 message
Message-Id: <398B430D.C53B6B42@htxtech.com>

Hello!

I am getting the 500 Server Error message.
I am using Win95 and Win98 (two different platforms)
I have updated to latest DCOM 1.3 from Microsoft
I have installed the Microsoft Installer
I have installed ActivePerl
I have MS Personal Web Server 1.x installed
I have /cgi-bin on c:\cgi-bin and virtualized to http://myspot/cgi-bin
I have /datadir on c:\datadir and virtualized to http://myspot/datadir
I have /cgi-bin set to execute, no read
I have /datadir set to read, no execute
I have a .htm file in my WWWROOT directory to test the .CGI script out
I have made the registry changes for .pl, .plx and .cgi files

I can run perl from a command prompt and get the correct output from the
 .CGI files
When I run a .CGI file in a web browser, I get the 500 Server Error
message

Please, please, please help!!!!

--Dave
(dave@htxtech.com)


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

Date: 04 Aug 2000 18:06:27 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: Dreaded 500 message
Message-Id: <873dkk7hjg.fsf@limey.hpcc.uh.edu>

>> On Fri, 04 Aug 2000 18:26:21 -0400,
>> David Somner <dave@htxtech.com> said:

> Hello!  I am getting the 500 Server Error message.  I am

Show us your code!  Can't help without seeing the code.

You're not outputting the right headers, but we don't know
what you *are* outputting, so it's impossible to go
anywhere...

> I can run perl from a command prompt and get the correct
> output from the .CGI files When I run a .CGI file in a
> web browser, I get the 500 Server Error message

Obviously you're *not* getting the right output from the
command-line.  But again, noone but you knows what the
output is.

hth
t
-- 
"With $10,000, we'd be millionaires!"
                                           Homer Simpson


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

Date: 05 Aug 2000 00:19:17 GMT
From: bean <bean@agentkhaki.com>
Subject: Re: execute a Perl script in another Perlscript
Message-Id: <MPG.13f525442a8c54198968f@news.concentric.net>

> I thought that was `Walking the plonk' in the case of newsgroups...

"How could you not see that boat?"

"Arr... two glass eyes... *dink* *dink*"

<grin>

bean


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

Date: Fri, 04 Aug 2000 23:49:37 GMT
From: superfly19@my-deja.com
Subject: File Manager Utility
Message-Id: <8mfkqh$itd$1@nnrp1.deja.com>

I have an old 20Gb Netware volume that I need to copy over to our an NT
server.  For some reason there are a number of corrupted files that
mess up all of the utilities I've tried so far (NT migration, windows
explorer, xcopy, ncopy, etc.)  I've also vrepaired the volume a number
of times, and it does vrepair clean, but the files are still there.

Could anyone point me in the direction of a Perl "File Manager" script
that would let me do this large of a copy and be able to just blow by
these files and not bother copying them?

Any help would be appreciated.

-J


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


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

Date: Fri, 4 Aug 2000 17:27:30 -0700
From: "VTAM_203" <VTAM_203@email.msn.com>
Subject: Re: File Manager Utility
Message-Id: <usAnVNn$$GA.279@cpmsnbbsa07>

copying files runs eventually on the OS, but the File::Copy module might
help.

<superfly19@my-deja.com> wrote in message
news:8mfkqh$itd$1@nnrp1.deja.com...
> I have an old 20Gb Netware volume that I need to copy over to our an NT
> server.  For some reason there are a number of corrupted files that
> mess up all of the utilities I've tried so far (NT migration, windows
> explorer, xcopy, ncopy, etc.)  I've also vrepaired the volume a number
> of times, and it does vrepair clean, but the files are still there.
>
> Could anyone point me in the direction of a Perl "File Manager" script
> that would let me do this large of a copy and be able to just blow by
> these files and not bother copying them?
>
> Any help would be appreciated.
>
> -J
>
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.




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

Date: Sat, 5 Aug 2000 00:09:48 +0100
From: "James Borden" <james@jborden.freeserve.co.uk>
Subject: Form to Email on NT
Message-Id: <8mfihj$eh8$1@news5.svr.pol.co.uk>

Can someone kindly point me to a free Form to Email CGI that works on NT.

Thanks,
James




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

Date: 5 Aug 2000 00:06:07 GMT
From: Adam Trace Spragg <spragg@cs.ucdavis.edu>
Subject: Game programming in perl...?
Message-Id: <8mflpf$d8a$2@mark.ucdavis.edu>

Hey all.  First off, let me say how glad I am to have found this newsgroup.
I love everying Perl, and there seems to be a wealth of knowledge and helpful
people here.

I've been using Perl professionally and personally for almost a year now.
I've always enjoyed game programming as a hobby, and in an effort to learn
Perl better, I've created a play-by-email game.  Perl was perfectly suited for
this... reading in standard input files, processing the files, and creating
the output which was then emailed off to the players.

My next project is working on an online multiplayer "roguelike" game (using
ascii graphics rather than traditional bitmaps).  I've had a little bit of 
luck, but not enough time to get very far on it yet.  At this point, multiple
players (haven't tested an upper bound) can connect, and run around a couple
of "maps", and talk to each other.  It's pretty exciting.

I'm wondering if anyone else is working on any such game-type projects in 
Perl.  I'd be interested to hear what you're up to...

Adam


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

Date: Fri, 4 Aug 2000 17:48:02 -0500
From: "Ryan Blundon" <rblundon@ameritech.net>
Subject: Help with Apache & Perl
Message-Id: <bNHi5.310$Lj1.30711@nntp0.chicago.il.ameritech.net>

Help please!

I have a web server running Apache on Solaris.

I need to be able to pass the user name from Apache authentication to my
Perl cgi script.

Any help or direction would be greatly appreciated.

Ryan




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

Date: 04 Aug 2000 18:08:40 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: Help with Apache & Perl
Message-Id: <87zoms62vb.fsf@limey.hpcc.uh.edu>

>> On Fri, 4 Aug 2000 17:48:02 -0500,
>> "Ryan Blundon" <rblundon@ameritech.net> said:

> Help please!  I have a web server running Apache on
> Solaris.

> I need to be able to pass the user name from Apache
> authentication to my Perl cgi script.

    use CGI ':standard';
    my $realm_name = remote_name();

"perldoc CGI"

(I assume you're talking about basic authentication.)

hth
t
-- 
"With $10,000, we'd be millionaires!"
                                           Homer Simpson


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

Date: 4 Aug 2000 23:31:05 GMT
From: dha@panix.com (David H. Adler)
Subject: Re: I need a Perl developer
Message-Id: <slrn8omkhp.1fv.dha@panix2.panix.com>

On Thu, 3 Aug 2000 16:24:10 -0500, EPIC <EPICSTAFFING@EMAIL.COM> wrote:
>I am looking for a Perl developer, with Apache, Linux, My SQL development

You have posted a job posting or a resume in a technical group.

Longstanding Usenet tradition dictates that such postings go into
groups with names that contain "jobs", like "misc.jobs.offered", not
technical discussion groups like the ones to which you posted.

Had you read and understood the Usenet user manual posted frequently
to "news.announce.newusers", you might have already known this. :)

Please do not explain your posting by saying "but I saw other job
postings here".  Just because one person jumps off a bridge, doesn't
mean everyone does.  Those postings are also in error, and I've
probably already notified them as well.

If you have questions about this policy, take it up with the news
administrators in the newsgroup news.admin.misc.

There is a Perl Jobs Announce list that may be more helpful to you.  See
<http://www.pm.org/mailing_lists.shtml> for details.

Yours for a better usenet,

dha


-- 
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
He was from the planet Blobnar.
	- Jon Orwant


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

Date: 4 Aug 2000 22:37:31 GMT
From: nospam@hairball.cup.hp.com (Richard J. Rauenzahn)
Subject: Re: Is "exit()" really necessary?
Message-Id: <965428649.617202@hpvablab.cup.hp.com>

vek@pharmnl.ohout.pharmapartners.nl (Villy Kruse) writes:
>>Tim <SPAM+indigo@dimensional.com> wrote in comp.lang.perl.misc:
>>>bart.lateur@skynet.be (Bart Lateur) wrote in
>>>Plus there was a CERT advisory this spring concerning a security hole
>>>if you fail to check the return value of exit.
>>
>>Huh?  How does this apply?  The return value of exit can only be
>>checked by a program that calls yours because exit, well, exits.
>
>Unless for some unknown and obscure reasons should choose not to exit.
>Exec might return, even if you don't expect it to, but that is a
>different story.

I think all of you might want to reread the CERT advisory, paying
particular attention to the date:

	http://x73.deja.com/getdoc.xp?AN=605122255.1

Rich
-- 
Rich Rauenzahn ----------+xrrauenza@cup.hp.comx+ Hewlett-Packard Company
Technical Consultant     | I speak for me,     |   19055 Pruneridge Ave. 
Development Alliances Lab|            *not* HP |                MS 46TU2
ESPD / E-Serv. Partner Division +--------------+---- Cupertino, CA 95014


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

Date: 04 Aug 2000 18:03:28 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: matching *.h
Message-Id: <8766pg7hof.fsf@limey.hpcc.uh.edu>

>> On Fri, 04 Aug 2000 15:26:06 -0600,
>> Phil Reardon <pcr@pinnatel.net> said:

> How can I detect include files?  I tried /.h/ and /\.h/,
> as in ($file =- /\.h/), but they dont seem to work.
               ^
               |
Typo? ---------' you want  =~

Some of those patterns might work for certain filenames,
but not in the general case.

Looking for /\.h$/ is probably what you intend.

    "a period followed by "h" at the end of the name"

hth
t
-- 
"With $10,000, we'd be millionaires!"
                                           Homer Simpson


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

Date: 04 Aug 2000 23:35:38 GMT
From: abigail@foad.org (Abigail)
Subject: Re: matching *.h
Message-Id: <slrn8omkpp.st1.abigail@alexandra.foad.org>

Phil Reardon (pcr@pinnatel.net) wrote on MMDXXX September MCMXCIII in
<URL:news:398B34EE.9A3F5C54@pinnatel.net>:
() How can I detect include files?  I tried /.h/ and /\.h/, as in ($file
() =-  /\.h/), but they dont seem to work.


"Doesn't work" is a pointless statement.

What happens, and what did you think should have?


Abigail
-- 
<purl> Look buddy, doesn't work is a strong statement. Does it sit on the
couch all day? Is it making faces at you? Does it want more money? Please
be specific!


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

Date: 04 Aug 2000 18:10:21 -0400
From: aperrin@demog.berkeley.edu (Andrew J. Perrin)
Subject: Re: my what?
Message-Id: <usnskd6eq.fsf@demog.berkeley.edu>

"Greg Griffiths" <gregory_griffiths@cargill.com> writes:

> The first specifies the value and the variable for use with the STRICT
> option, the other works fine, unless you use this approach.

Wow, that's a bass-ackwards way of thinking about it!

my() lexically scopes the variable, defining it as part of the
particular block in which it is defined, while simply assigning a
value to a variable makes it a global.  They are very much not the
same thing, and only "work fine" in certain situations.

my() is not designed to make strict happy; strict is designed to warn
against the sloppy disuse of my().

You might get some more edification by reading perldoc -f my .

-- 
----------------------------------------------------------------------
Andrew Perrin - Solaris-Linux-NT-Samba-Perl-Access-Postgres Consulting
       aperrin@igc.apc.org - http://demog.berkeley.edu/~aperrin
----------------------------------------------------------------------


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

Date: Sat, 05 Aug 2000 00:37:29 +0200
From: Michael Sternberg <sternberg@phys.uni-paderborn.de>
Subject: Re: negative zero?
Message-Id: <398B45A9.8BEC194C@phys.uni-paderborn.de>

Michael Sternberg wrote:
> 
> I found that some versions of perl treat zero-valued expressions as '-0'.
> This is strange to look at in scientific computing.  How can I change the
> way this is handled?
> 
> Consider this test program:
> 
>     @a = (0, -1, -0);
>     for (@a) { $_ *= 0; }
>     print -$x, "\t (@a) \t perl $]\t$^O\n";
> 
> Here's the output for several platforms:
> 
>     0        (0 -0 0)        perl 5.004     hpux
>     -0       (0 -0 0)        perl 5.00404   solaris
>     0        (0 0 0)         perl 5.00503   freebsd
>     -0       (0 -0 0)        perl 5.00503   linux
>     -0       (0 -0 0)        perl 5.006     dec_osf
> 
> Note the different behaviour for the two 5.00503 versions.

Looks like this doesn't bother anybody, so I thought about it myself - perl
is at the mercy of the system's libc, as it appears.

main()
{
    double x;
    while (scanf("%lf", &x) > 0) {
       printf("%lf\n", -x);
    }
}

cc, and feed '0' ...

Regards,
-- 
Michael Sternberg,  Dipl. Phys.          | Uni-GH Paderborn
http://www.phys.uni-paderborn.de/~stern/ | FB6 Theoretische Physik 
phone: +49-(0)5251-60-2329   fax: -3435  | 33098 Paderborn, Germany
"Who disturrrbs me at this time?"  << Zaphod Beeblebrox IV >>	<*>


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

Date: Fri, 04 Aug 2000 22:32:03 GMT
From: Steven Merritt <smerr612@mailandnews.com>
Subject: Re: newb Q, Our perl guy left!!
Message-Id: <8mfg94$g9t$1@nnrp1.deja.com>

In article <39809709.D6FB64C3@tcgfinancial.com>,
  toyboy@toy.eyep.net wrote:
<snip>

> Here is the code that I think needs to be fixed.

<snip>

> If you need more of the code, please ask me and I'll post the whole
> thing.  This is what are emails currently look like:

So let me get this straight.  You give us some nonworking code, the
data, and the requirements.  You can't do it yourself, and haven't
tried.  You'd like us to "fix" the code for you because you don't want
to learn Perl.
Wow.

<Excerpt from one of the passages I snipped earlier>

"our perl guy just left"

Good for him.


Steven
--
King of Casual Play
The One and Only Defender of Cards That Blow


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


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

Date: Fri, 04 Aug 2000 20:46:37 -0400
From: Michael Ragsdale <mragsdal@utk.edu>
Subject: passing spaces in URL
Message-Id: <398B63ED.5387C72B@utk.edu>

Up until this point, I've called all of my scripts when the
user clicks on the $q->submit(); button using the POST
method.  Now I'd like to call one when the user simply
clicks on a href link.  I figure I have two possible ways to
do that, but not sure about either:

1. Stick with the POST method (I prefer passing named
parameters) and somehow make the href link execute the form
submit command.  I tried to find information on this and
found that href has an -OnClick() attribute, but it calls
JavaScript, not CGI.  If I went this route, how do I make
the href link execute the form submit?

2. Use the GET method and simply put my parameter pairs in
the URL of the href link.  I tried this and had a problem. 
Some of my parameter strings have spaces and if they were
not the last parameter passed, they lost all characters
after the first space.  I've seen URLs passed with some
character string, perhaps %20, that represents a space
before, but I've searched and searched and cannot find any
information on replacing the spaces with this character
string before I put the complete string in the URL.  In
other words, how do I make this:

my $x = 'I need help';
print $q->a({href=>"/this/that?something=$x"},"Test");

comes out like:
<a href="/this/that?something=I%20need%20help>Test</a>

instead of:
<a href="/this/that?something=I need help>Test</a>


Again, I'd prefer to stick with the POST method, if there is
any way to do that.

-Mike


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

Date: Fri, 04 Aug 2000 23:08:03 GMT
From: jthornton@my-deja.com
Subject: Programming Ethics
Message-Id: <8mfici$hgq$1@nnrp1.deja.com>

Many of you have experienced this situation -- your employer (or
contractor) asks you to write a program that, from your point-of-view,
can lead to no good.

Recently, I was asked to compile a database of names and e-mail
addresses of users that share a common interest. It was thought that
these e-mail addresses would be extracted from various mailing lists
and newsgroups.

The corporation I am working with is a young, public company that
trades on the stock market. I work directly with the Chairman/CEO, and
he made the request to compile this database.

Immediately I told him that I did not think this would go over well. I
told him that people will not want to receive unsolicited e-mail, and
that the corporation could get itself blacklisted. He then said, "Don't
make the mistake of assuming what we are going to do with them. Let
this be a lesson...we'll do it right. If you see us about to do
something wrong, scream and yell, but so don't assume."

It's beyond me how you can appropriately use a list like this, but my
time is under contract by this corporation. I wrote the code and
populated the beginnings of the requested database, but I have not
given it to them.

What good can come from this? Is the proper use of this database my
responsibility? Should the code never be written?



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


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

Date: Fri, 4 Aug 2000 17:13:52 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Programming Ethics
Message-Id: <MPG.13f4fc172760ecaa98ac38@nntp.hpl.hp.com>

In article <8mfici$hgq$1@nnrp1.deja.com> on Fri, 04 Aug 2000 23:08:03 
GMT, jthornton@my-deja.com <jthornton@my-deja.com> says...
> Many of you have experienced this situation -- your employer (or
> contractor) asks you to write a program that, from your point-of-view,
> can lead to no good.

 ...

> What good can come from this? Is the proper use of this database my
> responsibility? Should the code never be written?

This is a question of ethics, not of the Perl programming language.  
Surely there is a more appropriate newsgroup for you to post your 
question to.

Good luck with it.  I feel very fortunate in working for a straight-
arrow company whose purpose is to invent 'with a shining soul'.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Sat, 05 Aug 2000 00:37:58 GMT
From: clintp@geeksalad.org (Clinton A. Pierce)
Subject: Re: Programming Ethics
Message-Id: <GlJi5.57983$fR2.589777@news1.rdc1.mi.home.com>

[Posted and mailed]

In article <8mfici$hgq$1@nnrp1.deja.com>,
	jthornton@my-deja.com writes:
> Many of you have experienced this situation -- your employer (or
> contractor) asks you to write a program that, from your point-of-view,
> can lead to no good.

Actually, programs like that (and other kinds!) have fed my family, 
are paying my mortgage and a make a car payment every month.  The 
writing of those programs seems to have caused a lot of good.  Also
I learn a lot writing almost any kind of program, regardless of its
use.  It is wrong to say that writing software, even software with 
questionable uses, has no benefits.

Whether the personal gain is outweighed by any misery spread among 
others because of it's use is another issue entirely.

> What good can come from this? Is the proper use of this database my
> responsibility? Should the code never be written?

Unless you're breaking laws (the real kind, the ones that will put you
in an orange jumpsuit) or you suspect that your employer will break
laws with the software you're under no obligation other than ethics to 
refuse to write it or deploy it.

Now, then the sticky part.

It's gut check time.  If your employer's view does not agree with your
own you're left with two options: give them the software or don't.
Any protests you give will generally be noted and will not win you 
any friends that count.  Refusing to give them the software potentially
gets you in legal hot water and will almost certainly get your reprimanded
or replaced.  If your ethical view of this situation is worth more than
your job, by all means protest.  Even refuse to give them the software
that they've already paid for.  Just be prepared for what can happen, and
weigh it in advance.

Myself, I've only refused to deploy a software solution once in my career.
At the request of management we were to patch the mail system so all
e-mail could be read to verify that company time and resources were 
not being wasted.  I refused.  They insisted.  I refused on the public
argument that this was a management issue, not a software issue, and should
be solved through proper supervision, policy and reprimand.  Privately
I refused because this would cause personal and specific harm to individuals
who I believed were indeed taking improper advantage of company resources,
but who needed proper supervision and discipline instead of secret
monitoring.  I believed that spying on them was wrong.

All thing considered, it worked out well.

Your situation will certainly not be the same as mine.  Suggest alternative
methods of getting the word out.  Advertizing.  Maybe get a booth at
a show.  Release your software for free, if it's any good.  (Not the spam
stuff!  :)

-- 
    Clinton A. Pierce              Teach Yourself Perl in 24 Hours! 
  clintp@geeksalad.org         for details see http://www.geeksalad.org
"If you rush a Miracle Man, 
	you get rotten Miracles." --Miracle Max, The Princess Bride


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

Date: Fri, 04 Aug 2000 22:14:36 GMT
From: SPAM+indigo@dimensional.com (Tim)
Subject: Re: semijoin() - a better way?
Message-Id: <8F86AC6E0indigodimcom@166.93.207.145>

kcivey@cpcug.org (Keith Calvert Ivey) wrote in
<3994ca9d.50683435@news.newsguy.com>: 

>anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote:
>
>>Well without the frills about negative $itemcount, the basic function
>>is
>>
>>push @newlist, join $jstr, splice( @oldlist, 0, $itemcount) while
>>@oldlist; 
>
>And with a negative $itemcount, it's
>
>    unshift @newlist, join $jstr, splice( @oldlist,
>        (-$itemcount > @oldlist ? 0 : $itemcount ), -$itemcount)
>        while @oldlist;
>

Careful...both of those solutions eat the original list.

my @old = qw(a b c d e f g h i j k l m);
my @new;
my $j = '+';
my $i = 5;

@new = ((map { join $j, @old[$_ * $i .. ($_ + 1) * $i - 1] } 
    0 .. @old / $i - 1), 
    @old[-(@old % $i) .. -1]);

print "$_\n" for @new;

----

a+b+c+d+e
f+g+h+i+j
k
l
m

-T


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

Date: Sat, 5 Aug 2000 10:12:13 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: Sendmail and ACTIVEPERL
Message-Id: <HnJi5.3$851.1063@vic.nntp.telstra.net>

Paris <odesseus@my-deja.com> wrote in message
news:8mf31b$5n4$1@nnrp1.deja.com...
> In article <rQni5.14$f_.2580@vic.nntp.telstra.net>,
>   "Wyzelli" <wyzelli@yahoo.com> wrote:
> >> When running a 'proper' PERL interpreter on a proper OS I can
usually
> >> pipe to the the 'sendmail' program in usr/lib to send mail.
> >> However there is no such luxury on an NT Server running
activeperl..
> >>
> >> Does anyone have a clue how you send mail from such a server???
> >>
> > Too few people know of the various sendmail ports to Windows.
> > I prefer the one from www.dynamicstate.com but there are others
> > (including one from Microsoft).
> > That helps keep your scripts portable.
>
> This is all true, but I don't understand how a port of sendmail
> can work, because NT cannot PIPE or FORK because it isn't a real
> multitasking OS.
> How do you use the sendmail.exe type programs?
>

I suppose going to the url in question and reading the instructions
would be out of the question?

(hint* you use it exactly the same as you use it on unix...)

#!/usr/bin/perl -w
$mail_prog = 'sendmail' ;
use CGI ;

$recip = "receiver\@receiver.com" ;

$mail = <<EOMAIL;
To: $recip
Reply-to: sender\@sender.com
From: sender\@sender.com
Subject: This is an E-mail

Dear Receiver

How are you today?

Regards

Sender

EOMAIL

open (MAIL, "|$mail_prog -t");
print MAIL $mail;
close (MAIL);

This works fine in the CGI environment once you have followed the
instructions referred to above regarding making the web-server pipe.

It also works fine from a 'normal' script.

Wyzelli





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

Date: Fri, 4 Aug 2000 15:36:48 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: split strings by number
Message-Id: <MPG.13f4e5589299740598ac37@nntp.hpl.hp.com>

In article <8mduuf$7k3$1@orpheus.gellyfish.com> on 4 Aug 2000 09:30:07 
+0100, Jonathan Stowe <gellyfish@gellyfish.com> says...
> On Thu, 03 Aug 2000 15:59:04 GMT oderus54@my-deja.com wrote:
> > How would i split strings by number, like for example;
> 
> > $blah = "abcdefghijklmn";
> > #now i want $string1 = "abc", $string2 = "defgh", $string3 = "ijk",
> > $string4 = "lmn"
> 
> TIMTOWTDI (though some ways are more sensible than others ):

 ...

Indeed, but no way would I include the following in a serious benchmark.

> {
>    my $i = 0;
>    my ( $string1,
>         $string2,
>         $string3,
>         $string4);
>  
>    foreach ( split //, $string )
>    {
>      ${ 
>         $i < 3  ? \$string1 :
>         $i < 8  ? \$string2 :
>         $i < 11 ? \$string3 : 
>                   \$string4 
>       } .= $_;
>      $i++
>     }
> 
>   print "$string1,$string2,$string3,$string4\n";
> }                                   

I replaced this with Anno Siegel's sensible attempt, which he guessed to 
be "Very probably slower too, though I didn't check.  But not really 
messy, and easily maintained."  I did check; he is right on all counts.


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

use vars '$s';
$s = 'abcdefghijklmn';

timethese( 1 << (shift || 0), {
    A_Unpack => 'my @a = unpack "A3A5A3A3", $s',
    B_Regex  => 'my @a = $s =~ /(.{3})(.{5})(.{3})(.{3})/s',
    C_Substr => 'my @a = (substr($s,  0, 3), 
                          substr($s,  3, 5), 
                          substr($s,  8, 3), 
                          substr($s, 11, 3))', 
    D_Siegel => 'my $x = $s;
                 my @a = map substr($x, 0, $_, ""), 3, 5, 3, 3',
} );
__END__

Output:

Benchmark: timing 262144 iterations of A_Unpack, B_Regex, C_Substr, 
D_Siegel...
  A_Unpack: 10 wallclock secs ( 8.39 usr +  0.00 sys =  8.39 CPU) @ 
31241.09/s (n=262144)
   B_Regex: 10 wallclock secs (10.48 usr +  0.00 sys = 10.48 CPU) @ 
25001.81/s (n=262144)
  C_Substr:  8 wallclock secs ( 7.23 usr +  0.00 sys =  7.23 CPU) @ 
36242.78/s (n=262144)
  D_Siegel: 16 wallclock secs (14.92 usr +  0.00 sys = 14.92 CPU) @ 
17567.62/s (n=262144)


So substr(), the hardest to maintain, is also the fastest (as usual
:-).  But unpack() does quite well.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: 4 Aug 2000 23:46:23 GMT
From: Adam Trace Spragg <spragg@cs.ucdavis.edu>
Subject: Re: very cool routine
Message-Id: <8mfkkf$d8a$1@mark.ucdavis.edu>

jason <elephant@squirrelgroup.com> wrote:
: Robin Bank writes ..
:>Sorry man,
:>I take that last flame back. Just in a pissy mood.

: your apology is bemusingly accepted

I just read this entire thread from start to finish, and it was really
quiet interesting:

Robin:  Hey, check out my cool routine!

Everyone:  Uhhh... isn't that just splice?

Robin: (trying to look like he (she?) intended this)  Oh yeah.  Well mine is 
just the same as PERL's, and just as fast.

Everyone: (smirking)  No it's not.  Perl is faster.  And it's Perl, not PERL.

Robin: (in real trouble now)  Oh yeah.  I didn't know that.  Perl is in C, so
builting Perl functions will be faster.  But mine takes parameters!

Everyone: So does splice.

Robin: (Proceeds to repeat back everything he's just been taught in an effort
to actually look like (s)he knows what (s)he's doing).


My advice, Robin, is if you get caught with your pants down, admit you made
a mistake, thank everyone for their help, and shut your yap before you make
a more of a fool of yourself.  I mean this in a friendly, helpful way.

Adam





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

Date: Sat, 05 Aug 2000 00:46:50 GMT
From: Terje Johannesen <terjej@my-deja.com>
Subject: voting
Message-Id: <8mfo5q$kvf$1@nnrp1.deja.com>

Hello,

   I am looking for a perl script that will let the visitors on my site
vote for different sites. Not give them point, but just choose a site
of the day to say it that way. The script should give the link to the
winner, not to the rest, and preferably reset the results every 24
hours. Does anyone know if there is such a script, or have made
something remotely similair? I have checked cgi-resources and most
other places I can think of, but haven't found any script that has more
than just normal voting...

Thanks in advance,
Terje


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


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

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


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