[22458] in Perl-Users-Digest
Perl-Users Digest, Issue: 4679 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Mar 7 06:05:56 2003
Date: Fri, 7 Mar 2003 03:05:10 -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, 7 Mar 2003 Volume: 10 Number: 4679
Today's topics:
Re: Auto save an image everyday (Anno Siegel)
Re: dbm <jvandervloet@hotmail.com>
Floyd-Warshall on undirected graph? <a_valarakos@hotmail.com>
Re: Floyd-Warshall on undirected graph? (Anno Siegel)
Re: Help with Inline::CPP.... <kalinabears@hdc.com.au>
Re: I want to know the line n umber of the error ! <tore@aursand.no>
Re: Lightweight CGI module? <ubl@schaffhausen.de>
Re: Lightweight CGI module? <tore@aursand.no>
Re: Lightweight CGI module? <tore@aursand.no>
Re: New module proposed: Class::Accessor::NoviceArray <ubl@schaffhausen.de>
Re: New module proposed: Class::Accessor::NoviceArray <ubl@schaffhausen.de>
Re: Non-fatal error, "script not found or unable to sta (Anno Siegel)
Re: Non-fatal error, "script not found or unable to sta <nobull@mail.com>
Obfuscated Perl Challenge <goldbb2@earthlink.net>
POSIX Charcter Classes and tr <ajglist@izzy.net>
Re: POSIX Charcter Classes and tr <mgjv@tradingpost.com.au>
Posting Guidelines for comp.lang.perl.misc ($Revision: tadmc@augustmail.com
Re: Problem Implementing Sleep() Function <wksmith@optonline.net>
Re: Put perl in old page (distrex)
Re: question about "new" in a module <bigj@kamelfreund.de>
Re: question about "new" in a module <tore@aursand.no>
Re: question about "new" in a module (Anno Siegel)
Regular Expression <ajglist@izzy.net>
Re: Regular Expression <ajglist@izzy.net>
Re: Regular Expression <uri@stemsystems.com>
Re: Regular Expression <ajglist@izzy.net>
Skip directories and Find (kydongau)
Re: Skip directories and Find <goldbb2@earthlink.net>
Unix TAIL program <kasp@epatra.com>
Re: Unix TAIL program <tore@aursand.no>
Re: Unix TAIL program (Anno Siegel)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 7 Mar 2003 11:03:03 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Auto save an image everyday
Message-Id: <b49u97$n6m$3@mamenchi.zrz.TU-Berlin.DE>
Jürgen Exner <jurgenex@hotmail.com> wrote in comp.lang.perl.misc:
> gonky wrote:
> > I want to know how i can auto schedule a perl script to run at a
> > certain time daily.
>
> Depends on your OS.
> On Unix use cron, on Windows use at, on Mac I've not idea.
If it's OS X, use cron :)
Anno
------------------------------
Date: Fri, 07 Mar 2003 08:11:14 GMT
From: "joeri" <jvandervloet@hotmail.com>
Subject: Re: dbm
Message-Id: <CuY9a.2872$Ma.333@afrodite.telenet-ops.be>
"Brian McCauley" <nobull@mail.com> wrote in message
news:u9heag72ud.fsf@wcl-l.bham.ac.uk...
> The first sentence of the documentation for dbmopen() reads "This
> function has been largely superseded...".
I know, but I've been trying to install DB_File, BerkeleyDB, DBD-Oracle,
etc. for two days now
without success :-{
> You can't. You must convert your data to strings. You can just
> join() it or use something like Storable.
Thanks. I tried that and it worked.
J
------------------------------
Date: Fri, 7 Mar 2003 09:57:05 +0200
From: "Alexandros" <a_valarakos@hotmail.com>
Subject: Floyd-Warshall on undirected graph?
Message-Id: <b49jbt$1p70$1@ulysses.noc.ntua.gr>
Hello,
i tried to apply APSP_Floyd_Warshall on a undirected graph but i didn't get
the expected output. Then i realised that the algorith should be applied on
a direxted graph.
Is it possible to overcome this prob.?
Thanx in advance
Alexandros V
------------------------------
Date: 7 Mar 2003 09:01:37 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Floyd-Warshall on undirected graph?
Message-Id: <b49n5h$hct$1@mamenchi.zrz.TU-Berlin.DE>
Alexandros <a_valarakos@hotmail.com> wrote in comp.lang.perl.misc:
> Hello,
>
> i tried to apply APSP_Floyd_Warshall on a undirected graph but i didn't get
What is "APSP_Floyd_Warshall"? The one Perl implementation I know
of is Abigail's Algorithm::Graphs::TransitiveClosure.
> the expected output. Then i realised that the algorith should be applied on
> a direxted graph.
> Is it possible to overcome this prob.?
Usually an undirected graph is represented as a directed graph with
(directed) vertices going in both directions. A Floyd_Warshall
implementation should be able to deal with both.
Anno
------------------------------
Date: Fri, 7 Mar 2003 17:23:07 +1100
From: "Sisyphus" <kalinabears@hdc.com.au>
Subject: Re: Help with Inline::CPP....
Message-Id: <3e683ba2$0$14085@echo-01.iinet.net.au>
"Brian Snyder" <bsnyder030174@yahoo.com> wrote in message
news:668c9529.0303060710.35de8312@posting.google.com...
> (First off, let me say this is a duplicate of a post I made to
> perl.inline newsgroup -- but that seems to be a dead group, so I
> thougth I'd try here)
>
That list is not dead, afaik - though it is rather quiet at the moment :-)
I didn't receive a copy of your post (though I'm subscribed) - nor can I see
it on the Archive.
I assume your referring to inline@perl.org for which the subscription
procedure can be found at http://lists.perl.org .
Are you sure you successfully subscribed ?
Cheers,
Rob
------------------------------
Date: Fri, 07 Mar 2003 10:05:49 +0100
From: "Tore Aursand" <tore@aursand.no>
Subject: Re: I want to know the line n umber of the error !
Message-Id: <pan.2003.03.07.08.49.05.704871@aursand.no>
On Fri, 07 Mar 2003 02:13:37 +0100, Gunnar Hjalmarsson wrote:
>> Why should _we_ be bothered with people whose problems occur because of
>> their need to reinvent the wheel every time? Isn't in it's place to
>> tell those people _how_ one should do things The Right Way (tm)?
> TIMTOWTDI.
Yes. And it's nice if someone want to _discuss_ a certain approach to
solve a certain problem. Most newbies doesn't do that, however.
> But, yes, people should indeed be *recommended* to make use of
> applicable modules. They'd better not be told that they are stupid if
> they don't...
Of course not. I haven't seen anyone in this newsgroup calling anyone
stupid. But I myself have _almost_ called a certain way to do a thing
stupid at least a few times. :)
>> Funny as it is, though; I myself requested a lightweight CGI
>> replacement earlier today. *g*
> I couldn't help noticing that. :)
Yeah, and know they're calling _me_ stupid. *hmph* :)
--
Tore Aursand <tore@aursand.no>
------------------------------
Date: Fri, 07 Mar 2003 09:46:45 +0100
From: Malte Ubl <ubl@schaffhausen.de>
Subject: Re: Lightweight CGI module?
Message-Id: <b49pg9$hbs$1@news.dtag.de>
Tore Aursand wrote:
> Ah. I might have been trying to fool everyone here. I suddenly became
> aware that I might have been saying 'loading' when I actually mean
> 'creating a new instance of'.
>
> The time it takes CGI.pm to spit out an instance of itself is the same, I
> guess, wether the module itself is preloaded or not. (And remember that I
> can't rely on the compile option here).
Alright. Instance creation time is independent of:
- the compile option
- any possible bloat in the module, that is not invoked on a call to new
The algorithm should be O(n) where n is the number of parameters you
passed to the script. So, you can improve instance creation time by
reducing the number of parameters you pass :)
I doubt that one could really improve the instance creation time of the
CGI module. You could probably implement the whle parameter parsing
stuff in C, but I don't think that will gain you much. Otherwise
somebody would certainly have done it already.
If you are really that concerned about performance choose a couple
modules that are interface polymorph to CGI.pm and go ahead benchmark.
->malte
--
srand 108641088; print chr int rand 256 for qw<J A P H>
------------------------------
Date: Fri, 07 Mar 2003 10:05:51 +0100
From: "Tore Aursand" <tore@aursand.no>
Subject: Re: Lightweight CGI module?
Message-Id: <pan.2003.03.07.08.57.13.650141@aursand.no>
On Thu, 06 Mar 2003 20:29:50 -0500, Benjamin Goldberg wrote:
>>> What makes you think you can cache everything but CGI.pm?
>> Well. Almost everything. Of course, something is _impossible_ to
>> parse, due to the course of the application, but most of it is cached.
>> The most important things, if I remember correctly, must be:
> You mistook the important part of Tore's question.
Hmm. Of Ben's question, I think. :)
> If you can cache everything else, why can't you cache CGI.pm?
How can I? As I wrote in the previous post, I've been a little sloppy
when it comes to using the right terms here;
As long as I'm running for example mod_perl (or PerlEx), I can cache
whatever it is in memory. Nice, and this is being done - also for CGI.pm.
However, with _most_ of the other modules, I even keep them in memory
_after_ they've been created. I didn't think I could do that with CGI.pm,
as it then would miss out the query...?
Example: I have a module called 'Nifty', because it contains a few nifty
methods I've gathered. This module doesn't need to be created for each
request, so I store the created instance in memory;
use vars qw( $Nifty );
.
.
.
unless ( defined $Nifty ) {
$Nifty = Nifty->new();
}
}
If the new() method in Nifty contains _a lot_ of heavy code, this saves me
pretty much time. CGI.pm _does_ require some "heavy code" to be run every
times it's instanciated (right word?), and I want to keep it from doing
that.
I have been playing around with a CGI module of my own; It does most of
the things CGI.pm does at startup (ie. when running new()), except it does
it slightly (ie. 400 percent) faster. :)
When using that module instead of CGI.pm - _and_ running under mod_perl -
my application _becomes_ faster. Not 400 percent faster, of course, but
approximately 10% faster, which is significantly enough for me.
--
Tore Aursand <tore@aursand.no>
------------------------------
Date: Fri, 07 Mar 2003 11:44:18 +0100
From: "Tore Aursand" <tore@aursand.no>
Subject: Re: Lightweight CGI module?
Message-Id: <pan.2003.03.07.10.41.57.750614@aursand.no>
On Fri, 07 Mar 2003 09:46:45 +0100, Malte Ubl wrote:
> I doubt that one could really improve the instance creation time of the
> CGI module.
Hmm. Well. Looking at the code, it seems like there's some room for
improvement, don't you think?
--
Tore Aursand <tore@aursand.no>
------------------------------
Date: Fri, 07 Mar 2003 09:23:15 +0100
From: Malte Ubl <ubl@schaffhausen.de>
Subject: Re: New module proposed: Class::Accessor::NoviceArray
Message-Id: <b49o47$3os$1@news.dtag.de>
Ronald Schmidt wrote:
> Would anyone care to comment on the relevance of this fine point of
> array like behavior in scalar context?
Maybe what you want is to extend Class::MethodMaker, instead of
reinventing the whole wheel.
--
srand 108641088; print chr int rand 256 for qw<J A P H>
------------------------------
Date: Fri, 07 Mar 2003 09:35:47 +0100
From: Malte Ubl <ubl@schaffhausen.de>
Subject: Re: New module proposed: Class::Accessor::NoviceArray
Message-Id: <b49orn$e26$1@news.dtag.de>
Ronald Schmidt wrote:
> NAME
> Class::Accessor::NoviceArray - Automated array accessor generation
> that does not require class/accessor user to understand references.
>
> SYNOPSIS
> # This documentation, in some cases, is copied from the documentation
> # for Class::Accessor with minor modifications.
>
> package Foo;
>
> use base qw(Class::Accessor::NoviceArray);
Why use inheritance? Wouldnt exporting methods work better here. Use of
inheritance in this case is problematic if people are afraid of multiple
inheritance and I personally dont want my classes namespace polluted by
all of your helper methods
> Foo->mk_na_accessors(qw(array_el));
> Foo->mk_na_ro_accessors(qw(array_el_ro));
I am never going to write out that method name. What does it do. The
name certainly doesnt tell me. Don't expect anyone to read your
documentation :)
Overall your interface is just tooooo big. What if I want to implement a
push method in my class? I always have to remember all methods defined
in your class. People won't do that.
I have written pretty stupid modules myself, but I feel that you are
going into a pretty well explored area, where you should at least
integrate the existing functionality that's already on CPAN.
->malte
--
srand 108641088; print chr int rand 256 for qw<J A P H>
------------------------------
Date: 7 Mar 2003 10:17:55 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Non-fatal error, "script not found or unable to stat"
Message-Id: <b49rkj$lr6$1@mamenchi.zrz.TU-Berlin.DE>
Mike <csdude@hotmail.com> wrote in comp.lang.perl.misc:
> Hey, guys,
>
> I'm running my scripts on a remote host, and when I checked the error
> log I found that the following error is in there on literally every
> script on my site:
>
> script not found or unable to stat: /www/mydomain/cgi-bin/[object]
^^^^^^^^
Is this the *literal* error message? Or is "[object]" supposed to
mean that this part can vary?
> The scripts are running fine, and when I added the -w switch to
> troubleshoot them all I didn't find anything relevant (I get things
> like "/\n/ should probably be \n" when I split or join by \n, so I
> usually leave the -w out).
This is certainly a warning that ought to be corrected, not suppressed.
The join() (not split()) it comes from will not work right unless you do.
> Unfortunately, though, my error log is
> purged every couple of days, so I have no idea how long this is been
> going on.
>
> What's more, though, is the following non-fatal error shows on all of
> my SSI files:
> File does not exist: /www/mydomain/company/[object]
>
> This particular example does nothing more than use SSI to include a
> separate html file as a header, and I've been doing it that way on
> this host for years!
>
> The only thing I could find in Google was in reference to server
> errors, but my host says that nothing has changed on their end. Am I
> overlooking something?
It certainly looks like a server configuration error, not a Perl
problem.
Anno
------------------------------
Date: 07 Mar 2003 08:45:20 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: Non-fatal error, "script not found or unable to stat"
Message-Id: <u97kbb5vxv.fsf@wcl-l.bham.ac.uk>
csdude@hotmail.com (Mike) writes:
> I'm running my scripts on a remote host, and when I checked the error
> log I found that the following error is in there on literally every
> script on my site:
>
> script not found or unable to stat: /www/mydomain/cgi-bin/[object]
>
> The scripts are running fine, and when I added the -w switch to
> troubleshoot them all I didn't find anything relevant (I get things
> like "/\n/ should probably be \n" when I split or join by \n, so I
> usually leave the -w out). Unfortunately, though, my error log is
> purged every couple of days, so I have no idea how long this is been
> going on.
I suspect this has nothing to do with Perl. Quite probably it has
nothing to do with scripts running on your _server_ at all.
'[object]' is what you see if you stringify a JavaScript object that
doesn't have a string interpretation. The analagous thing in Perl
would be something like 'FOO::BAR=HASH(0x80fa20c)'.
I suspect some buggy JavaScript somewhere (probably running
client-side) that's trying to use an object as a relative URL.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Fri, 07 Mar 2003 03:59:26 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Obfuscated Perl Challenge
Message-Id: <3E685F6E.C3E9A517@earthlink.net>
Can anyone guess/figure out what this code does, without running it?
@1=a..c;$;=4;{push@2,map[$;--,@1[0,2,1]=@1
],2..$;x--$|;print"$1[0]=>$1[2]\n";--$;?@1
=@1[1,0,2]:(($;,@1)=@{pop@2||last});redo}
A large part of the obfuscation is because the flow control is
significantly different from the way this particular algorithm is
normally implemented, so even using Deparse won't significantly help
you.
If you give up on figuring it out, run it. It should be quite
recognizable to most programmers as the output of a basic learning
excercise for ... well, that would be a spoiler :). If you don't
recognize it, send me a private email, and I'll tell you.
Hopefully (for the sake of having fun), even once you understand what
it's producing, it'll be difficult to see *how* it's doing what it's
doing :)
Have fun, and Good Luck!
------------------------------
Date: Fri, 07 Mar 2003 08:20:49 GMT
From: Alan Gutierrez <ajglist@izzy.net>
Subject: POSIX Charcter Classes and tr
Message-Id: <slrnb6gmil.hdh.ajglist@izzy.net>
With perl 5.8.0:
echo 'hello$$*%&(@world' | perl -ne 'chomp; tr/A-Za-z0-9/-/cs; print; print "\n"'
prints: hello-world
echo 'hello$$*%&(@world' | perl -ne 'chomp; tr/[[:alnum:]]/-/cs; print; print "\n"'
prints: -ll-l-
No POSIX character classes with transliteration I take it. True?
--
Alan Gutierrez - ajglist@izzy.net
http://khtml-win32.sourceforge.net/ - KHTML on Windows
------------------------------
Date: Fri, 7 Mar 2003 19:36:28 +1100
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: POSIX Charcter Classes and tr
Message-Id: <slrnb6gmgc.747.mgjv@martien.heliotrope.home>
On Fri, 07 Mar 2003 08:20:49 GMT,
Alan Gutierrez <ajglist@izzy.net> wrote:
>
> No POSIX character classes with transliteration I take it. True?
True.
None of the regexp stuff applies to tr///. What made you think it would?
Martien
--
|
Martien Verbruggen | I used to have a Heisenbergmobile. Every
| time I looked at the speedometer, I got
| lost.
------------------------------
Date: Fri, 07 Mar 2003 02:22:21 -0600
From: tadmc@augustmail.com
Subject: Posting Guidelines for comp.lang.perl.misc ($Revision: 1.4 $)
Message-Id: <8RmdnR3aWN0gy_WjXTWc3Q@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, 07 Mar 2003 05:08:27 GMT
From: "Bill Smith" <wksmith@optonline.net>
Subject: Re: Problem Implementing Sleep() Function
Message-Id: <fPV9a.35361$gf7.7270169@news4.srv.hcvlny.cv.net>
"DannyBoy" <dan4606@hotmail.com> wrote in message
news:6d72f570.0303061058.1e85a021@posting.google.com...
-snip--
> do `$file`;
--snip--
refer perldoc -f do for proper syntax.
There is no problem with sleep.
Bill
------------------------------
Date: 6 Mar 2003 21:46:39 -0800
From: distrex@hotmail.com (distrex)
Subject: Re: Put perl in old page
Message-Id: <d9ea2696.0303062146.73b61817@posting.google.com>
roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson) wrote in message news:<b491rg$9oh$1@canopus.cc.umanitoba.ca>...
> In article <d9ea2696.0303061818.460e8fb0@posting.google.com>,
> distrex <distrex@hotmail.com> wrote:
> :I have just learned some perl and i would like to put it into my site
> :I already have up (it makes random quotes). Is there a way to just
> :call the program from HTML or something simialr.
>
> No, HTML itself does not offer any way to call programs.
>
> You need to talk to your WWW server administrator to find out what
> kinds of dynamic HTML or CGI scripts that they support. Depending on
> what is supported, you -might- be able to embed a line in your HTML
> that signals that the program should be called. [You would probably
> have to rename the files slightly to get the server to recognize
> that it should process them specially.]
Well i run the server off my home comp right now. So i am the admin.
(a newbie one i might add). So would i just have to do the page threw
all perl? couldn't i just
print until_end_of_lines
{all the code for sight + perl code}
until_end_of_lines
or something similar
------------------------------
Date: Fri, 07 Mar 2003 06:38:13 +0100
From: "Janek Schleicher" <bigj@kamelfreund.de>
Subject: Re: question about "new" in a module
Message-Id: <pan.2003.03.07.05.38.13.819554@kamelfreund.de>
Andrew Lee wrote at Fri, 07 Mar 2003 03:27:24 +0000:
> I am getting an error in the following code, I wonder if anyone can
> explain the error and tell me how to avoid it :
>
>
> package DT::AssetManager;
> use 5.006;
> use strict;
> use warnings;
> use DBConf;
> my $conf = DBConf::new("/PATH-TO-CONFIG/myconfig");
>
> # this works in a .pl file
> # more stuff snipped
>
> sub new {
> my $classname = shift;
>
>>>error : Subroutine new redefined at blib/lib/DT/AssetManager.pm line 22.
>
> It seems like I am fully qualifying 'new' for the module DBConf. Why is
> there a name clash?
>
> DBConf starts with :
>
> package DBConf;
> require Exporter;
>
> our @EXPORT = qw/new get_dbh getVars DB_Connect getMaxId getMaxRow/;
^^^
That's why.
The new function is exported from the DBConf module into the namespace of
every module that uses DBConf.
Just remove new from the export list and everything will work fine.
> ... other stuff
> ...
Best Wishes,
Janek
------------------------------
Date: Fri, 07 Mar 2003 10:05:50 +0100
From: "Tore Aursand" <tore@aursand.no>
Subject: Re: question about "new" in a module
Message-Id: <pan.2003.03.07.09.00.43.141913@aursand.no>
On Fri, 07 Mar 2003 06:38:13 +0100, Janek Schleicher wrote:
>> our @EXPORT = qw/new get_dbh getVars DB_Connect getMaxId getMaxRow/;
> ^^^
>
> That's why.
Hmm. Thinking of it; Where did I read that one should _never_ export
method names?
--
Tore Aursand <tore@aursand.no>
------------------------------
Date: 7 Mar 2003 10:42:53 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: question about "new" in a module
Message-Id: <b49t3d$n6m$1@mamenchi.zrz.TU-Berlin.DE>
Tore Aursand <tore@aursand.no> wrote in comp.lang.perl.misc:
> On Fri, 07 Mar 2003 06:38:13 +0100, Janek Schleicher wrote:
> >> our @EXPORT = qw/new get_dbh getVars DB_Connect getMaxId getMaxRow/;
>
> > ^^^
> >
> > That's why.
>
> Hmm. Thinking of it; Where did I read that one should _never_ export
> method names?
Exporting methods is an invitation to use them as non-method subs
and break inheritance. Also, at least for object methods, there
is no need to export them because they are accessed through the
object without explicit class reference.
One of the few cases where this rule may be ignored for reasons of
convenience is when exporting a constructor method into a non-class
package. It *may* be useful to do that, but probably not under
the nondescript name new(). This may be the OPs situation.
Another case might be when a class is so big that you want to
split off part of the definitions. In that case, the split-off
part would be treated as a regular module (not a stand-alone class)
and importing its routines into the receiving class is no problem.
It will rarely make sense to export methods from one class to
another. That is what inheritance is for, and exportation can
only break it.
Anno
------------------------------
Date: Fri, 07 Mar 2003 06:44:56 GMT
From: Alan Gutierrez <ajglist@izzy.net>
Subject: Regular Expression
Message-Id: <slrnb6gguq.h44.ajglist@izzy.net>
Trying to assert that an identifier has a certian form which is:
* starts with alpha.
* followed by alpha, digit or space.
* no consecutive spaces.
Here is what I've got:
echo 'hello world' | perl -ne '/^[\w\d](?:[\w\d]| [\w\d])*$/ && print'
echo 'hello world' | perl -ne '/^[\w\d](?:[\w\d]| [\w\d])*$/ && print'
The first prints hello world, the second doesn't.
It works.
If you all see something obviously wrong, please let me know.
--
Alan Gutierrez - ajglist@izzy.net
http://khtml-win32.sourceforge.net/ - KHTML on Windows
------------------------------
Date: Fri, 07 Mar 2003 07:45:37 GMT
From: Alan Gutierrez <ajglist@izzy.net>
Subject: Re: Regular Expression
Message-Id: <slrnb6gkgh.h6d.ajglist@izzy.net>
In article <slrnb6gguq.h44.ajglist@izzy.net>, Alan Gutierrez wrote:
> Trying to assert that an identifier has a certian form which is:
>
> * starts with alpha.
> * followed by alpha, digit or space.
> * no consecutive spaces.
>
> Here is what I've got:
>
> echo 'hello world' | perl -ne '/^[\w\d](?:[\w\d]| [\w\d])*$/ && print'
> echo 'hello world' | perl -ne '/^[\w\d](?:[\w\d]| [\w\d])*$/ && print'
>
> The first prints hello world, the second doesn't.
>
> It works.
>
> If you all see something obviously wrong, please let me know.
Talking to myself again.
echo '1hello world' | perl -ne '/^\w(?:[\w\d]| [\w\d])*$/ && print'
The above matches.
echo '1hello world' | perl -ne '/^[:alpha:](?:[[:alnum:]]| [[:alnum:]])*$/ && print'
This one doesn't.
--
Alan Gutierrez - ajglist@izzy.net
http://khtml-win32.sourceforge.net/ - KHTML on Windows
------------------------------
Date: Fri, 07 Mar 2003 07:51:12 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Regular Expression
Message-Id: <x765qvty1d.fsf@mail.sysarch.com>
>>>>> "AG" == Alan Gutierrez <ajglist@izzy.net> writes:
AG> In article <slrnb6gguq.h44.ajglist@izzy.net>, Alan Gutierrez wrote:
>> Trying to assert that an identifier has a certian form which is:
>>
>> * starts with alpha.
>> * followed by alpha, digit or space.
>> * no consecutive spaces.
AG> echo '1hello world' | perl -ne '/^\w(?:[\w\d]| [\w\d])*$/ && print'
\w matches \d. [\w\d] is just \w.
AG> The above matches.
AG> echo '1hello world' | perl -ne '/^[:alpha:](?:[[:alnum:]]| [[:alnum:]])*$/ && print'
why the [[ and ]]? the [:alnum:] is a single char and so there is no
need for a char class around it (same as single \w)
AG> This one doesn't.
[:alpha:] doesn't match \d
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
----- Stem and Perl Development, Systems Architecture, Design and Coding ----
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
Damian Conway Perl Classes - January 2003 -- http://www.stemsystems.com/class
------------------------------
Date: Fri, 07 Mar 2003 07:59:00 GMT
From: Alan Gutierrez <ajglist@izzy.net>
Subject: Re: Regular Expression
Message-Id: <slrnb6gl9o.hcb.ajglist@izzy.net>
In article <x765qvty1d.fsf@mail.sysarch.com>, Uri Guttman wrote:
>>>>>> "AG" == Alan Gutierrez <ajglist@izzy.net> writes:
>
> AG> In article <slrnb6gguq.h44.ajglist@izzy.net>, Alan Gutierrez wrote:
> >> Trying to assert that an identifier has a certian form which is:
> >>
> >> * starts with alpha.
> >> * followed by alpha, digit or space.
> >> * no consecutive spaces.
>
> AG> echo '1hello world' | perl -ne '/^\w(?:[\w\d]| [\w\d])*$/ && print'
>
> \w matches \d. [\w\d] is just \w.
>
> AG> The above matches.
>
> AG> echo '1hello world' | perl -ne '/^[:alpha:](?:[[:alnum:]]| [[:alnum:]])*$/ && print'
>
> why the [[ and ]]? the [:alnum:] is a single char and so there is no
> need for a char class around it (same as single \w)
>
> AG> This one doesn't.
>
> [:alpha:] doesn't match \d
Thank you. Here is what looks like a final version:
/^[[:alpha:]](?:[[:alnum:]]|-[[:alnum:]])*$/
--
Alan Gutierrez - ajglist@izzy.net
http://khtml-win32.sourceforge.net/ - KHTML on Windows
------------------------------
Date: 6 Mar 2003 22:18:59 -0800
From: kydongau@yahoo.com.au (kydongau)
Subject: Skip directories and Find
Message-Id: <738c2d89.0303062218.75b171a4@posting.google.com>
Hi,
I want to get the total size of all files under $path except for those
under @exclude directories. I am using Prune but it does not seem
working, it does not skip any directories, my codes attached. I
appreciate if you could point out what I am doing wrong.
Thanks,
Ky
use File::Find;
my $path='/home/kydong';
my @exclude = ("/home/kydong","/home/kydong/junk","/home/kydong/src/tmp");
my $size=0;
find (\&filesize, $path);
print "$size\n";
sub filesize {
my $name=$_;
foreach my $edir (@exclude) {
next if ($edir eq $path);
if (-d $name && ("$File::Find::name" eq "$edir")) {
$File::Find::Prune = 1;
return;
}
}
$size += -s $name if (-f $name);
}
------------------------------
Date: Fri, 07 Mar 2003 04:01:37 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Skip directories and Find
Message-Id: <3E685FF1.4C29605A@earthlink.net>
kydongau wrote:
>
> Hi,
> I want to get the total size of all files under $path except for those
> under @exclude directories. I am using Prune but it does not seem
> working,
[snip]
> $File::Find::Prune = 1;
Reread the documentation. The variable's name is not "Prune".
Here's a hint: You are exactly one bit off from the right name.
--
@1=a..c;$;=4;{push@2,map[$;--,@1[0,2,1]=@1
],2..$;x--$|;print"$1[0]=>$1[2]\n";--$;?@1
=@1[1,0,2]:(($;,@1)=@{pop@2||last});redo}
------------------------------
Date: Fri, 7 Mar 2003 15:53:17 +0530
From: "Kasp" <kasp@epatra.com>
Subject: Unix TAIL program
Message-Id: <b49s14$ts1$1@newsreader.mailgate.org>
Hi,
I am trying to make a simple program i.e. an implementation of "tail"
program that is found in Unix-based systems.
Now one simple way I thought of goes like this:
Read the _entire_ file into an array say @wholeFile.
For displaying the last few lines (default 10), I go elements from (
$#wholeFile -10) and display till end of array.
But there is a performance issue - consider a huge file and I just want to
see the last 10 lines of it, then there is a lot of time spent in loading
the whole file (unnecessarily) into the array. Is there a better solution to
this?
Thanks.
--
Perl is designed to give you several ways to do anything, so
consider picking the most readable one.
-- Larry Wall
------------------------------
Date: Fri, 07 Mar 2003 11:45:46 +0100
From: "Tore Aursand" <tore@aursand.no>
Subject: Re: Unix TAIL program
Message-Id: <pan.2003.03.07.10.45.41.554627@aursand.no>
On Fri, 07 Mar 2003 15:53:17 +0530, Kasp wrote:
> I am trying to make a simple program i.e. an implementation of "tail"
> program that is found in Unix-based systems.
Re-inventing the wheel, aren't we? :) There is already a module named
'File::Tail' which you can find at CPAN;
http://www.cpan.org/
But you probably already knew that, didn't you?
--
Tore Aursand <tore@aursand.no>
------------------------------
Date: 7 Mar 2003 10:59:25 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Unix TAIL program
Message-Id: <b49u2d$n6m$2@mamenchi.zrz.TU-Berlin.DE>
Tore Aursand <tore@aursand.no> wrote in comp.lang.perl.misc:
> On Fri, 07 Mar 2003 15:53:17 +0530, Kasp wrote:
> > I am trying to make a simple program i.e. an implementation of "tail"
> > program that is found in Unix-based systems.
>
> Re-inventing the wheel, aren't we? :) There is already a module named
> 'File::Tail' which you can find at CPAN;
>
> http://www.cpan.org/
>
> But you probably already knew that, didn't you?
Well, the main purpose of File::Tail is to provide the "tail -f"
functionality. I expect it does the fixed-number-of-tail-lines
thing too, but that isn't its reason of being.
File::ReadBackwards looks like a good candidate if all you want
is to split off a number of lines from the end.
To answer the OPs question directly, here is how to find the last
$n lines without ever keeping (much) more than $n lines in memory
(untested):
my @buffer;
while ( <$in> ) {
push @buffer, $_;
shift @buffer if @buffer > $n;
}
print @buffer;
Anno
------------------------------
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 4679
***************************************