[31295] in Perl-Users-Digest
Perl-Users Digest, Issue: 2540 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Aug 7 06:09:54 2009
Date: Fri, 7 Aug 2009 03:09:19 -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 Fri, 7 Aug 2009 Volume: 11 Number: 2540
Today's topics:
Re: conditional modules <stoupa@practisoft.cz>
constant variable in perl <abu.4000@gmail.com>
Re: constant variable in perl <news123@free.fr>
Re: constant variable in perl <abu.4000@gmail.com>
Re: constant variable in perl <ben@morrow.me.uk>
Re: constant variable in perl <abu.4000@gmail.com>
Re: constant variable in perl <abu.4000@gmail.com>
Re: FAQ 8.14 How do I modify the shadow password file o (Alan Curry)
Re: FAQ 8.14 How do I modify the shadow password file o <kkeller-usenet@wombat.san-francisco.ca.us>
Re: Function prototype (Alan Curry)
Re: Function prototype <ben@morrow.me.uk>
Re: Function prototype <xhoster@gmail.com>
Re: Improving page layout when doing elementary CGI pro <bugbear@trim_papermule.co.uk_trim>
Re: issue with multiprocess - fork <xhoster@gmail.com>
Re: Passing structure from perl to C. <xhoster@gmail.com>
Posting Guidelines for comp.lang.perl.misc ($Revision: tadmc@seesig.invalid
Re: problem with fork <xhoster@gmail.com>
Usage of sub-routine prototype <abu.4000@gmail.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 7 Aug 2009 01:06:23 +0200
From: "Petr Vileta \"fidokomik\"" <stoupa@practisoft.cz>
Subject: Re: conditional modules
Message-Id: <h5fnu1$lq8$1@ns.felk.cvut.cz>
John wrote:
> Hi
>
> Can you access modules with a condition, ie
>
> my ($language,$text);
> if ($language eq 'English') {use English; $text=new English;}
> elsif ($language eq 'German') {use German; $text=new German;}
> etc
>
my ($language,$text);
if ($language eq 'English') {require English; $text=new English;}
elsif ($language eq 'German') {require German; $text=new German;}
--
Petr Vileta, Czech Republic
(My server rejects all messages from Yahoo and Hotmail.
Send me your mail from another non-spammer site please.)
Please reply to <petr AT practisoft DOT cz>
------------------------------
Date: Thu, 6 Aug 2009 22:31:17 -0700 (PDT)
From: Alexander Jack <abu.4000@gmail.com>
Subject: constant variable in perl
Message-Id: <bad7bcb7-4bc5-4ff1-94dc-5ba199b42ea2@i4g2000prm.googlegroups.com>
How to declare and use a constant variable in Perl ,
please help me out ,
thanx in Advance .
------------------------------
Date: Fri, 07 Aug 2009 09:00:51 +0200
From: News123 <news123@free.fr>
Subject: Re: constant variable in perl
Message-Id: <4a7bd123$0$426$426a34cc@news.free.fr>
Hi ALex,
As so often.
Perldoc would be your friend.
or if you prefer web front ends
(go to http://perldoc.perl.org/ and enter constant in the search field)
One Alexander Jack wrote:
> How to declare and use a constant variable in Perl ,
> please help me out ,
>
There's multiple option:
the one directly documented in the perl onine documentation can be seen with
perldoc constant
> =head1 NAME
>
> constant - Perl pragma to declare constants
>
> =head1 SYNOPSIS
>
> use constant PI => 4 * atan2(1, 1);
> use constant DEBUG => 0;
>
> print "Pi equals ", PI, "...\n" if DEBUG;
------------------------------
Date: Fri, 7 Aug 2009 00:17:13 -0700 (PDT)
From: Alexander Jack <abu.4000@gmail.com>
Subject: Re: constant variable in perl
Message-Id: <cb814206-bb5d-4d1d-87f7-b7bf42830079@m7g2000prd.googlegroups.com>
On Aug 7, 12:00 pm, News123 <news...@free.fr> wrote:
> Hi ALex,
>
> As so often.
>
> Perldoc would be your friend.
> or if you prefer web front ends
> (go tohttp://perldoc.perl.org/and enter constant in the search field)
>
> One Alexander Jack wrote:
> > How to declare and use a constant variable in Perl ,
> > please help me out ,
>
> There's multiple option:
>
> the one directly documented in the perl onine documentation can be seen with
>
> perldoc constant
>
> > =head1 NAME
>
> > constant - Perl pragma to declare constants
>
> > =head1 SYNOPSIS
>
> > use constant PI => 4 * atan2(1, 1);
> > use constant DEBUG => 0;
>
> > print "Pi equals ", PI, "...\n" if DEBUG;
Thank you news
------------------------------
Date: Fri, 7 Aug 2009 07:39:22 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: constant variable in perl
Message-Id: <qpusk6-9nh2.ln1@osiris.mauzo.dyndns.org>
Quoth Alexander Jack <abu.4000@gmail.com>:
> How to declare and use a constant variable in Perl ,
> please help me out ,
use constant NAME => "value";
or
use Readonly;
Readonly my $var = "value";
depending on which you prefer.
Ben
------------------------------
Date: Fri, 7 Aug 2009 01:28:46 -0700 (PDT)
From: Alexander Jack <abu.4000@gmail.com>
Subject: Re: constant variable in perl
Message-Id: <42ed00e7-9f6a-4356-b469-d82ff73d1665@12g2000pri.googlegroups.com>
On Aug 7, 11:39 am, Ben Morrow <b...@morrow.me.uk> wrote:
> Quoth Alexander Jack <abu.4...@gmail.com>:
>
> > How to declare and use a constant variable in Perl ,
> > please help me out ,
>
> use constant NAME => "value";
>
> or
>
> use Readonly;
> Readonly my $var = "value";
>
> depending on which you prefer.
>
> Ben
Don't think that I am too greedy , but I want to know what is the
difference between constant and Readonly in perl .
------------------------------
Date: Fri, 7 Aug 2009 01:31:26 -0700 (PDT)
From: Alexander Jack <abu.4000@gmail.com>
Subject: Re: constant variable in perl
Message-Id: <e696fa3c-b482-4dae-bacf-b52017d6f583@i8g2000pro.googlegroups.com>
On Aug 7, 11:39 am, Ben Morrow <b...@morrow.me.uk> wrote:
> Quoth Alexander Jack <abu.4...@gmail.com>:
>
> > How to declare and use a constant variable in Perl ,
> > please help me out ,
>
> use constant NAME => "value";
>
> or
>
> use Readonly;
> Readonly my $var = "value";
>
> depending on which you prefer.
>
> Ben
I didn't find any pragma like Readonly in my system , Can you tell me
how to get this...
------------------------------
Date: Fri, 7 Aug 2009 01:52:41 +0000 (UTC)
From: pacman@kosh.dhis.org (Alan Curry)
Subject: Re: FAQ 8.14 How do I modify the shadow password file on a Unix system?
Message-Id: <h5g1d9$k5m$1@aioe.org>
In article <lnhbwkj35j.fsf@nuthaus.mib.org>,
Keith Thompson <kst-u@mib.org> wrote:
>PerlFAQ Server <brian@stonehenge.com> writes:
>[...]
>> 8.14: How do I modify the shadow password file on a Unix system?
>>
>> If perl was installed correctly and your shadow library was written
>> properly, the getpw*() functions described in perlfunc should in theory
>> provide (read-only) access to entries in the shadow password file. To
>> change the file, make a new shadow password file (the format varies from
>> system to system--see passwd for specifics) and use pwd_mkdb(8) to
>> install it (see pwd_mkdb for more details).
>[...]
>
>This should mention that pwd_mkdb may not be available on all
>systems. It doesn't exist on my Ubuntu system or on Solaris 9.
>I think it's a BSDism.
This whole FAQ entry is nothing but a disguised rant (originally written by
Tom Christiansen, I'll bet) about how SysV/Linux/glibc shadow functions
aren't "written properly" because they added a parallel set of functions
(getsp*) to read the shadow file instead of warping the behavior of getpw*
in a manner dependent on the process's privileges, which Tom decreed was the
only "proper" way.
The answer was not meant to be useful to you on your Ubuntu or Solaris
system. It was meant to insult you for not using BSD.
The complete omission of the names of any functions or external programs that
might be useful on a SysV or Linux system, leaving you with not even a lead
to follow, was deliberate.
If it was meant to be useful, this answer would contain words like usermod
and getspnam. But they're not "proper".
--
Alan Curry
------------------------------
Date: Thu, 6 Aug 2009 19:25:55 -0700
From: Keith Keller <kkeller-usenet@wombat.san-francisco.ca.us>
Subject: Re: FAQ 8.14 How do I modify the shadow password file on a Unix system?
Message-Id: <jufsk6x35e.ln2@goaway.wombat.san-francisco.ca.us>
On 2009-08-07, Alan Curry <pacman@kosh.dhis.org> wrote:
>
> This whole FAQ entry is nothing but a disguised rant
Did you have new text to propose, or would you rather just rant?
--keith
--
kkeller-usenet@wombat.san-francisco.ca.us
(try just my userid to email me)
AOLSFAQ=http://www.therockgarden.ca/aolsfaq.txt
see X- headers for PGP signature information
------------------------------
Date: Fri, 7 Aug 2009 02:11:12 +0000 (UTC)
From: pacman@kosh.dhis.org (Alan Curry)
Subject: Re: Function prototype
Message-Id: <h5g2g0$l47$1@aioe.org>
In article <slrnh7mcni.3g6.hjp-usenet2@hrunkner.hjp.at>,
Peter J. Holzer <hjp-usenet2@hjp.at> wrote:
>
>With a suitable prototype in scope, it knows that some_function() will
>return exactly one element, since it is called in scalar context.
>
>Yes, that means that with a prototype
>
> sub add($$);
>
>this
>
> my $sum = add(some_function());
>
>cannot work, because the compiler will notice at compile time that add
>has only one argument, not two, and will abort the compilation. This may
>be a problem or it may be what the OP wants.
Once upon a time, I tried something like this, honestly expecting it to work:
sub foo ($$$$);
if($something) {
@args=($a, $b, $c, 0);
} else {
@args=($x, $y, $z, 1);
}
foo(@args);
It's easy to see at compile time that @args will always have the proper
number of elements to satisfy the prototype. But prototypes don't do that,
and furthermore there's nothing in perl that does do that, so you have to
live with run-time assertions. Oh well.
--
Alan Curry
------------------------------
Date: Fri, 7 Aug 2009 03:47:23 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Function prototype
Message-Id: <r6hsk6-p4q1.ln1@osiris.mauzo.dyndns.org>
Quoth pacman@kosh.dhis.org (Alan Curry):
> In article <slrnh7mcni.3g6.hjp-usenet2@hrunkner.hjp.at>,
> Peter J. Holzer <hjp-usenet2@hjp.at> wrote:
> >
> >With a suitable prototype in scope, it knows that some_function() will
> >return exactly one element, since it is called in scalar context.
<snip>
>
> Once upon a time, I tried something like this, honestly expecting it to work:
>
> sub foo ($$$$);
>
> if($something) {
> @args=($a, $b, $c, 0);
> } else {
> @args=($x, $y, $z, 1);
> }
>
> foo(@args);
>
> It's easy to see at compile time that @args will always have the proper
> number of elements to satisfy the prototype.
No it's not, at least not without performing seriously difficult
data-flow analysis which is (because of tie, for one thing) impossible
in Perl.
> But prototypes don't do that, and furthermore there's nothing in perl
> that does do that, so you have to live with run-time assertions. Oh
> well.
Perl 5 prototypes are *just* a (somewhat hackish and misguided) attempt
to allow user-defined function to parse the same way as (some) builtins.
Trying to use them for anything else is a mistake.
Ben
------------------------------
Date: Thu, 06 Aug 2009 19:16:11 -0700
From: Xho Jingleheimerschmidt <xhoster@gmail.com>
Subject: Re: Function prototype
Message-Id: <4a7ba79c$0$9217$ed362ca5@nr5-q3a.newsreader.com>
Charlton Wilbur wrote:
>>>>>> "TZ" == Ted Zlatanov <tzz@lifelogs.com> writes:
>
>
> TZ> He specifically asked for compile-time checks.
>
> And how do you propose that the compiler can check that?
The same way it does for built-ins.
>
> If the compiler sees
>
> my $sum = add(some_function());
>
> how is it supposed to know that some_function() will return exactly two
> elements in a list, for instance?
It isn't. It is supposed to know that some_function will return exactly
one element. That is because it will arrange for some_function to be
called in a scalar context.
What do you think "split some_function()" does?
Xho
------------------------------
Date: Fri, 07 Aug 2009 09:06:21 +0100
From: bugbear <bugbear@trim_papermule.co.uk_trim>
Subject: Re: Improving page layout when doing elementary CGI programming.
Message-Id: <456dnd7A5sHgfebXnZ2dnUVZ8nRi4p2d@brightview.co.uk>
smallpond wrote:
>
> There are a lot of perl modules for parsing CSS. It would be handy
> if there was some WYSIWYG tool for generating CSS. The last perl
> UI that I worked on had paper & pencil layout, then a lot of
> tweaking and testing of CSS in an editor, then viewing the result
> in a browser and guessing how to make it look like you want.
>
> Changing "75px" to "100px" in a file, saving it, and reloading it
> in a browser is much lower productivity then just grabbing it with
> the mouse and sliding it an inch to the right.
If you're using any of the "cascading" features
of CSS with any sophistication, this can't work.
The sort of WYSIWIG you're wishing for is only
practical with all-the-parameters-set-for-everything-object
style HTML, which defeats the benefit of CSS.
BugBear
------------------------------
Date: Thu, 06 Aug 2009 19:37:45 -0700
From: Xho Jingleheimerschmidt <xhoster@gmail.com>
Subject: Re: issue with multiprocess - fork
Message-Id: <4a7ba79d$0$9217$ed362ca5@nr5-q3a.newsreader.com>
friend.05@gmail.com wrote:
> My script is using fork so there are child processes. Sometimes my
> script runs properly and output is correct. But sometime my script
> gets stuck just after exiting child process.
Asking the same question under a different subject line is more likely
to annoy the people you want to help you, than it is to get you more help.
Threads exist for a reason.
Xho
------------------------------
Date: Thu, 06 Aug 2009 21:01:32 -0700
From: Xho Jingleheimerschmidt <xhoster@gmail.com>
Subject: Re: Passing structure from perl to C.
Message-Id: <4a7ba7aa$0$9217$ed362ca5@nr5-q3a.newsreader.com>
Prathap wrote:
> On Aug 6, 8:32 am, Xho Jingleheimerschmidt <xhos...@gmail.com> wrote:
>> Prathap wrote:
>>
>>> The C function addStruct takes pointer to structure as an input.
>>> How do I make perl pass the data as pointer to structure kind of
>>> variable?
>> I'd use a wrapper. (This is for Inline, not XS)
>>
>> int addStruct_wrapper(int t1, int t2) {
>> struct test t;
>> t.t1=t1;
>> t.t2=t2;
>> return addStruct(&t);
>>
>> };
>>
>
> Thanks for the reply.
> How do I access the members of the structure that the C routinue
> returns in Perl.
I wouldn't. I carefully arranged for it to happen that C never returns
a struct test * to Perl. If you return a pointer to Perl, then it AFAIK
it will have to get cast to a void *, rather than a specific pointer,
and then from there will get recast to an int of the appropriate size.
Now you have this thing in Perl, that is a struct test * but as far as
Perl knows it is just an integer. And just who is responsible for
deciding when it should be freed and actually doing the freeing?
I really don't want to deal with crap like that on a regular basis. If
I did, I'd just stick with C in the first place rather than using Perl
and trying to interface them together in a messy hodge-podge.
If I really needed to do this, there are several different ways I could
choose from. You could return a list of values, and interpret it
positionally, like Sisyphus showed. Or return a list of name value
pairs and assign it to a hash. Or define a getter method for each
element of the struct (which requires you to deal with naked pointers in
Perl, ugh). Which one I chose would depend the exact situation. Your
exact situation seems to be adding two integers, which I wouldn't try to
accomplish by juggling back and forth between Perl and C in the first place.
use Inline C;
my $x=addStruct_ptr(8,9);
print get_t1($x);
__END__
__C__
struct test
{
int t1;
int t2;
} test;
void * addStruct_ptr(int t1, int t2) {
struct test *t;
t=(struct test *) malloc(sizeof(struct test));
t->t1=t1;
t->t2=t2;
return t;
};
int get_t1(void * x) {
return ((struct test *)x)->t1;
};
Xho
------------------------------
Date: Fri, 07 Aug 2009 02:17:38 -0500
From: tadmc@seesig.invalid
Subject: Posting Guidelines for comp.lang.perl.misc ($Revision: 1.9 $)
Message-Id: <OPOdnciOCoiPSObXnZ2dnUVZ_g2dnZ2d@giganews.com>
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.9 $)
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.
The article at:
http://www.catb.org/~esr/faqs/smart-questions.html
describes how to get answers from technical people in general.
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://www.rehabitation.com/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 that they do
know and are being the "bad kind" of Lazy.
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_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
"top-posting", "Jeopardy" (because the answer comes before the
question), or "TOFU" (Text Over, Fullquote Under).
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 and many others on the comp.lang.perl.misc newsgroup.
--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"
------------------------------
Date: Thu, 06 Aug 2009 18:47:29 -0700
From: Xho Jingleheimerschmidt <xhoster@gmail.com>
Subject: Re: problem with fork
Message-Id: <4a7b87a0$0$9223$ed362ca5@nr5-q3a.newsreader.com>
friend.05@gmail.com wrote:
>
> And I check the trace(truss -p on sun). I found that sometimes one of
> the child goes to sleeping and parent is still waiting for that child
> exit status. But it never gets that bcoz child is sleeping.
What system call does it use to put itself to sleep? You are quite sure
that it reaches the "exit" before going to sleep? If it prints its
exiting message immediately before the exit, what do you see in the
strace between the "write" (or whatever system call does the actual
printing) and the command that puts it to sleep?
Xho
------------------------------
Date: Thu, 6 Aug 2009 21:06:18 -0700 (PDT)
From: Alexander Jack <abu.4000@gmail.com>
Subject: Usage of sub-routine prototype
Message-Id: <f67ec3e9-7f68-4348-836a-24ce37d34879@x6g2000prc.googlegroups.com>
Dear friends ,
Can any one tell me what is the usage of sub-routine prototype , I
know that was optional one but I wanted to know that whether it has
any usages.
ThanX in advance
------------------------------
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.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
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 V11 Issue 2540
***************************************