[11211] in Perl-Users-Digest
Perl-Users Digest, Issue: 4811 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Feb 2 23:07:22 1999
Date: Tue, 2 Feb 99 20:00:17 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Tue, 2 Feb 1999 Volume: 8 Number: 4811
Today's topics:
Re: [Q] CPAN module installs on Windows98 with ActivePe (Randy Kobes)
Re: are regular expression rationaly designed ? (Ilya Zakharevich)
Re: are regular expression rationaly designed ? <uri@ibnets.com>
Building threaded perl <aarontav@cs.berkeley.edu>
Can't find any reference to... <mwebster@inetarena.com>
Re: Can't find any reference to... (Martien Verbruggen)
Re: END blocks for subs? (Martien Verbruggen)
Re: grep and a variable (Tad McClellan)
Help me with this small script <vanm01@netrevolution.com>
Re: Help Unistalling ActivePerl <info@purco.qc.ca>
Re: Is it possible to source a .cshrc file from a perl <spicano@ptdcs2.intel.com>
JOBS: Apache/Mod_perl programmer, sysadmin (Nick Tonkin)
Re: newbie having trouble with concatination (Tad McClellan)
Re: Newbie question <gasmiley@nospam.mediaone.net>
Perl bug on search patterns? (EX:MTL:6V41)
Re: Perl bug on search patterns? <uri@ibnets.com>
Re: Perl bug on search patterns? <aarontav@cs.berkeley.edu>
Re: Perl Criticism (Sam Holden)
Re: Perl in ASP code (Sean McKenna)
perlscript with ASP <usagi@indo-mail.com>
Re: problem forking with perl: child sometimes dies (Charles DeRykus)
Re: problem forking with perl: child sometimes dies (Charles DeRykus)
Re: replacing non-printable characters (Charles DeRykus)
Re: Statistics for comp.lang.perl.misc (Bill Moseley)
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 3 Feb 1999 02:43:30 GMT
From: randy@theory.uwinnipeg.ca (Randy Kobes)
Subject: Re: [Q] CPAN module installs on Windows98 with ActivePerl and Cygwin20.1
Message-Id: <slrn7bfeh1.md3.randy@theory.uwinnipeg.ca>
On 02 Feb 1999 15:42:11 -0700, Wade Holst <wade@cs.ualberta.ca> wrote:
>I have a laptop with Windows 98, Active Perl, and Cygwin20.1.
>I would like to use 'perl -MCPAN -e shell' and then start installing
>the approx. 100 non-standard modules I find useful. Unfortunately, the
>Makefiles that are generated have SHELL='c:\com /c /x' or some such thing.
>Since I'd like to use the UNIX-like capabilities of Cygwin, I'd like the
>SHELL to be 'bash'.
>
>So, how can I do this. I suspect that I need to modify CPAN::Config.pm
>to pass some flags to the perl Makefile.PL phase, and was hoping someone
>knows what to do.
Hi,
You would have to change CPAN.pm's config file, as well as
perl's Config.pm file for the location of your make and other programs,
C compiler, library and include paths, etc. However, ActiveState's
perl (which I assume you have) won't work with make, gcc, etc.
of cygwin. You'll either have to rebuild perl with these tools,
which is possible but non-trivial (search deja-news about 1-2 months
ago for a HOW-TO for doing this), or else stick with ActiveState
and use their Perl Package Manager (ppm) to install modules, or
use some combination of dmake/nmake/perl make and Borland/VC++
(for XS modules) to install your own.
--
best regards,
Randy Kobes
Physics Department Phone: (204) 786-9399
University of Winnipeg Fax: (204) 774-4134
Winnipeg, Manitoba R3B 2E9 e-mail: randy@theory.uwinnipeg.ca
Canada http://theory.uwinnipeg.ca/
------------------------------
Date: 3 Feb 1999 01:38:16 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: are regular expression rationaly designed ?
Message-Id: <7989a8$ho2$1@mathserv.mps.ohio-state.edu>
[A complimentary Cc of this posting was sent to Uri Guttman
<uri@ibnets.com>],
who wrote in article <394sp4foon.fsf@ibnets.com>:
> >>>>> "IZ" == Ilya Zakharevich <ilya@math.ohio-state.edu> writes:
>
> >> if (/\Qmain(){while(1);}/) { print "This program loops forever!\n";
> >> }
>
> IZ> This matches
>
> IZ> #ifdef LINUX main(){while(1);} #else main(){return 1;} #endif
>
> IZ> and does not match many other loopers.
>
> ilya,
>
> he was pulling your leg and commenting on your statement below. if you
> had said "ALL correct C" you would have been more accurate. his regex
> matches A correct C looper.
You have a queer understanding of what "recognize" means.
Ilya
------------------------------
Date: 02 Feb 1999 20:53:55 -0500
From: Uri Guttman <uri@ibnets.com>
To: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: are regular expression rationaly designed ?
Message-Id: <391zk8fe18.fsf@ibnets.com>
>>>>> "IZ" == Ilya Zakharevich <ilya@math.ohio-state.edu> writes:
>> he was pulling your leg and commenting on your statement below. if
>> you had said "ALL correct C" you would have been more accurate. his
>> regex matches A correct C looper.
IZ> You have a queer understanding of what "recognize" means.
and you have a poor sense of humor. he was joking. ask him.
uri
--
Uri Guttman Hacking Perl for Ironbridge Networks
uri@sysarch.com uri@ironbridgenetworks.com
------------------------------
Date: Tue, 02 Feb 1999 17:53:39 -0800
From: Aaron Tavistock <aarontav@cs.berkeley.edu>
Subject: Building threaded perl
Message-Id: <36B7AC23.B03D5E67@cs.berkeley.edu>
I'm having a terrible time trying to get a threaded perl built under
i386-BSD.
The basic problem is really so silly, but one that I can't find a good
work around for. The posix pthread API is built into lib_c, but perl
either wants an external library (libpthread) or to not compile with
threads.
Anyone have simillar problems? Any good ways around this besides trying
to tweak the various config files heavily?
------------------------------
Date: Tue, 02 Feb 1999 18:27:36 -0800
From: "mwebster@inetarena.com" <mwebster@inetarena.com>
Subject: Can't find any reference to...
Message-Id: <36B7B418.51B3655@inetarena.com>
Okay, y'all. I've checked several different references, and I'm pretty
sure that the answer's out there but I'm just missing the small print:
I have the following challenge: copy the files from one directory on one
system to a network drive, checking modification dates and only copying
files which have been changed. Now, I've figured out how to check the
mod dates, and I can copy one file from point A to point B, but I've
found squat on copying whole directories from place to place...
Any suggestions? I'm digging this language alot, and learning a great
deal, but I think on this one I could use a kick in the right direction.
Anybody game?
mwebster@inetarena.com
------------------------------
Date: Wed, 03 Feb 1999 02:40:21 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Can't find any reference to...
Message-Id: <pGOt2.126$9v3.8511@nsw.nnrp.telstra.net>
In article <36B7B418.51B3655@inetarena.com>,
"mwebster@inetarena.com" <mwebster@inetarena.com> writes:
> I have the following challenge: copy the files from one directory on one
> system to a network drive, checking modification dates and only copying
> files which have been changed.
For unix systems, that is called rdist. I am sure there's stuff
available for other platforms, but if you insist on reinventing the
wheel:
> Now, I've figured out how to check the
> mod dates, and I can copy one file from point A to point B, but I've
> found squat on copying whole directories from place to place...
perldoc File::Find.
traverse the tree, check whether you're looking at a file or
directory. compare the things. Possibly create directories on the
destination file system. use File::Copy to copy the things. You may
need to set the access and modification times to be the same if you
want them to be in sync as opposed to just be younger than the source:
# perldoc -f utime
Note that symbolic links will provide a problem.
Martien
--
Martien Verbruggen |
Interactive Media Division | Think of the average person. Half of
Commercial Dynamics Pty. Ltd. | the people out there are dumber.
NSW, Australia |
------------------------------
Date: Wed, 03 Feb 1999 02:15:08 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: END blocks for subs?
Message-Id: <MiOt2.114$9v3.8511@nsw.nnrp.telstra.net>
In article <7980l9$am0$2@news.rz.uni-karlsruhe.de>,
Marc.Haber-usenet@gmx.de (Marc Haber) writes:
> This doesn't look very perlish. Especially taking care about the file
> being closed in the second unless statement doesn't strike me as being
> a perlism.
(I believe your test for -f is the wrong way around in your code)
(-f $configFile) || return 1;
# OR: return 1 unless (-f $configFile);
# OR: return 1 if (!-f $configFile);
open(FH, $configFile) || return 1;
# do something else
close(FH);
If you need the warnings, replace 'return 1' by something else, like a
do BLOCK statement.
(-f $configFile) || do { message(MESS_DEBUG, "Ignoring....\n"); return 1};
Or adapt the 'message routine'
sub message
{
my $ret = shift;
my $severity = shift;
# do something with @_ based on severity
return $ret.
}
(-f $configFile) || return message(1, MESS_DEBUG, "Ignoring....\n");
> If this were a standalone program, I'd establish an END
> block to close the file after closing. Do I have such a mechanism
> available for subs too?
Not really.
I believe you want to know how one would make sure the file got closed
in case the '# do something else' needs to return from the sub
immediately, before the close() statement is reached, right?
One possibility is a goto. Not preferred by many, but sometimes the
most elegant solution.
Another possibility is to call a sub that closes the file.
sub returnAndClose
{
my $fh = shift;
my $error = shift;
close($fh);
return $error;
}
DoSomething() || return returnAndClose(\*FH, 1);
If you only have a few of these, explicitly closing the file in a do
BLOCK is probably easier.
If you need to have all of the above done, I'd probably use do BLOCKS:
open(FH, $configFile) || do {message("blabla"); return 1};
doSomething() || do {message("foobar"); close(FH); return 2};
> Would eval be a better way to code this? How would a perl wizard do
> this?
A perl wizard may come up with many obfuscations of the above, or do
it something like that, or any way they like. How would I know? :)
eval probably wouldn't be used, though.
BTW: returning an integer to signify success or failure isn't often
done in perl. Most subs return undef or an empty list on failure, and
a real value or a list on success. That makes the these constructs
very common:
doAThing() || die "Couldn't do A Thing";
Martien
--
Martien Verbruggen |
Interactive Media Division | Advertising: The science of arresting
Commercial Dynamics Pty. Ltd. | the human intelligence long enough to
NSW, Australia | get money from it.
------------------------------
Date: Tue, 2 Feb 1999 19:58:34 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: grep and a variable
Message-Id: <aga897.787.ln@magna.metronet.com>
jimbob4334@my-dejanews.com wrote:
: Can someone tell me how to use
: grep on the following?
: @date - is an array with many dates including 1-12-98
In Perl we say that like this:
@date = qw(1-10-98 1-11-98 1-12-98 1-13-98);
Not too much trouble to type, and much more likely to
contribute to your chances of getting help that you can use.
: $var="1-12-98";
You should not ask for interpolation if you don't need interpolation.
$var = '1-12-98';
: @match = grep(/\Q$var\E/, @date);
There are no regex metacharacters in your $var,
so you don't need \Q
But it should be matching fine anyway.
: $no_of_mathces = $#match;
That does _not_ give the number of matches.
It gives one less than the number of matches...
: I get $no_of_matches = -1
... so it looks like you got zero matches.
$no_of_mathces = @match; # this really does give the # of matches
There is something that you are not telling us.
Show us code. Small. Complete. Shows the behavior you
need help with.
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 2 Feb 1999 22:55:02 -0500
From: "LukeV" <vanm01@netrevolution.com>
Subject: Help me with this small script
Message-Id: <TQPt2.404$C53.992@wagner.videotron.net>
@pages contains two occurences (as an example): cies_an&1 and cies_fr&1
I read them, increment their value (at the right of the &) and after that, I
wanna write them to a file like this:
cies_an&1 [line break]
cies_fr&1 [line break]
when i have only one, it's fine, it increments ok. Then, if i add another
one, it's still ok but as soon as i wanna increment the 2nd one, the file
looks like this:
cies_an&1 [line break]
[line break]
cies_fr&1 [line break]
here's the script:
open(INF, ">$logfile");
foreach $i (@pages) {
print INF "$i\n";
}
close(INF);
I know the rest of the prg is ok, but what makes it go wrong like that ?!
thanks for your time.
LukeV
vanm01@netrevolution.com
www.illusion.qc.ca
------------------------------
Date: Tue, 02 Feb 1999 21:42:25 -0500
From: Leon Stepanian <info@purco.qc.ca>
Subject: Re: Help Unistalling ActivePerl
Message-Id: <36B7B791.2EFFD377@purco.qc.ca>
You should be able to remove the remnants from your
Start/Settings/Control Panel/Add-Remove Programs. In the
Install/Uninstall window you should see a reference to this program.
Usually when you click on the program name to reomve, and windows see
that it is not available, it will ask you if you want to remove this
reference. Say yes, and it's done.
If you don't have any reference to this in the above location, or if
Windows won't let you remove it, you'll have to use your RegEdit program
located in your Windows directory, and do a "find" and delete each
reference manually. But, be very carefull because you could make
mistakes which could result in other problems.
Another thing to do is check your System.ini and Win.ini files and
remove any reference to this program, then reboot. Hope this helps.
=================================================
Blair Kingsland wrote:
>
> Hi:
>
> I installed ActivePerl on Win95. But something went wrong. So, I
> (stupidly) unistalled AP by deleting the AP directory. I should have
> used the Win95 unistall, but I forgot. Now, I want to re-install AP.
> But I get a "system error decompressing file" message when I start the
> AP install.
>
> I think I may have a corrupt registry. How do I completely remove the
> old copy of AP?
>
> Your help would be appreciated.
>
> Blair
> Blairk@tigron.com
------------------------------
Date: Tue, 02 Feb 1999 17:56:19 -0800
From: Silvio Picano <spicano@ptdcs2.intel.com>
Subject: Re: Is it possible to source a .cshrc file from a perl script?
Message-Id: <36B7ACC2.796B9668@ptdcs2.intel.com>
Soo Jang wrote:
> Hi,
> I'm trying to source a .cshrc file which sets environment variable
> by setenv c-shell command from a perl script.
>
> How can I perform this?
>
> Thanks,
> Soo
Soo,
I perform something like this when I need to import env variables from a
csh script file:
open(PH, "/bin/csh -cf 'source $csh_file_s >>&! /dev/null; env' |") ||
return (-3, "$routine_s: failed open(/bin/csh -cf 'source
$csh_file_s >>&! /dev/null; env' |)");
while (<PH>) {
;# key=value pairs (e.g., environment vars).
if (/^(\S+)=(.*)/) {
$key_s = $1;
$val_s = $2;
....
$ENV{$key_s} = $val_s;
....
}
}
close ...
Silvio
------------------------------
Date: Wed, 03 Feb 1999 02:14:55 GMT
From: nick@valueclick.com (Nick Tonkin)
Subject: JOBS: Apache/Mod_perl programmer, sysadmin
Message-Id: <36b7b1df.363481418@news.sysci.org>
ValueClick is seeking highly qualified experts to fill the following
positions:
Modperl/Apache Programmer:
To join our existing staff of programmers in developing our in-house
banner advertising software. Solid experience in configuring,
customizing and optimizing Apache, mod_perl, and Perl, as well as
programming to the Apache C and Perl APIs is required, preferably in
an extremely high traffic, distributed architecture system.
Particularly valuable will be experience in creating task-distribution
architectures, utilizing front and back end proxies, shared data
servers, etc.
Network/Systems Administrator:
To oversee our rapidly growing worldwide network of server farms; aid
in designing and implementing solutions for intranational and
inter-continental distribution of tens of millions of httpd requests
among multiple facilities. Networking/routing/DNS guru, client-server
programming expert, with solid experience on very large enterprises.
Background:
ValueClick Incorporated is the Internet's fastest growing advertising
company, currently serving almost 20 million banner ads served dailyon
more than 10,000 websites in the United States and around the world.
Successful applicants for these positions will be based in our Santa
Barbara, Calif. offices, and will enjoy a compensation package
including generous salary and benefits, and the possibility of
valuable stock options.
If you are a true net warrior and relish the challenge of joining our
team and building out our system into a worldwide modperl/Apache
juggernaut, please e-mail me or call (805) 965-0543 ext. 13
Thanks
------------------------------
Date: Tue, 2 Feb 1999 18:56:03 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: newbie having trouble with concatination
Message-Id: <3r6897.ij6.ln@magna.metronet.com>
Steve Linberg (linberg@literacy.upenn.edu) wrote:
: In article <36B70CF4.3AB3@ee.surrey.ac.uk>, Gavin Ian Andrew Kenny
: <eem3gk@ee.surrey.ac.uk> wrote:
: > $line =~ /\s*(\S+.*)$/; # this gets rid of tab at the start and \n
: > at # the end
: That will get rid of whitespace at the start of the string, but not the
: end.
It is a m// not a s///
It doesn't get rid of anything.
: Your .* matches everything to the end of the string.
No, it doesn't match the newline at the end of the string,
which, I believe, was the whole point :-)
: Look into chomp() if you want to kill end-of-line newlines.
That is very good advice.
: Or do
: something like this:
: $line =~ s/\s*(.*?)\s*$/$1/;
That may remove more than just a tab from the front.
It may also remove more that just a newline from the end.
It doesn't do what the poster's comment says he wants to do.
And it has all of the problems that Perl FAQ 4 says it has.
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 02 Feb 1999 20:41:25 -0500
From: Gary Smiley <gasmiley@nospam.mediaone.net>
Subject: Re: Newbie question
Message-Id: <36B7A945.B9C4FB90@nospam.mediaone.net>
I think we're getting close- I have tested this pgm successfully from my desktop
machine. On our server, there is a permission set for "anonymous-user". But on
the shared network drive, there is no "ananymous-user" showing up in the
permissions. When somebody browses to our site they become an anonymous user,
but when they press the submit button and the Perl program tries to write to the
network drive, there is no anonymous user there. So actually it's not a Perl
problem- it's a NT Server problem. But you have all helped me a lot. Tomorrow I
will come in to work and reinstall perl on the shared computer in hopes that
"anonymous user" will reappear on that machine, and then I will test the whole
thing out again, and I'll let you know what happens. Thanks for all your help -
Gary
John Counts wrote:
> Gary Smiley wrote in message <36B65899.1CCDC95B@nospam.mediaone.net>...
> >Here's the latest: My syntax is OK. If I run the pgm via a DOS prompt, it
> >"sees" the shared drive and writes to it. Over the Web via an HTML form, it
> >dies trying to open the file for appending.
>
> Your problem seems to be the file permissions of the user accessing the HTTP
> server. If you are running Apache this is usually 'nobody' if you're
> running IIS it's something like IUSER_[MACHINENAME]. You need to give this
> user write permission on the file in question. If you're running Apache you
> can also change the username that it runs as. I don't thnk this is possible
> with IIS. It works in DOS because the script is being executed as your
> login username, which obviously has the correct permisions on the file.
--
To reply, please remove the anti-spam portion of the return address.
------------------------------
Date: Tue, 02 Feb 1999 20:33:50 -0500
From: "Patrice Chalin (EX:MTL:6V41)" <chalin@americasm01.nt.com>
Subject: Perl bug on search patterns?
Message-Id: <36B7A77E.F8DE228@americasm01.nt.com>
Hi,
Consider the following perl5 snippet:
| my $pattern = "^\s*class";
|
| while(<>) {
| print ( /$pattern/ ? "Y" : "N");
| print ( /^\s*class/ ? "y" : "n");
| }
| print "\n";
| exit 0;
run over the following input
xxx
class foo
// class foo
end
yields
NnNyNnNn
It should yield "NnYyNnNn", i.e. pairs of Nn, Yy.
Anybody know why this doesn't work? (I'm using Perl 5.002.)
Thanks,
Patrice
------------------------------
Date: 02 Feb 1999 21:03:31 -0500
From: Uri Guttman <uri@ibnets.com>
Subject: Re: Perl bug on search patterns?
Message-Id: <39yamgdz0s.fsf@ibnets.com>
>>>>> "PC(" == Patrice Chalin (EX:MTL:6V41) <chalin@americasm01.nt.com> writes:
be careful when you call something a bug in perl. check your own work
VERY carefully first.
PC(> | my $pattern = "^\s*class";
what is in $pattern now? what do you think is in $pattern now? are they
the same? did you check? the answer is right there.
a simpler question: what is in $foo after this?
$foo = "\s" ;
this is why i always say to use single quotes for strings EXCEPT if you
are interpolatin variables into the string. you should have doen that
above.
PC(> |
PC(> | while(<>) {
PC(> | print ( /$pattern/ ? "Y" : "N");
PC(> | print ( /^\s*class/ ? "y" : "n");
PC(> | }
PC(> | print "\n";
PC(> | exit 0;
PC(> NnNyNnNn
PC(> It should yield "NnYyNnNn", i.e. pairs of Nn, Yy.
no it shouldn't as the 2 regexes are not the same.
hth,
uri
--
Uri Guttman Hacking Perl for Ironbridge Networks
uri@sysarch.com uri@ironbridgenetworks.com
------------------------------
Date: Tue, 02 Feb 1999 18:15:46 -0800
From: Aaron Tavistock <aarontav@cs.berkeley.edu>
Subject: Re: Perl bug on search patterns?
Message-Id: <36B7B152.4008ACD5@cs.berkeley.edu>
Patrice Chalin (EX:MTL:6V41) wrote:
>
> Hi,
>
> Consider the following perl5 snippet:
>
> | my $pattern = "^\s*class";
> |
> | while(<>) {
> | print ( /$pattern/ ? "Y" : "N");
> | print ( /^\s*class/ ? "y" : "n");
> | }
> | print "\n";
> | exit 0;
>
> run over the following input
>
> xxx
> class foo
> // class foo
> end
>
> yields
>
> NnNyNnNn
>
> It should yield "NnYyNnNn", i.e. pairs of Nn, Yy.
> Anybody know why this doesn't work? (I'm using Perl 5.002.)
>
> Thanks,
> Patrice
I'm not entirely sure on the internals of perl that make this not work,
but I do know that you can't just shove a standard string into a regex
and expect it to evaluate properly. I'm guessing that its related to
there not being an explicit 'e' modifier to m//
You can get this to work without much trouble though. You could either
do some complex tricker beign careful with your syntax and using
quotemeta. But the best solution is to simply use qr// when defining
$pattern (I think this may be newer than perl 5.002, sorry). qr//
returns a compiled pattern, so it will plug right in.
Heres your example in a way that works:
my $pattern = qr/^\s*class/;
while(<>)
{
print ( m/$pattern/ ? "Y" : "N");
print ( m/^\s*class/ ? "y" : "n");
}
------------------------------
Date: 3 Feb 1999 01:06:34 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: Perl Criticism
Message-Id: <slrn7bf88q.orc.sholden@pgrad.cs.usyd.edu.au>
On Tue, 02 Feb 1999 13:47:32 GMT, topmind@technologist.com wrote:
>In article <slrn7b9ujh.4tu.sholden@pgrad.cs.usyd.edu.au>,
> sholden@cs.usyd.edu.au wrote:
>>
>> Basically, avoid comments. If your code needs a comment to be
>> understood, it would be better to rewrite it so it's easier to
>> understand. --Rob Pike
>>
>
>I disagree with that statement. Sometimes one comment
>will nicely summarize a dozen or so lines of code. Also,
>by hinting the reader about the code BEFORE they read
>it helps them figure it out faster. Otherwise, one
>pass is needed to make a guess, and a second to verify
>the guess.
Any rule like that is a guideline that should apply most of the time. It is
not a law or anything.
Notice he said 'needs a comment to be understood' not 'needs a comment to
be understood in two seconds'.
Rob Pike's comment was meant to be interpreted something along the lines of
if you find yourself commenting your code because you think others will have
trouble understanding it, then rewrite it.
>
>For example, "sort list" takes only two
>seconds to understand. However, if somebody stumbled upon
>sorting code without knowing what it does, it would
>usually take them several minutes to figure out
>what it is doing. Those two words are a bargain.
That's only true if the author can't write code in a readable fashion.
I would write sort list like this and it would not need any comments (though I
do put header comments on functions anyway)...
void
sort_list(List list)
{
/*insert code here*/
}
Good code doesn't need simple comments line 'sort list' the function name should
provide that level of comment. If you inline soorting code then you are a
performance freak and I don't want to have to read your code anyway...
In fact the comment I would have would be something along the lines of
/* sort_list is an implementation of the algorithm described in Blah on
pages blah-blah by Bill Blah...*/
>
>Further, if there is a bug, then reading only the code
>may not indicate what was INTENDED. Only comments can
>tell what was intended.
In which case the refernce to literature will be of more help then saying that
it's meant to sort a list (which is obvioud by the function name anyway).
--
Sam
Fifty years of programming language research, and we end up with C++ ???
--Richard A. O'Keefe
------------------------------
Date: Tue, 02 Feb 1999 19:28:31 -0800
From: seanmck@mckennaprod.com (Sean McKenna)
Subject: Re: Perl in ASP code
Message-Id: <36b7c1fe.4884432@nntp1.ba.best.com>
On Tue, 2 Feb 1999 14:09:18 -0000, "Simon GIllespie"
<simon.gillespie@virgin.com> wrote:
>Having real problems getting ASP's Folder object's File collection to work.
>Anyone know of any useful "using Perl for ASP" URL's or books ?
>Thanks,
>Simon Gillespie.
>
Look at the Perl section on http://come.to/fastnet for Perscript with
ASP info. I don't know if it goes into the Folder object, though.
Sean McKenna "All the world's a stage..."
------------------------------
Date: Wed, 3 Feb 1999 10:38:52 +0700
From: "news.dnet.net.id" <usagi@indo-mail.com>
Subject: perlscript with ASP
Message-Id: <79a1mf$auj3@indo-news>
Does anyone know how to read and write using ASP in perlscript language..?
------------------------------
Date: Wed, 3 Feb 1999 02:18:31 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: problem forking with perl: child sometimes dies
Message-Id: <F6K3qv.Gx@news.boeing.com>
In article <79811p$1nn$1@nnrp1.dejanews.com>, <k2k2@my-dejanews.com> wrote:
>I have a perl script that forks off a child to do some work in the
>background that can take a long time. It works somthing like this:
>
>
> if (!defined($child_pid = fork())) {
> die "cannot fork $!\n";
> } elsif ($child_pid) { #parent process
> print "this is the parent";
> } else { #child process
> open STDERR, ">/dev/null"; #must close STDERR & STDOUT or the
> open STDOUT, ">/dev/null"; # process will wait for the fork
> # before finishing if run via CGI.
> open (LOG, ">$logfile")||die "Can't open $logfile: $!\n";
>
> ....
Here's a vague possilibility:
$SIG{HUP} = 'IGNORE' # add to child
hth,
--
Charles DeRykus
------------------------------
Date: Wed, 3 Feb 1999 02:38:24 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: problem forking with perl: child sometimes dies
Message-Id: <F6K4o0.1Dn@news.boeing.com>
In article <F6K3qv.Gx@news.boeing.com>,
Charles DeRykus <ced@bcstec.ca.boeing.com> wrote:
>Here's a vague possilibility:
>
> $SIG{HUP} = 'IGNORE' # add to child
> ^^^^^^^^^^^^
Misleading comment: the signal disposition will affect
both parent and child so position doesn't matter.
--
Charles DeRykus
------------------------------
Date: Wed, 3 Feb 1999 01:59:26 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: replacing non-printable characters
Message-Id: <F6K2v2.p@news.boeing.com>
In article <lfnnjBAq54t2Ewsy@beausys.demon.co.uk>,
Andrew Fry <andrewf@beausys.demon.co.uk> wrote:
>I am trying to write a Perl module that decodes
>a trace of network traffic, and I need a bit of
>Perl that replaces all non-printable characters
>by, say, a '.' (...to display each octet in
>hex on one side and ASCII on the other side).
>Does anyone have such a piece of code to hand ?
>(...to do the replacing, that is).
>
Maybe something like this:
foreach my $byte ...
$hex .= sprintf("%x ", $byte);
if ($byte >= 0x21 and $byte <= 0x7e) {
$ascii .= sprintf "%c ", $byte;
} else {
$ascii .= '. '; }
}
}
hth,
--
Charles DeRykus
------------------------------
Date: Tue, 2 Feb 1999 19:08:21 -0800
From: moseley@best.com (Bill Moseley)
Subject: Re: Statistics for comp.lang.perl.misc
Message-Id: <MPG.11215d7f70cdd0da98969a@nntp1.ba.best.com>
What a nice service this summary is.
> - Original Content Rating (OCR) is the ratio of the original content
> volume to the total body volume.
Is a high ratio good or bad???
I wonder what percent of postings match (RTFM|perldoc) with a very low
OCR.
I also sometimes wonder what percent of posts go unanswered.
--
Bill Moseley mailto:moseley@best.com
------------------------------
Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>
Administrivia:
Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing.
]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body. Majordomo will then send you instructions on how to confirm your
]subscription. This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.
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.misc (and this Digest), send your
article to perl-users@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.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
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 V8 Issue 4811
**************************************