[23725] in Perl-Users-Digest
Perl-Users Digest, Issue: 5931 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Dec 12 06:05:53 2003
Date: Fri, 12 Dec 2003 03:05:05 -0800 (PST)
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, 12 Dec 2003 Volume: 10 Number: 5931
Today's topics:
Re: @ISA specific to instance rather than class? <uri@stemsystems.com>
Re: @ISA specific to instance rather than class? <ubl@schaffhausen.de>
Anyone work on Mailserver Statistics? (John Oliver)
Re: How to map URL to %xx? <mpapec@yahoo.com>
Re: improve code - combine for & join (Mike Solomon)
Make $$ now quick. THIS WORKS I SWEAR TO IT!! paid my t <djoh@yahoo.com>
Re: Perl2EXE vs. PAR vs. perlcc <simon.andrews@bbsrc.ac.uk>
Posting Guidelines for comp.lang.perl.misc ($Revision: tadmc@augustmail.com
Re: Reconnecting to Database in a script <tore@aursand.no>
recursive closures? <bik.mido@tiscalinet.it>
Re: recursive closures? <uri@stemsystems.com>
Re: windows services (Jexxa)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 12 Dec 2003 08:45:45 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: @ISA specific to instance rather than class?
Message-Id: <x7fzfq1l1i.fsf@mail.sysarch.com>
>>>>> "TvP" == Tassilo v Parseval <tassilo.parseval@rwth-aachen.de> writes:
> $object is now blessed into a new class which inherits from the
> previous class of $object, its superclasses and the two classes
> Class1 and Class2. In order to avoid clashes, the new class name is
> a random string such as '__lmcpnuvj'. This should ensure that no two
> objects get reblessed into the same class although this could of
> course still happen by coincidence.
or bless it into a dynamically made class name which has the address of
the object inside it. this is guaranteed to be unique and is done in
wacko OO modules such as Class::Classless.
> Even though Perl allows such things, I wouldn't recommend them.
using one of those modules makes it easier for each object to be its own
class and to have its own @ISA.
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: Fri, 12 Dec 2003 10:43:13 +0100
From: Malte Ubl <ubl@schaffhausen.de>
Subject: Re: @ISA specific to instance rather than class?
Message-Id: <brc5ln$p82$1@news.dtag.de>
Matthew Braid wrote:
> Hi all,
>
> I'm streamlining one of my own packages by splitting off optional
> functionality into sub-packages and only use base'ing them when
> required, eg:
>
> sub use_something {
> my $self = shift;
> eval {use base qw/My::Package::Something/};
This to not defer the use statement until after compile time. You were
probably thinking og the eval "" form.
malte
PS: Changing Super-Classes at runtime is probably not the best thing to
do. Take a look at the decorator pattern for a more robust way to
implement this behaviour.
------------------------------
Date: 12 Dec 2003 02:08:23 -0600
From: joliver@john-oliver.net (John Oliver)
Subject: Anyone work on Mailserver Statistics?
Message-Id: <slrnbtitrg.44d.joliver@ns.sdsitehosting.net>
http://mail.people.it/stats/
A very nifty little program, but not of much use without support for
sendmail, qmail, postfix, etc. I'm going to try to hack up a module for
sendmail, but probably anybody can do it much better and much faster
than I... :-)
--
************************************************************************
* John Oliver http://www.john-oliver.net/ *
* "For the wages of spam is death!" http://www.spamcon.org/legalfund/ *
************************************************************************
-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
------------------------------
Date: Fri, 12 Dec 2003 10:38:11 +0100
From: Matija Papec <mpapec@yahoo.com>
Subject: Re: How to map URL to %xx?
Message-Id: <dt2jtvc2vlbqc81obnbedc8710cug5l384@4ax.com>
On Fri, 12 Dec 2003 04:00:31 GMT, "Liberal" <test@test.com> wrote:
>$url =~ s/([^\w.-])/sprintf "%%%02X", ord $1/eg;
>
>don't understand it and don't care. it works.
So, you just wanted to share your thoughts with the world? :)
------------------------------
Date: 12 Dec 2003 02:18:49 -0800
From: mike_solomon@lineone.net (Mike Solomon)
Subject: Re: improve code - combine for & join
Message-Id: <56568be5.0312120218.50946951@posting.google.com>
Brian McCauley <nobull@mail.com> wrote in message news:<u97k13z42g.fsf@wcl-l.bham.ac.uk>...
> mike_solomon@lineone.net (Mike Solomon) writes:
>
> > I have written the following code that does what I require but I am
> > sure it could be done better
> >
> > How can I improve this
> >
> > my @required = (
> > {company => "Company is required"},
> > {address1 => "Address1 is required"},
> > {postcode => "Postcode is required"},
> > {phone => "Phone is required"},
> > );
>
> I shall assume that the above is just example input data and is not
> part of the 'this' you are seeking to improve. Obviously an array of
> single element hashes is a very weird data structure and whatever the
> data you are seeking to represent there's almost certainly a better
> structure. But without knowing the problem I couldn't say what the
> better structure is.
>
> > my (@key, @value);
> >
> > for (@required) {
> > for (keys %{$_}) { push @key, qq {'$_'};}
> > for (values %{$_}) { push @value, qq {'$_'};}
> > }
> >
> > my $key = join "," , @key;
> > my $value = join "," , @value;
> >
> > return $key , $value;
>
> The above is more simply written:
>
> return join("," => map { "'$_'" } map { keys %$_ } @required),
> join("," => map { "'$_'" } map { values %$_ } @required);
>
> Or if you prefer:
>
> return join(",", map "'$_'", map keys %$_, @required),
> join(",", map "'$_'", map values %$_, @required);
Sorry I should have said what the purpose of this code is for.
I am using it in various cgi programs that create some javascript
The data is a field name and a message
The order is important which is why I used an array
I could just have created the 2 strings to return but as I tend too
use this method in most of my cgi scripts I find the above data
structure easier to view and edit, also in some scripts I have a lot
of fields
I may well be missing an obvious simple way of doing this and any
further suggestions for improvement would be welcome
I like the map option and will probably use it
Thanks
------------------------------
Date: Fri, 12 Dec 2003 00:33:26 -0800
From: "D. Johnson" <djoh@yahoo.com>
Subject: Make $$ now quick. THIS WORKS I SWEAR TO IT!! paid my tuition
Message-Id: <brbuts$etf$1004@woodrow.ucdavis.edu>
I found this on a bulletin board and decided to try it: A little while back, I was browsing through news groups and e-mails, just like you are now, and came across an article similar to this that said you can make thousands of dollars within weeks with only an initial investment of $6.00!! So, I thought, "Yeah right, this must be a scam," but like most of us, I was curious, so I KEPT reading. Anyway, it said that you send $1.00 to each of the six names and addresses stated in the article. You then place your own name and address in the bottom of the list at $6.00, and post the article in at least 200 news groups. (There are thousands) No catch, that was it. So after thinking it over, and talking to a few people first, I thought about trying it. I figured, "What have I got to lose; except six stamps and $6.00 right, right?" Then I invested the measly $6.00.
WELL GUESS WHAT!!!
Within seven days, I started getting money in the mail!! I was shocked!! I figured it would end soon, but the money just kept coming in. In my first week, I made about $25.00. By the end of the second week I had made a total of more than $1000.00!! In the third week I had more than $10,000.00 and it's still growing!! This is now my fourth week and I have made a total of $42,000.00 and it's still coming rapidly. It's certainly worth $6.00 and six stamps, and I have spent more than that on the lottery without ever winning!!!
Let me tell you how this works and most important, why it works.......... also make sure you print this out NOW, so you can get the information off of it, as you will need it. I promise you that if you follow the directions exactly that you will start making more money than you thought possible by doing something so easy!!
Suggestion: Read this entire message carefully!! (Print it out or download it)
Follow the simple directions and watch the money come in!! It's easy. It's legal. And, your investment is only $6.00 (Plus postage)!!!
IMPORTANT:
This is not a rip-off, it is decent; it's legal; and it is virtually no risk - it really works!! If all the following instructions are adhered to, you will receive extraordinary dividends.
PLEASE NOTE:
Please follow the directions EXACTLY, and $50,000 or more can be yours in 20 to 60 days. This program remains successful because of the honesty and integrity of the participants. Please continue its success by carefully adhering to the instructions. You will now become apart of the Mail Order business. You are in the business of developing Mailing Lists. Many large corporations are happy to pay big bucks for quality lists. However, the money made from the mailing lists is secondary to income, which is made from people like you and me asking to be included in that list. Here are the four easy steps to success.
STEP ONE: Get six separate pieces of paper and write the following on each piece of paper "PLEASE PUT ME ON YOUR MAILING LIST." Now get 6 U.S. $1.00 bills and place ONE inside of EACH of the six pieces of paper so the bill will not be seen through the envelope (to prevent thievery). Next, place one paper in each of the six envelopes and seal them. You now should have six sealed envelopes, each with a piece of paper stating the above phrase, your name and address, and a $1.00 bill. What you are doing is creating a service.
THIS IS ABSOLUTELY LEGAL!!!!!
You are requesting a legitimate service and you are paying for it!! Like most of us I was a little skeptical and little worried about the legal aspects of it all. So I checked it out with the U.S. Post Office (1-800-238-5355) and they confirmed that it is indeed legal!!
Mail the six envelopes to the following addresses:
1) W. Edens
4829 Bud Ln
Lexington, KY 40514
2) L.Lessard
40 Martins Ferry Rd
Hooksett,NH 03106
3) J. Safian
6950 W. Forest Presrv. Dr., #115
Norridge, IL 60706-1324
4) G. Takla
690 Adelaide Avenue East
Oshawa, Ontario, L1G 2A8
5) Q. Huda
1212- 1315 Bough Beeches Blvd.
Mississauga, Ontario, L4W 4A1
6) D. Jacobs
148 La Rue Rd. #243
Davis, CA 95616
STEP TWO: Now take the #1 name off the list that you see above, move the other names up (six becomes 5, 5 becomes 4, and etc.) and add YOUR NAME as number 6 on the list.
STEP THREE: Change anything you need to but try to keep this article as close to original as possible. Now post your amended article to at least 200 news groups. :
(I think there are close to 24,000 groups) All you need is 200, but remember, the more you post, the more money you make!! This is perfectly legal!! If you have any doubts, refer to Title 18 Sec. 1302 & 1341 of the Postal Lottery laws. Keep a copy of these steps for yourself and whenever you need money, you can use it again, and again. PLEASE REMEMBER that this program remains successful because of the honesty and integrity of the participants and by their carefully adhering to directions. Look at it this way. If you were of integrity, the program will continue and the money that so many others have received will come your way.
NOTE: You may want to retain every name and address sent to you, either on a computer or hard copy and keep the notes people send you. This VERIFIES that you are truly providing a service. (Also, it might be a good idea to wrap the $1 bill in dark paper to reduce the risk of mail theft). So, as each post is downloaded and the directions carefully followed, all members will be reimbursed for their participation as a List Developer with one dollar each. Your name will move up the list geometrically so that when your name reaches the #1 position you will be receiving thousands of dollars in CASH!!! What an opportunity for only $6.00 ($1.00 for each of the first six people listed above) Send it now, add your own name to the list and you're in business!!!
*****DIRECTIONS FOR HOW TO POST TO NEWS GROUPS!!!*****
STEP ONE: You do not need to re-type this entire letter to do your own posting. Simply put your cursor at the beginning of this letter and drag your cursor to the bottom of this document, and select 'copy' from the edit menu. This will copy the entire letter into the computer's memory.
STEP TWO: Open a blank 'notepad' file and place your cursor at the top of the blank page. From the 'edit' menu select 'paste'. This will paste a copy of the letter into the notepad so that you will add your name to the list.
STEP THREE: Save your new notepad file as a text file. If you want to do your posting in different settings, you'll always have this file to go back to.
STEP FOUR: You can use a program like "postXpert" to post to all the newsgroups at once. You can find this program at <http://www.download.com>. If you don't understand how it works you can email me at: mailto:andreass@orange.nl (this is only when my name is in the list, so send a copy of my address as well. put this in the header: make millions very easy + my full name)
Use Netscape or Internet Explorer and try searching for various new groups (on- line forums, message boards, chat sites, discussions.)
STEP FIVE: Visit message boards and post this article as a new message by highlighting the text of this letter and selecting paste from the edit menu. Fill in the subject, this will be the header that everyone sees as they scroll through the list of postings in a particular group, click the post message button. You're done.
Congratulations!!!!!!
THAT'S IT!! All you have to do, and It Really works!!!
Best Wishes
------------------------------
Date: Fri, 12 Dec 2003 08:36:50 +0000
From: Simon Andrews <simon.andrews@bbsrc.ac.uk>
Subject: Re: Perl2EXE vs. PAR vs. perlcc
Message-Id: <brbun4$p92$1@south.jnrs.ja.net>
Alan Stewart wrote:
> On Mon, 08 Dec 2003 15:03:25 +0000, Simon Andrews
> <simon.andrews@bbsrc.ac.uk> wrote:
>
>
>>ppm install PAR
>>
>>[wait whilst PAR installs]
>>
>
> I have always downloaded PAR from par.perl.org and compiled myself,
I've actually done both at different times. I did say that my
instructions were the least you might have to do to get a working
compiled executatble. Having said that, the installer which comes with
PAR is one of the best I've seen for any module.
> but I wonder what version you see with ppm?
>
> I run ActiveState 5.6 build 635 and ppm3 tells me their repository
> only has version 0.63. There have been some important bug fixes since
> then.
M:\>ppm search PAR
Searching in Active Repositories
[snip stuff]
118. PAR [0.75] Perl Archive Tookit
M:\>perl -v
This is perl, v5.8.0 built for MSWin32-x86-multi-thread
0.75 is pretty recent. The new PAR builds seem to be playing better
with the ActiveState auto-compile routines so updates do get pushed out
in a reasonably timely mannar (though possibly only for 5.8.x?).
Simon.
------------------------------
Date: Fri, 12 Dec 2003 02:23:47 -0600
From: tadmc@augustmail.com
Subject: Posting Guidelines for comp.lang.perl.misc ($Revision: 1.4 $)
Message-Id: <TKKdnRTPEtuO5kSiRVn-ig@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: Fri, 12 Dec 2003 09:10:36 +0100
From: Tore Aursand <tore@aursand.no>
Subject: Re: Reconnecting to Database in a script
Message-Id: <pan.2003.12.12.07.50.49.838066@aursand.no>
On Thu, 11 Dec 2003 11:53:25 -0800, dn_perl@hotmail.com wrote:
> I run a perl script which uses an infinite loop.
> I would like to incorporate checks which allow me to exit
> the infinite loop if the database is brought down.
Do you really want to do that? Why don't you want to reconnect to the
database?
> $dbh = DBI->connect or die ;
> while(1) {
> do certain things ;
> if( str eq 'this' ) { # check one
> last;
> }
> # I want to add check # two here
> sleep 100 ;
> }
> $dbh->disconnect ;
Check #2 could be something like this;
last unless ( $dbh->ping() );
However, I would have written this routine like this (and then have my
script reconnect to the server if the connection is lost):
my $dbh = undef;
while ( 1 ) {
unless ( defined $dbh || $dbh->ping() ) {
# Connect
}
# The rest of the loop
}
$dbh->disconnect if ( defined $dbh && $dbh->ping() );
--
Tore Aursand <tore@aursand.no>
"I am become Death, shatterer of worlds." -- J. Robert Oppenheimer,
upon witnessing the explosion of the first atomic bomb.
------------------------------
Date: 12 Dec 2003 08:48:31 GMT
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: recursive closures?
Message-Id: <qb50uv4p90l1lbia9u7kqgtdcb9eer9cba@4ax.com>
I was wondering if it could be possible for a sub to return a
recursive closure. Of course this turns out to be possible, although,
to the best of my efforts, not in "one step", see e.g. the following
code:
#!/usr/bin/perl -l
# Oversimplified example
use strict;
use warnings;
sub mkrecsub {
my $k=shift;
my @memoize = ( $k => [0,1] );
my $tmp = sub {
my ($n, $func) = @_;
return $memoize[$k][$n] if defined $memoize[$k][$n];
$memoize[$k][$n] =
$func->($n-1, $func) + $func->($n-2, $func);
};
sub { $tmp->(shift, $tmp) };
}
my $Fib = mkrecsub(1);
print $Fib->($_) for 1..73;
__END__
Now I wonder if there is/could be (could not find any!) some sort of
identifier that refers to the current (anomynous) sub; say, something
like __SUB__ or __THIS__, to be used like this:
sub {
...
__SUB__->(...);
}
Michele
--
# This prints: Just another Perl hacker,
seek DATA,15,0 and print q... <DATA>;
__END__
------------------------------
Date: Fri, 12 Dec 2003 08:59:14 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: recursive closures?
Message-Id: <x7brqe1kf2.fsf@mail.sysarch.com>
>>>>> "MD" == Michele Dondi <bik.mido@tiscalinet.it> writes:
> I was wondering if it could be possible for a sub to return a
> recursive closure. Of course this turns out to be possible, although,
> to the best of my efforts, not in "one step", see e.g. the following
> code:
> sub mkrecsub {
> my $k=shift;
> my @memoize = ( $k => [0,1] );
> my $tmp = sub {
make my $sub be a separate line. then you can refer to it INSIDE the
closure and also assign to it. a recent post had someone else with the
same problem. you can't refer to a my variable in the same statement
that declares it.
so something like:
my $sub ;
$sub = sub{ blah; $sub->() }
should work. i have seen damian do it for sure and i think that is the
general syntax idea. search google groups for this and you may find a
hit with his code doing that.
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: 12 Dec 2003 02:40:24 -0800
From: jeremy@emmjay.freeserve.co.uk (Jexxa)
Subject: Re: windows services
Message-Id: <90225942.0312120240.2417bbaf@posting.google.com>
ko <kuujinbo@hotmail.com> wrote in message news:<br9l0u$t3b$1@pin3.tky.plala.or.jp>...
> Jexxa wrote:
> > kuujinbo@hotmail.com (ko) wrote in message news:<92d64088.0312101450.2e006ea9@posting.google.com>...
>
> [snip]
>
> > You know you are right. However I'm running on win 2000 and the
> > service status tends to come back as an empty hash. probably something
> > in the policy, or something. All I can get is a list of services that
> > may or may not be running. Some services return status information but
> > not the ones I am interested in.
> >
> > Thanks anyway.
> >
> > Jeremy
>
> Haven't played with the module in while. Also had another link with more
> sample scripts, but can't find it now...
>
> Anyway, try this:
>
> use strict;
> use warnings;
> use Win32::Service qw[GetServices GetStatus];
>
> my (%services, %status);
> GetServices('', \%services);
> foreach my $service(sort keys %services) {
> print "$services{$service} [ $service ]\n";
> GetStatus('', $services{$service}, \%status);
> foreach (keys %status) {
> # remove this for more info
> print "\t$_: $status{$_}\n" if $_ eq 'CurrentState';
> }
> }
>
> When 'CurrentState' has a value of 1, the service is stopped. When the
> value is 4, the service is running. See comment in code to get more info
> - but as stated in the Win32::Service docs, you'll have to check the
> Win32 Platform SDK documentation to see what everything means.
>
> To stop/start a service import StartService()/StopService(), and make
> sure that you use the service name (key of the %services hash above) as
> the second argument.
>
> HTH -keith
solved my problem of not getting back the status info. I had to use
the value rather than the key of the hash returned by GetServices. Not
sure why all the documentation says key. maybe its because its windows
2000. but then it still works when I interrogate NT4 machines from my
win 2000 box.
Thanks for all the help
Jeremy
------------------------------
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 5931
***************************************