[23097] in Perl-Users-Digest
Perl-Users Digest, Issue: 5318 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Aug 5 14:36:27 2003
Date: Tue, 5 Aug 2003 11:35:56 -0700 (PDT)
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, 5 Aug 2003 Volume: 10 Number: 5318
Today's topics:
Perl Math Syntax <ducott@hotmail.com>
Re: Perl Math Syntax <emschwar@pobox.com>
Re: Perl Math Syntax <noreply@gunnar.cc>
Re: Perl Math Syntax <ducott@hotmail.com>
Re: Perl Math Syntax <ducott@hotmail.com>
Re: Perl Math Syntax <emschwar@pobox.com>
Re: Perl Math Syntax <ducott@hotmail.com>
Re: Perl Math Syntax <REMOVEsdnCAPS@comcast.net>
Re: Perl Math Syntax <jaspax@u.washington.edu>
Re: Perl Math Syntax (Tad McClellan)
Re: Perl Math Syntax <krahnj@acm.org>
Re: Perl Math Syntax <bigj@kamelfreund.de>
Re: Perl Math Syntax <REMOVEsdnCAPS@comcast.net>
Re: Perl Math Syntax <uri@stemsystems.com>
Re: Perl Math Syntax (Tad McClellan)
Re: Perl Math Syntax <noreply@gunnar.cc>
Posting Guidelines for comp.lang.perl.misc ($Revision: tadmc@augustmail.com
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 05 Aug 2003 00:59:09 GMT
From: "\"Dandy\" Randy" <ducott@hotmail.com>
Subject: Perl Math Syntax
Message-Id: <xjDXa.649145$Vi5.15441736@news1.calgary.shaw.ca>
Hello peoples,
Needs some help getting a ... well ... pretty basic math script working but
the solution eludes me .... I have a text file called opened.txt ... it
contains the following single line data:
2000|0|0
What I am looking to do is when the script is run, I would like the second
value to increase by 1 .... kind of like this:
#!/usr/bin/perl
open (FILE, "<opened.txt") or &error("Unable to open");
$data=<FILE>;
chomp ($data);
($total,$opened,$closed)=split(/\|/,$data);
close(FILE);
$opened = $opened + 1; // is incorrect of course
open (FILE, ">opened.txt") or &error("Unable to open");
print FILE "$total|$opened|$closed";
close(FILE);
print "Content-type: text/html \n\n";
print "All done";
exit;
So now the data in opened.txt would read:
2000|1|0
Can you please help me with the syntax to increase the second value when the
script is run. Thanx!
Randy
------------------------------
Date: Mon, 04 Aug 2003 19:20:37 -0600
From: Eric Schwartz <emschwar@pobox.com>
Subject: Re: Perl Math Syntax
Message-Id: <etoznionbmi.fsf@wormtongue.emschwar>
"\"Dandy\" Randy" <ducott@hotmail.com> writes:
> Needs some help getting a ... well ... pretty basic math script
> working but the solution eludes me .... I have a text file called
> opened.txt ... it contains the following single line data:
>
> 2000|0|0
>
> What I am looking to do is when the script is run, I would like the second
> value to increase by 1 .... kind of like this:
<snip perl program>
> So now the data in opened.txt would read:
>
> 2000|1|0
>
> Can you please help me with the syntax to increase the second value
> when the script is run. Thanx!
It works fine for me:
emschwar@wormtongue:/tmp$ cat opened.txt
2000|2|0
emschwar@wormtongue:/tmp$ perl test.pl
Content-type: text/html
All doneemschwar@wormtongue:/tmp$ cat opened.txt
2000|3|0emschwar@wormtongue:/tmp$
Btw, some comments on your script:
* You didn't use strict or warnings. That's bad; you should always
ask Perl to help you as much as possible. In this example, anyway,
all it would cost you is a few 'my's.
* You're checking your open()s for failure, which is good, but you
should include $! so you'll know WHY they failed.
* You seem to be writing a CGI program; in that case, you should be
using the CGI module. 'perldoc CGI' for more details.
* Your problem may have to do with multiple users running that code at
once. You really should be performing some sort of lock on the file
before editing it like that. See 'perldoc -q lock' for more
details.
* // is NOT a valid Perl comment. If you have it in your real code,
then that may well be your problem. If you don't, then shame on you
for not posting real live code. :)
* For human-reability, you'll probably want to print a "\n" at the end
of the file after you update it.
-=Eric
--
Come to think of it, there are already a million monkeys on a million
typewriters, and Usenet is NOTHING like Shakespeare.
-- Blair Houghton.
------------------------------
Date: Tue, 05 Aug 2003 03:20:45 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Perl Math Syntax
Message-Id: <bgn1ac$ot287$1@ID-184292.news.uni-berlin.de>
"Dandy" Randy wrote:
> I have a text file called opened.txt ... it contains the following
> single line data:
>
> 2000|0|0
<snip>
> Can you please help me with the syntax to increase the second value
> when the script is run.
Your code doesn't include any apparent errors. The first thing you
should do - before asking for help here - is asking Perl to help you
find the problem by adding
use strict;
use warnings;
and study possible messages written to STDERR.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Tue, 05 Aug 2003 01:34:32 GMT
From: "\"Dandy\" Randy" <ducott@hotmail.com>
Subject: Re: Perl Math Syntax
Message-Id: <IQDXa.649792$Vi5.15449213@news1.calgary.shaw.ca>
Thank you for playing Eric, my comments:
A) I dont know a heck of alot about strict or warnings, but I'l look into
that.
B) Good point about opening files, will modify.
C) Multipul users is od course a bid thing, in which case i would modify my
write-to-file script like so:
open (FILE, ">opened.txt") or &error("Unable to open");
flock FILE, 2;
print FILE "$total|$opened|$closed";
close(FILE);
Just curious, I got this flock code from a perldoc example ... what does the
"2" represent? should it be a different value? Or ... is flocking really
what I need to be doing?
thanx!
> * You didn't use strict or warnings. That's bad; you should always
> ask Perl to help you as much as possible. In this example, anyway,
> all it would cost you is a few 'my's.
> * You're checking your open()s for failure, which is good, but you
> should include $! so you'll know WHY they failed.
> * You seem to be writing a CGI program; in that case, you should be
> using the CGI module. 'perldoc CGI' for more details.
> * Your problem may have to do with multiple users running that code at
> once. You really should be performing some sort of lock on the file
> before editing it like that. See 'perldoc -q lock' for more
> details.
> * // is NOT a valid Perl comment. If you have it in your real code,
> then that may well be your problem. If you don't, then shame on you
> for not posting real live code. :)
> * For human-reability, you'll probably want to print a "\n" at the end
> of the file after you update it.
>
> -=Eric
> --
> Come to think of it, there are already a million monkeys on a million
> typewriters, and Usenet is NOTHING like Shakespeare.
> -- Blair Houghton.
------------------------------
Date: Tue, 05 Aug 2003 01:35:50 GMT
From: "\"Dandy\" Randy" <ducott@hotmail.com>
Subject: Re: Perl Math Syntax
Message-Id: <WRDXa.621863$ro6.13467829@news2.calgary.shaw.ca>
Thanx Gunner, your points are good and will be addressed. thanx!
R
> Your code doesn't include any apparent errors. The first thing you
> should do - before asking for help here - is asking Perl to help you
> find the problem by adding
>
> use strict;
> use warnings;
>
> and study possible messages written to STDERR.
>
> --
> Gunnar Hjalmarsson
> Email: http://www.gunnar.cc/cgi-bin/contact.pl
>
------------------------------
Date: Mon, 04 Aug 2003 19:43:42 -0600
From: Eric Schwartz <emschwar@pobox.com>
Subject: Re: Perl Math Syntax
Message-Id: <etovftcnak1.fsf@wormtongue.emschwar>
"\"Dandy\" Randy" <ducott@hotmail.com> writes:
> Thank you for playing Eric, my comments:
>
> A) I dont know a heck of alot about strict or warnings, but I'l look into
> that.
perldoc strict
perldoc warnings
> B) Good point about opening files, will modify.
> C) Multipul users is od course a bid thing, in which case i would modify my
> write-to-file script like so:
>
> open (FILE, ">opened.txt") or &error("Unable to open");
> flock FILE, 2;
> print FILE "$total|$opened|$closed";
> close(FILE);
>
> Just curious, I got this flock code from a perldoc example ... what does the
> "2" represent? should it be a different value? Or ... is flocking really
> what I need to be doing?
Did you read the perldocs I referred you to? They specifically
contain examples of how to do it right. In fact, I'm not sure which
perldocs you have that suggest using literal numbers, as all the
obvious ones (perldoc -f flock, perldoc -q locking) used Fcntl.pm to
provide the symbolic constants LOCK_EX and LOCK_SH, and so on.
Also, and this is a big one here: do NOT top-post, and do NOT quote
the reply in its entirety. This is rude, and makes things harder to
read than they need to be.
It causes confusion like this.
Why shouldn't you top-post?
Instead, intersperse your comments with the text they're replying to,
and only quote what's necessary to provide the context for your
replies. I'm no paragon of virtue, but observe this reply for an
example.
-=Eric
--
Come to think of it, there are already a million monkeys on a million
typewriters, and Usenet is NOTHING like Shakespeare.
-- Blair Houghton.
------------------------------
Date: Tue, 05 Aug 2003 02:07:14 GMT
From: "\"Dandy\" Randy" <ducott@hotmail.com>
Subject: Re: Perl Math Syntax
Message-Id: <mjEXa.622754$3C2.15265051@news3.calgary.shaw.ca>
> perldoc strict
> perldoc warnings
Gotcha, tnx
> Did you read the perldocs I referred you to? They specifically
> contain examples of how to do it right. In fact, I'm not sure which
> perldocs you have that suggest using literal numbers, as all the
> obvious ones (perldoc -f flock, perldoc -q locking) used Fcntl.pm to
> provide the symbolic constants LOCK_EX and LOCK_SH, and so on.
I had read the section on flocking in the perdoc located at www.perdoc.com.
After studying further, I would now choose to use the following locking
procedure when writing to file:
use 5.004;
use Fcntl qw(:DEFAULT :flock);
open (FILE, ">opened.txt") or die "Unable to open: $!";
flock (FILE, LOCK_EX) or die "Can't lock file: $!";
print FILE "$total|$opened|$closed";
close(FILE);
Not quite sure what the use 5.004 does as noted in the perdoc but i'll trust
it's needed. There were sections on SH & EX ... any opinions on whether I
should be using shared locks or exclusive locks? At most maybe 10-20 users
may access the opened.txt file at any one time. I assume flocking would add
them to a cue rather than just not allowing access period. Thoughts? thanx
again!
R
------------------------------
Date: Mon, 04 Aug 2003 21:14:53 -0500
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: Perl Math Syntax
Message-Id: <Xns93CDE2219EAA9sdn.comcast@206.127.4.25>
-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1
"\"Dandy\" Randy" <ducott@hotmail.com> wrote in
news:xjDXa.649145$Vi5.15441736@news1.calgary.shaw.ca:
>
> $opened = $opened + 1; // is incorrect of course
Please elaborate on why you are drawing the conclusion that this is
incorrect "of course". It's not.
- --
Eric
$_ = reverse sort qw p ekca lre Js reh ts
p, $/.r, map $_.$", qw e p h tona e; print
-----BEGIN xxx SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>
iQA/AwUBPy8S12PeouIeTNHoEQKtygCgwnqfX+LPlNgp8fHY1ztvPh5ckXwAoNxT
VMb2M0IEMUPEnNr1+97t8SLR
=6OuB
-----END PGP SIGNATURE-----
------------------------------
Date: Mon, 4 Aug 2003 20:10:30 -0700
From: JS Bangs <jaspax@u.washington.edu>
Subject: Re: Perl Math Syntax
Message-Id: <Pine.A41.4.56.0308042009470.95418@dante18.u.washington.edu>
Eric J. Roode sikyal:
> -----BEGIN xxx SIGNED MESSAGE-----
> Hash: SHA1
>
> "\"Dandy\" Randy" <ducott@hotmail.com> wrote in
> news:xjDXa.649145$Vi5.15441736@news1.calgary.shaw.ca:
>
> >
> > $opened = $opened + 1; // is incorrect of course
>
> Please elaborate on why you are drawing the conclusion that this is
> incorrect "of course". It's not.
It's not incorrect, but the OP is probably better off doing:
$opened++;
--
Jesse S. Bangs jaspax@u.washington.edu
http://students.washington.edu/jaspax/
http://students.washington.edu/jaspax/blog
------------------------------
Date: Mon, 4 Aug 2003 22:06:21 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Perl Math Syntax
Message-Id: <slrnbiu7pd.dqc.tadmc@magna.augustmail.com>
[ please do not top-post ]
\"Dandy\" Randy <ducott@hotmail.com> wrote:
> A) I dont know a heck of alot about strict or warnings, but I'l look into
> that.
They help you find common mistakes.
They will do it in only a part of one second...
... or leave them out and spend hundreds/thousands? of seconds
chasing common mistakes.
Your choice.
> open (FILE, ">opened.txt") or &error("Unable to open");
> flock FILE, 2;
> print FILE "$total|$opened|$closed";
> close(FILE);
>
> Just curious, I got this flock code from a perldoc example ... what does the
> "2" represent?
All of Perl's functions are documented in the perlfunc manual.
You can look up a function's description with the -f switch:
perldoc -f flock
If there was some part of what is said there that you didn't
understand, then tell us what part and we'll help you to
understand it.
> should it be a different value?
It _could_ be a different value on different operating systems,
so it is best to use the imported constants instead of hard-coding
a particular number.
perldoc mentions that too...
> Or ... is flocking really
> what I need to be doing?
Yes, you need file locking when multiple processes may write
to a file at the same time (eg. in a CGI environment).
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 05 Aug 2003 07:15:17 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Perl Math Syntax
Message-Id: <3F2F59BD.A1D21C05@acm.org>
\"Dandy\" Randy wrote:
>
> Needs some help getting a ... well ... pretty basic math script working but
> the solution eludes me .... I have a text file called opened.txt ... it
> contains the following single line data:
>
> 2000|0|0
>
> What I am looking to do is when the script is run, I would like the second
> value to increase by 1 .... kind of like this:
#!/usr/bin/perl -p
BEGIN { ( $^I, @ARGV ) = ( '', 'opened.txt' ) }
s/|(\d+)|/|@{[$1+1]}|/
__END__
John
--
use Perl;
program
fulfillment
------------------------------
Date: Tue, 05 Aug 2003 11:51:55 +0200
From: "Janek Schleicher" <bigj@kamelfreund.de>
Subject: Re: Perl Math Syntax
Message-Id: <pan.2003.08.05.09.51.54.703307@kamelfreund.de>
"Dandy" Randy wrote at Tue, 05 Aug 2003 00:59:09 +0000:
> Hello peoples,
>
> Needs some help getting a ... well ... pretty basic math script working but
> the solution eludes me .... I have a text file called opened.txt ... it
> contains the following single line data:
>
> 2000|0|0
>
> What I am looking to do is when the script is run, I would like the second
> value to increase by 1 .... kind of like this:
Here's another (self announcing) way do to it:
use Tie::CSV_File; # from CPAN
tie my @data, 'Tie::CSV_File', 'filename.dat', PIPE_SEPARATED;
$data[0][1]++;
untie @data;
Greetings,
Janek
------------------------------
Date: Tue, 05 Aug 2003 05:20:51 -0500
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: Perl Math Syntax
Message-Id: <Xns93CE407B5CFE6sdn.comcast@206.127.4.25>
-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1
JS Bangs <jaspax@u.washington.edu> wrote in
news:Pine.A41.4.56.0308042009470.95418@dante18.u.washington.edu:
>
> It's not incorrect, but the OP is probably better off doing:
>
> $opened++;
Why is that "better"? For a simple variable increment, I would say that
it's just a matter of style. I can't see any real difference between
$opened = $opened + 1;
$opened += 1;
$opened++;
- --
Eric
$_ = reverse sort qw p ekca lre Js reh ts
p, $/.r, map $_.$", qw e p h tona e; print
-----BEGIN xxx SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>
iQA/AwUBPy+E4WPeouIeTNHoEQICNwCgmWgIJtlKRKtVFWdwd272fgsi7O8AoNsB
XkwWOkdyis8BNwJ+a68+bWVR
=HiK5
-----END PGP SIGNATURE-----
------------------------------
Date: Tue, 05 Aug 2003 13:10:19 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Perl Math Syntax
Message-Id: <x7r84045dx.fsf@mail.sysarch.com>
>>>>> "EJR" == Eric J Roode <REMOVEsdnCAPS@comcast.net> writes:
EJR> Why is that "better"? For a simple variable increment, I would
EJR> say that it's just a matter of style. I can't see any real
EJR> difference between
EJR> $opened = $opened + 1;
EJR> $opened += 1;
EJR> $opened++;
run them under the benchmark module. report your results back here.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: Tue, 5 Aug 2003 07:32:00 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Perl Math Syntax
Message-Id: <slrnbiv8u0.eqf.tadmc@magna.augustmail.com>
\"Dandy\" Randy <ducott@hotmail.com> wrote:
> print FILE "$total|$opened|$closed";
^^
^^ aren't you missing a \n there?
> Not quite sure what the use 5.004 does
Requires perl version 5.004 or newer.
The program will not run if used with an earlier version.
> There were sections on SH & EX ... any opinions on whether I
> should be using shared locks or exclusive locks?
It is not a matter of "opinion".
It is a matter of which protects against corrupted data and
which doesn't.
Use an exclusive lock when writing to the file.
Use a shared lock when reading from the file.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 05 Aug 2003 16:04:26 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Perl Math Syntax
Message-Id: <bgoe3g$qc94t$1@ID-184292.news.uni-berlin.de>
Tad McClellan wrote:
> \"Dandy\" Randy <ducott@hotmail.com> wrote:
>
>>print FILE "$total|$opened|$closed";
> ^^
> ^^ aren't you missing a \n there?
What good would a \n do?
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Tue, 05 Aug 2003 02:22:07 -0500
From: tadmc@augustmail.com
Subject: Posting Guidelines for comp.lang.perl.misc ($Revision: 1.4 $)
Message-Id: <29qdnYgBkoWCxrKiXTWJhQ@august.net>
Outline
Before posting to comp.lang.perl.misc
Must
- Check the Perl Frequently Asked Questions (FAQ)
- Check the other standard Perl docs (*.pod)
Really Really Should
- Lurk for a while before posting
- Search a Usenet archive
If You Like
- Check Other Resources
Posting to comp.lang.perl.misc
Is there a better place to ask your question?
- Question should be about Perl, not about the application area
How to participate (post) in the clpmisc community
- Carefully choose the contents of your Subject header
- Use an effective followup style
- Speak Perl rather than English, when possible
- Ask perl to help you
- Do not re-type Perl code
- Provide enough information
- Do not provide too much information
- Do not post binaries, HTML, or MIME
Social faux pas to avoid
- Asking a Frequently Asked Question
- Asking a question easily answered by a cursory doc search
- Asking for emailed answers
- Beware of saying "doesn't work"
- Sending a "stealth" Cc copy
Be extra cautious when you get upset
- Count to ten before composing a followup when you are upset
- Count to ten after composing and before posting when you are upset
-----------------------------------------------------------------
Posting Guidelines for comp.lang.perl.misc ($Revision: 1.4 $)
This newsgroup, commonly called clpmisc, is a technical newsgroup
intended to be used for discussion of Perl related issues (except job
postings), whether it be comments or questions.
As you would expect, clpmisc discussions are usually very technical in
nature and there are conventions for conduct in technical newsgroups
going somewhat beyond those in non-technical newsgroups.
This article describes things that you should, and should not, do to
increase your chances of getting an answer to your Perl question. It is
available in POD, HTML and plain text formats at:
http://mail.augustmail.com/~tadmc/clpmisc.shtml
For more information about netiquette in general, see the "Netiquette
Guidelines" at:
http://andrew2.andrew.cmu.edu/rfc/rfc1855.html
A note to newsgroup "regulars":
Do not use these guidelines as a "license to flame" or other
meanness. It is possible that a poster is unaware of things
discussed here. Give them the benefit of the doubt, and just
help them learn how to post, rather than assume
A note about technical terms used here:
In this document, we use words like "must" and "should" as
they're used in technical conversation (such as you will
encounter in this newsgroup). When we say that you *must* do
something, we mean that if you don't do that something, then
it's unlikely that you will benefit much from this group.
We're not bossing you around; we're making the point without
lots of words.
Do *NOT* send email to the maintainer of these guidelines. It will be
discarded unread. The guidelines belong to the newsgroup so all
discussion should appear in the newsgroup. I am just the secretary that
writes down the consensus of the group.
Before posting to comp.lang.perl.misc
Must
This section describes things that you *must* do before posting to
clpmisc, in order to maximize your chances of getting meaningful replies
to your inquiry and to avoid getting flamed for being lazy and trying to
have others do your work.
The perl distribution includes documentation that is copied to your hard
drive when you install perl. Also installed is a program for looking
things up in that (and other) documentation named 'perldoc'.
You should either find out where the docs got installed on your system,
or use perldoc to find them for you. Type "perldoc perldoc" to learn how
to use perldoc itself. Type "perldoc perl" to start reading Perl's
standard documentation.
Check the Perl Frequently Asked Questions (FAQ)
Checking the FAQ before posting is required in Big 8 newsgroups in
general, there is nothing clpmisc-specific about this requirement.
You are expected to do this in nearly all newsgroups.
You can use the "-q" switch with perldoc to do a word search of the
questions in the Perl FAQs.
Check the other standard Perl docs (*.pod)
The perl distribution comes with much more documentation than is
available for most other newsgroups, so in clpmisc you should also
see if you can find an answer in the other (non-FAQ) standard docs
before posting.
It is *not* required, or even expected, that you actually *read* all of
Perl's standard docs, only that you spend a few minutes searching them
before posting.
Try doing a word-search in the standard docs for some words/phrases
taken from your problem statement or from your very carefully worded
"Subject:" header.
Really Really Should
This section describes things that you *really should* do before posting
to clpmisc.
Lurk for a while before posting
This is very important and expected in all newsgroups. Lurking means
to monitor a newsgroup for a period to become familiar with local
customs. Each newsgroup has specific customs and rituals. Knowing
these before you participate will help avoid embarrassing social
situations. Consider yourself to be a foreigner at first!
Search a Usenet archive
There are tens of thousands of Perl programmers. It is very likely
that your question has already been asked (and answered). See if you
can find where it has already been answered.
One such searchable archive is:
http://groups.google.com/advanced_group_search
If You Like
This section describes things that you *can* do before posting to
clpmisc.
Check Other Resources
You may want to check in books or on web sites to see if you can
find the answer to your question.
But you need to consider the source of such information: there are a
lot of very poor Perl books and web sites, and several good ones
too, of course.
Posting to comp.lang.perl.misc
There can be 200 messages in clpmisc in a single day. Nobody is going to
read every article. They must decide somehow which articles they are
going to read, and which they will skip.
Your post is in competition with 199 other posts. You need to "win"
before a person who can help you will even read your question.
These sections describe how you can help keep your article from being
one of the "skipped" ones.
Is there a better place to ask your question?
Question should be about Perl, not about the application area
It can be difficult to separate out where your problem really is,
but you should make a conscious effort to post to the most
applicable newsgroup. That is, after all, where you are the most
likely to find the people who know how to answer your question.
Being able to "partition" a problem is an essential skill for
effectively troubleshooting programming problems. If you don't get
that right, you end up looking for answers in the wrong places.
It should be understood that you may not know that the root of your
problem is not Perl-related (the two most frequent ones are CGI and
Operating System related), so off-topic postings will happen from
time to time. Be gracious when someone helps you find a better place
to ask your question by pointing you to a more applicable newsgroup.
How to participate (post) in the clpmisc community
Carefully choose the contents of your Subject header
You have 40 precious characters of Subject to win out and be one of
the posts that gets read. Don't waste them. Take care while
composing them, they are the key that opens the door to getting an
answer.
Spend them indicating what aspect of Perl others will find if they
should decide to read your article.
Do not spend them indicating "experience level" (guru, newbie...).
Do not spend them pleading (please read, urgent, help!...).
Do not spend them on non-Subjects (Perl question, one-word
Subject...)
For more information on choosing a Subject see "Choosing Good
Subject Lines":
http://www.cpan.org/authors/id/D/DM/DMR/subjects.post
Part of the beauty of newsgroup dynamics, is that you can contribute
to the community with your very first post! If your choice of
Subject leads a fellow Perler to find the thread you are starting,
then even asking a question helps us all.
Use an effective followup style
When composing a followup, quote only enough text to establish the
context for the comments that you will add. Always indicate who
wrote the quoted material. Never quote an entire article. Never
quote a .signature (unless that is what you are commenting on).
Intersperse your comments *following* each section of quoted text to
which they relate. Unappreciated followup styles are referred to as
"Jeopardy" (because the answer comes before the question), or
"TOFU".
Reversing the chronology of the dialog makes it much harder to
understand (some folks won't even read it if written in that style).
For more information on quoting style, see:
http://web.presby.edu/~nnqadmin/nnq/nquote.html
Speak Perl rather than English, when possible
Perl is much more precise than natural language. Saying it in Perl
instead will avoid misunderstanding your question or problem.
Do not say: I have variable with "foo\tbar" in it.
Instead say: I have $var = "foo\tbar", or I have $var = 'foo\tbar',
or I have $var = <DATA> (and show the data line).
Ask perl to help you
You can ask perl itself to help you find common programming mistakes
by doing two things: enable warnings (perldoc warnings) and enable
"strict"ures (perldoc strict).
You should not bother the hundreds/thousands of readers of the
newsgroup without first seeing if a machine can help you find your
problem. It is demeaning to be asked to do the work of a machine. It
will annoy the readers of your article.
You can look up any of the messages that perl might issue to find
out what the message means and how to resolve the potential mistake
(perldoc perldiag). If you would like perl to look them up for you,
you can put "use diagnostics;" near the top of your program.
Do not re-type Perl code
Use copy/paste or your editor's "import" function rather than
attempting to type in your code. If you make a typo you will get
followups about your typos instead of about the question you are
trying to get answered.
Provide enough information
If you do the things in this item, you will have an Extremely Good
chance of getting people to try and help you with your problem!
These features are a really big bonus toward your question winning
out over all of the other posts that you are competing with.
First make a short (less than 20-30 lines) and *complete* program
that illustrates the problem you are having. People should be able
to run your program by copy/pasting the code from your article. (You
will find that doing this step very often reveals your problem
directly. Leading to an answer much more quickly and reliably than
posting to Usenet.)
Describe *precisely* the input to your program. Also provide example
input data for your program. If you need to show file input, use the
__DATA__ token (perldata.pod) to provide the file contents inside of
your Perl program.
Show the output (including the verbatim text of any messages) of
your program.
Describe how you want the output to be different from what you are
getting.
If you have no idea at all of how to code up your situation, be sure
to at least describe the 2 things that you *do* know: input and
desired output.
Do not provide too much information
Do not just post your entire program for debugging. Most especially
do not post someone *else's* entire program.
Do not post binaries, HTML, or MIME
clpmisc is a text only newsgroup. If you have images or binaries
that explain your question, put them in a publically accessible
place (like a Web server) and provide a pointer to that location. If
you include code, cut and paste it directly in the message body.
Don't attach anything to the message. Don't post vcards or HTML.
Many people (and even some Usenet servers) will automatically filter
out such messages. Many people will not be able to easily read your
post. Plain text is something everyone can read.
Social faux pas to avoid
The first two below are symptoms of lots of FAQ asking here in clpmisc.
It happens so often that folks will assume that it is happening yet
again. If you have looked but not found, or found but didn't understand
the docs, say so in your article.
Asking a Frequently Asked Question
It should be understood that you may have missed the applicable FAQ
when you checked, which is not a big deal. But if the Frequently
Asked Question is worded similar to your question, folks will assume
that you did not look at all. Don't become indignant at pointers to
the FAQ, particularly if it solves your problem.
Asking a question easily answered by a cursory doc search
If folks think you have not even tried the obvious step of reading
the docs applicable to your problem, they are likely to become
annoyed.
If you are flamed for not checking when you *did* check, then just
shrug it off (and take the answer that you got).
Asking for emailed answers
Emailed answers benefit one person. Posted answers benefit the
entire community. If folks can take the time to answer your
question, then you can take the time to go get the answer in the
same place where you asked the question.
It is OK to ask for a *copy* of the answer to be emailed, but many
will ignore such requests anyway. If you munge your address, you
should never expect (or ask) to get email in response to a Usenet
post.
Ask the question here, get the answer here (maybe).
Beware of saying "doesn't work"
This is a "red flag" phrase. If you find yourself writing that,
pause and see if you can't describe what is not working without
saying "doesn't work". That is, describe how it is not what you
want.
Sending a "stealth" Cc copy
A "stealth Cc" is when you both email and post a reply without
indicating *in the body* that you are doing so.
Be extra cautious when you get upset
Count to ten before composing a followup when you are upset
This is recommended in all Usenet newsgroups. Here in clpmisc, most
flaming sub-threads are not about any feature of Perl at all! They
are most often for what was seen as a breach of netiquette. If you
have lurked for a bit, then you will know what is expected and won't
make such posts in the first place.
But if you get upset, wait a while before writing your followup. I
recommend waiting at least 30 minutes.
Count to ten after composing and before posting when you are upset
After you have written your followup, wait *another* 30 minutes
before committing yourself by posting it. You cannot take it back
once it has been said.
AUTHOR
Tad McClellan <tadmc@augustmail.com> and many others on the
comp.lang.perl.misc newsgroup.
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 5318
***************************************