[24300] in Perl-Users-Digest
Perl-Users Digest, Issue: 6491 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Apr 30 06:05:50 2004
Date: Fri, 30 Apr 2004 03:05:06 -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, 30 Apr 2004 Volume: 10 Number: 6491
Today's topics:
another thing <webmaster @ infusedlight . net>
Re: Count how many times find and replaced happened <webmaster @ infusedlight . net>
Re: cywin versus activestate on xp <webmaster @ infusedlight . net>
Re: generating time series graphs with perl <mgjv@tradingpost.com.au>
Howto: Search between 2 files (josetg)
Re: Howto: Search between 2 files <spamtrap@dot-app.org>
Re: Howto: Search between 2 files <bernard.el-haginDODGE_THIS@lido-tech.net>
Re: I am so lost... sort and writing a shell script in <uri.guttman@fmr.com>
LWP::UserAgent & threads problem (unreal)
Re: myfile.cgi?image.gif saved as myfile.cgi in mozilla <mystery-reject-please@null.com>
Re: myfile.cgi?image.gif saved as myfile.cgi in mozilla <webmaster @ infusedlight . net>
Re: myfile.cgi?image.gif saved as myfile.cgi in mozilla <mark.clements@kcl.ac.uk>
Re: myfile.cgi?image.gif saved as myfile.cgi in mozilla <spamtrap@dot-app.org>
Re: myfile.cgi?image.gif saved as myfile.cgi in mozilla <flavell@ph.gla.ac.uk>
Re: OSs with Perl installed <lv@aol.com>
Parsing Path Data into Tree Structure (Dale)
Posting Guidelines for comp.lang.perl.misc ($Revision: tadmc@augustmail.com
Re: Remote uploading with hops? <calvine.is.not@starhub.net.sg>
search.pl <webmaster @ infusedlight . net>
Re: search.pl <spamtrap@dot-app.org>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 29 Apr 2004 22:56:32 -0800
From: "Robin" <webmaster @ infusedlight . net>
Subject: another thing
Message-Id: <c6stfj$3dm$3@reader2.nmix.net>
# my code is not meant as an example to newbies
# it is simply there
--
Regards,
-Robin
--
[ webmaster @ infusedlight.net ]
www.infusedlight.net
------------------------------
Date: Thu, 29 Apr 2004 22:55:07 -0800
From: "Robin" <webmaster @ infusedlight . net>
Subject: Re: Count how many times find and replaced happened
Message-Id: <c6stfi$3dm$2@reader2.nmix.net>
"Keith Keller" <kkeller-usenet@wombat.san-francisco.ca.us> wrote in message
news:ku0s6c.mq.ln@goaway.wombat.san-francisco.ca.us...
> -----BEGIN xxx SIGNED MESSAGE-----
> Hash: SHA1
>
> On 2004-04-29, Robin <webmaster@infusedlight> wrote:
> >
> > "Tad McClellan" <tadmc@augustmail.com> wrote in message
> > news:slrnc92qpb.3qo.tadmc@magna.augustmail.com...
> >>
> >> Please choose one posting address and stick to it.
>
> > yeah I did...sorry.
>
> You did? This is the third address you've used in the span of a few
> weeks. Webmaster, indeed--I hope your webmaster skillz are markedly
> better than your skillz "creating dynamic websites with CGI".
well, two of those email addresses are prefixed with "webmaster", but it
doesn't improve my webmaster skills.
-Robin
------------------------------
Date: Thu, 29 Apr 2004 22:53:27 -0800
From: "Robin" <webmaster @ infusedlight . net>
Subject: Re: cywin versus activestate on xp
Message-Id: <c6stfh$3dm$1@reader2.nmix.net>
"usenet_spam_cygwin" <beau@oblios-cap.com> wrote in message
news:Pine.CYG.4.58.0404291259130.1808@beren...
> Howdy. A google search "activestate versus cygwin" didn't do me much
> good, so I'm asking the fine folks at comp.lang.perl.misc: any clear
> reason to use one over the other? My objective, really, is as seamless as
> possible an experience as I work my way through the llama book for the
> first time. Many thanks! (My feelings won't be hurt by backchannel
> responses if you feel it's not sufficiently on topic.)
> --
> beau
cygwin is hard and tedious to download, taking many days if your on a
dial-up connection, there's nothing wrong with perl on win32. Just to tell
you if your on dial-up.
-Robin
------------------------------
Date: 30 Apr 2004 06:00:16 GMT
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: generating time series graphs with perl
Message-Id: <slrnc93qre.2qk.mgjv@verbruggen.comdyn.com.au>
On Thu, 29 Apr 2004 18:28:43 -0500,
Po Boy <a5ufv8u02@sneakemail.com> wrote:
>
> On Thu, 29 Apr 2004 23:16:30 +0000, Martien Verbruggen wrote:
>>
>> That sort of graph isn't possible with GD::Graph. I don't know off
>> hand of another package for Perl that does support that sort of thing.
>
> Yuk! well, thanks for your help. Maybe I'll see if I can get gnuplot or
> octave or something to do it.
Note that the chart you use can also be seen as a two-dimensional
straight projection of a three-dimensional chart with the time on the
Z axis (which points straight away from the view plane).
If you get gnuplot to plot a three-dimensional chart, switch off
display of the time axis and labels, and rotate it appropriately, you
might just have what you're looking for.
Any other package that does three-d charts and that lets you do a
straight projection and switch off axes probably will do as well.
Regards,
Martien
--
|
Martien Verbruggen | Think of the average person. Approximately
Trading Post Australia | half of the people out there are dumber.
|
------------------------------
Date: 30 Apr 2004 02:03:52 -0700
From: josetg@yahoo.com (josetg)
Subject: Howto: Search between 2 files
Message-Id: <158a491d.0404300103.643c25f4@posting.google.com>
Hi,
Am a absolute newbie.
I have a list of keywords in one file, and the text to search for in 2nd file.
I need to find lines in the 2nd file which match keywords in the 1st file.
The output should be sorted by line # in 2nd file.
Many thanks
Jose
------------------------------
Date: Fri, 30 Apr 2004 05:13:15 -0400
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: Howto: Search between 2 files
Message-Id: <3Z6dnVwx2f0shQ_dRVn-tw@adelphia.com>
josetg wrote:
> Am a absolute newbie.
Welcome aboard. Here are some links to help you get started:
<http://learn.perl.org>
<http://perldoc.com/perl5.8.0/pod/perlfaq.html>
Lots of documentation is installed on your machine along with Perl itself.
To read it, use the 'perldoc' command-line tool. It can show you a specific
documentation page, module doc, function description, or find a keyword in
the list of FAQs.
Some examples:
Read the "perl" page: "perldoc perl"
Read about the "strict" module: "perldoc strict"
Read about the "grep" function: "perldoc -f grep"
Look for the keyword "strict": "perldoc -q strict"
> I have a list of keywords in one file, and the text to search for in 2nd
> file. I need to find lines in the 2nd file which match keywords in the 1st
> file.
>
> The output should be sorted by line # in 2nd file.
What have you tried so far?
sherm--
--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org
------------------------------
Date: Fri, 30 Apr 2004 11:11:16 +0200
From: "Bernard El-Hagin" <bernard.el-haginDODGE_THIS@lido-tech.net>
Subject: Re: Howto: Search between 2 files
Message-Id: <Xns94DB71D66BBD8elhber1lidotechnet@62.89.127.66>
josetg@yahoo.com (josetg) wrote:
> Hi,
>
> Am a absolute newbie.
>
> I have a list of keywords in one file, and the text to search for
> in 2nd file. I need to find lines in the 2nd file which match
> keywords in the 1st file.
>
> The output should be sorted by line # in 2nd file.
What have you tried so far?
--
Cheers,
Bernard
------------------------------
Date: 29 Apr 2004 18:10:40 -0400
From: Uri Guttman <uri.guttman@fmr.com>
Subject: Re: I am so lost... sort and writing a shell script in Perl
Message-Id: <siscisfi5tb3.fsf@configsvr.fmr.com>
>>>>> "T" == Tsu-na-mi <tsunami@zedxinc.com> writes:
T> Since all the replies I see seem overcomplex, if efficient, I will
T> provide my suggestion. Personally, I value readibility and ease of
T> maintainance over efficiency, so this should be easy for you to
T> follow. I'll start by saying the file format is in incredibly bad
T> form, but I'll show you how I would deal with it.
and i value correctness over readability.
no strict
no warnings
you get no cookie.
T> open(IN,$filename);
always test the result of open.
T> while ($in = <IN>) {
T> $pop_density{$county} = sprintf("%.1f",$pop/$land);
T> $water_pct{$county} = sprintf(%.2f",$water/$land);
ok, you have two hashes keys by county with number values.
T> # sort in ascending order
T> foreach $county (sort {$a<=>$b} values %pop_density) {
T> print "$county County : $pop_density{$county}\n";
hmmm, what does values %hash return? its values, which are
numbers. great. so you loop over them and print out the numbers followed
by the word 'County' and then the pop_density of a county named for a
number.
nice work!
very readable too!
at least mark your post with <untested and broken code>
T> It would be better if you used a printf() statement when you printed
T> them out so you can have nuce columns, etc.
it would have been better if your code was tested and correct.
uri
------------------------------
Date: 30 Apr 2004 02:01:29 -0700
From: unreal_v13@yahoo.com (unreal)
Subject: LWP::UserAgent & threads problem
Message-Id: <a16c9723.0404300101.47d4c47e@posting.google.com>
Hi,
I have problem using LWP::UserAgent with threads.
In function get_google_page() I create object from class
LWP::UserAgent and get page 'http://google.com'. After this create 3
threads and 1 object from class LWP:UserAgent in every thread. But
there is error 'Segmentation fault' before creating threads. All
objects are declared as my and I don't know why there is 'Segmentation
fault'.
If I don't call function get_google_page() (i.e. don't create object
before creating threads) there aren't problem.
Please look at code below. Can someone help me?
use threads;
use threads::shared;
use CGI qw/:standard/;
use CGI::Carp qw(fatalsToBrowser);
use LWP::UserAgent;
get_google_page(); # if this row is in comment there isn't problem
for ( my $i = 0; $i < 3; $i++ )
{
$threads[$i] = threads->create("follow_URL", $i);
}
for ( my $i = 0; $i < 3; $i++ )
{
$threads[$i]->join();
}
sub follow_URL
{
my $TID = shift;
print "\n TID: $TID started";
my $user_agent = LWP::UserAgent->new;
$user_agent->protocols_allowed( [ 'http', 'https'] );
$user_agent->agent("Mozilla/8.0");
$user_agent->timeout( 30 );
print "\n TID: $TID ended";
}
sub get_google_page
{
my $ua = LWP::UserAgent->new;
$ua->protocols_allowed( [ 'http', 'https'] );
$ua->agent("Mozilla/8.0");
$ua->timeout( 30 );
my $request = HTTP::Request->new(GET => 'http://google.com');
$request->header('Accept' => 'text/html');
$res = $ua->request($request);
if ( !$res->is_success )
{
print "Unable to get google page!\n";
return 0;
}
print "Successfully get google page!\n";
}
------------------------------
Date: 30 Apr 2004 18:30:37 +1200
From: Peter Payne <mystery-reject-please@null.com>
Subject: Re: myfile.cgi?image.gif saved as myfile.cgi in mozilla?
Message-Id: <4091f28d@clear.net.nz>
I tried solving this problem a while ago and had trouble. Eventually
I used google to find the answer.
What does this mean? You're silly enough not to find out the answer
for yourself. Poor you. But because I'm a show off I'll actually
give you the answer. But it's not to your credit that you asked.
# By specifying Content-Length you automatically tell
# the browser that what follows is a binary file
#
# $s_length is the length of the file in bytes
# $s_fname is the name of the file that will be prompted for saving
print( "Content-Length: $s_length\n" );
print( "Content-Disposition: attachment; filename=\"$s_fname\"\n" );
print( "\n" );
my $s_buffer = undef;
while ( read( EXECGZIP, $s_buffer, 1024 ) )
{
print( $s_buffer );
}
Do everyone a favour and google next time.
Peter
joe <jcharth@hotmail.com> wrote:
> Hi i have a pl file that prints
> print "Content-type: application/octet-stream\n\n";
> and then the output of a file
> in ie it works fine the download.cgi?myzip.zip saves the file as myzip.zip
> in mozilla however i get the wrong file name i get download.cgi
> i tried doing http://www.domain.com/cgi-bin/download.cgi/myzip.zip and i
> get the correct name but the contents dont look right any suggestions?
> thanks.
------------------------------
Date: Fri, 30 Apr 2004 00:33:51 -0800
From: "Robin" <webmaster @ infusedlight . net>
Subject: Re: myfile.cgi?image.gif saved as myfile.cgi in mozilla?
Message-Id: <c6t325$6ie$1@reader2.nmix.net>
"joe" <jcharth@hotmail.com> wrote in message
news:Xns94DAC811B1E5Fjosephthecianet@207.69.154.202...
> Hi i have a pl file that prints
> print "Content-type: application/octet-stream\n\n";
> and then the output of a file
> in ie it works fine the download.cgi?myzip.zip saves the file as myzip.zip
> in mozilla however i get the wrong file name i get download.cgi
> i tried doing http://www.domain.com/cgi-bin/download.cgi/myzip.zip and i
> get the correct name but the contents dont look right any suggestions?
> thanks.
check your query string parse code first.
-Robin
------------------------------
Date: Fri, 30 Apr 2004 09:43:41 +0100
From: Mark Clements <mark.clements@kcl.ac.uk>
Subject: Re: myfile.cgi?image.gif saved as myfile.cgi in mozilla?
Message-Id: <409211b9$1@news.kcl.ac.uk>
Robin wrote:
> "joe" <jcharth@hotmail.com> wrote in message
>>Hi i have a pl file that prints
>>in mozilla however i get the wrong file name i get download.cgi
>>i tried doing http://www.domain.com/cgi-bin/download.cgi/myzip.zip and i
> check your query string parse code first.
What query string parse code? The only application doing any query
parsing for the purposes of this exercise is mozilla, and I doubt that
you are suggesting he check the source code of that.
Mark
------------------------------
Date: Fri, 30 Apr 2004 04:47:11 -0400
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: myfile.cgi?image.gif saved as myfile.cgi in mozilla?
Message-Id: <D8mdnfAmJqQNjw_dRVn-jw@adelphia.com>
Robin wrote:
> "joe" <jcharth@hotmail.com> wrote in message
> news:Xns94DAC811B1E5Fjosephthecianet@207.69.154.202...
>> Hi i have a pl file that prints
>> print "Content-type: application/octet-stream\n\n";
>> and then the output of a file
>> in ie it works fine the download.cgi?myzip.zip saves the file as
>> myzip.zip in mozilla however i get the wrong file name i get download.cgi
>> i tried doing http://www.domain.com/cgi-bin/download.cgi/myzip.zip and i
>> get the correct name but the contents dont look right any suggestions?
>
> check your query string parse code first.
Robin, were you born stupid or do you have to work at it? To begin with, no
one in their right mind is going to be using their own parsing code.
Second, query string parsing doesn't have *one* *damn* *thing* to do with
this problem.
Joe, in theory what you need is to return a Content-Disposition header as
part of your response. It appears to have some problems in practice though.
See this page for discussion:
<http://www.hanselman.com/blog/PermaLink.aspx?guid=360>
And these are the relevant standards docs:
<http://www.faqs.org/rfcs/rfc1806.html>
<http://www.faqs.org/rfcs/rfc2183.html>
sherm--
--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org
------------------------------
Date: Fri, 30 Apr 2004 10:04:50 +0100
From: "Alan J. Flavell" <flavell@ph.gla.ac.uk>
Subject: Re: myfile.cgi?image.gif saved as myfile.cgi in mozilla?
Message-Id: <Pine.LNX.4.53.0404301004030.29336@ppepc56.ph.gla.ac.uk>
On Fri, 30 Apr 2004, Sherm Pendley wrote:
> Robin wrote:
>
> > check your query string parse code first.
>
> Robin, were you born stupid or do you have to work at it?
Please resist the temptation to feed the trolls.
------------------------------
Date: Thu, 29 Apr 2004 23:09:11 -0500
From: l v <lv@aol.com>
Subject: Re: OSs with Perl installed
Message-Id: <4091d18d$1_1@corp.newsgroups.com>
Charlton Wilbur wrote:
>>>>>>"JC" == Jim Cochrane <jtc@shell.dimensional.com> writes:
>
>
> JC> Unfortunately, since MS does not include Perl as a standard
> JC> component, it's also true that most computers these days do
> JC> not have Perl installed. (I can only think of advantages to
> JC> MS including Perl with their OS - can't think of any
> JC> disadvantages, so I'm can't understand why they don't do it.
> JC> Am I missing something?)
>
> If Microsoft included Perl, they couldn't charge people for Visual
> Basic, and people who mastered Perl on the Microsoft platform could
> easily pack up and move to another platform without a lot of trouble.
>
> So they can't charge for it, it cuts into sales of one of their
> products, and it doesn't lock people into their platform.
>
> Charlton
>
>
I just did a quick search on MS's web site. Looks like they want you to
install AS Perl to sway you away from Unix. Fat chance on that
Len
-----= 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: 30 Apr 2004 00:23:02 -0700
From: desau@aisc.ac.cy (Dale)
Subject: Parsing Path Data into Tree Structure
Message-Id: <f748e986.0404292323.60491f72@posting.google.com>
I'm creating a simple web-based image management tool and am looking
for a way of creating a tree structure to display folders and titles
of images contained in those folders. What I am trying to do is take a
very plain text string describing a path and parse that into a tree to
display in html.
My incoming data via DBI looks like this
/folder 1/image1.jpg
/folder 1/subfolder 1/image2.jpg
/folder 1/subfolder 1/subsub folder 1/image3.jpg
/folder 1/image4.jpg
/folder 2/image5.jpg
/folder 1/subfolder 2/image6.jpg
etc...
and I want to output sort of like
folder 1
-> subfolder 1
-> -> subsubfolder 1
-> -> -> image3.jpg
-> -> image2.jpg
-> subfolder 2
-> -> image6.jpg
-> image1.jpg
-> image4.jpg
folder 2
-> image5.jpg
though with lots of pretty icons and collapsing row structures (which
I won't bore you with since its jscript and not perl)
So my questions:
1. Is there a module available anywhere that already does this?
2. If not, I can work with one of the Tree:: modules and need ideas on
how to parse my paths into the required structure. (ie how to extract
the parent/child node relationships correctly)
3. And if there is another better way of accomplishing this whole task
I would love to hear about it.
* and for those list purists who are wondering where the perl is in
this question, my whole app is perl, so am looking for perl answers
using regexes, splits, and arrays or hashes, etc.
Many thanks in advance for any guidance
DRE
------------------------------
Date: Fri, 30 Apr 2004 02:22:25 -0500
From: tadmc@augustmail.com
Subject: Posting Guidelines for comp.lang.perl.misc ($Revision: 1.5 $)
Message-Id: <-cKdnfjnmLssYwzd4p2dnA@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.5 $)
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://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
"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 <tadmc@augustmail.com> and many others on the
comp.lang.perl.misc newsgroup.
------------------------------
Date: Fri, 30 Apr 2004 14:11:49 +0800
From: "Calvine Chew" <calvine.is.not@starhub.net.sg>
Subject: Re: Remote uploading with hops?
Message-Id: <c6sq2a$mpe$1@reader01.singnet.com.sg>
Any help?
"Calvine Chew" <calvine.is.not@starhub.net.sg> wrote in message
news:c6o73h$tds$1@reader01.singnet.com.sg...
> I've been trying to write a script that will allow me to simultaneously
> update several websites in a company LAN environment, across multiple
> divisions, just by updating an initial one.
>
> Basically:
>
> 1) I upload an update (say a new dataset in a zip file) to website A.
> 2) Script in website A saves it to disk, unpacks it nicely, then sends the
> zip off to website B before deleting it from the disk,
> 3) Website B does the same and sends it off to website C.
> 4) This process is repeated until it reaches an end node.
>
> Obviously the scripts on each site have been pre-programmed to hop to the
> next server, so the hopping logic is done. I basically use LWP to post
from
> HTML form to HTML form until the last form which just saves the file and
> unpacks it.
>
> This works beautifully but because I use LWP, it only works for perl
> installations where the LWP/HTML/HTTP modules are make'd and install'd
> properly (pls correct me if I'm wrong on that). I can't seem to get it to
> work on servers where I did not make and install the required modules.
Carp
> shows that it can't find loadable module for HTML::Parser in the available
> library paths even tho I've already used "use lib". In fact, it seems the
> offenders are HTML::Parser and HTML::Entities.
>
> I'm suspecting this is because LWP/Parser/etc (I think Entities.pm too)
uses
> XS and other files and binaries besides the .pm files. So does anyone know
> how I should go about doing a proper local non-make/install installation
of
> LWP/HTML/HTTP on the problematic server(s) or is there another way to look
> at this problem/issue (perhaps by directly interfacing with each perl
script
> without using LWP?? But not sure how to do that... socket/port connections
> are not available to me)?
>
> Any comments or suggestions are appreciated!
>
>
------------------------------
Date: Thu, 29 Apr 2004 22:50:38 -0800
From: "Robin" <webmaster @ infusedlight . net>
Subject: search.pl
Message-Id: <c6st0v$3de$1@reader2.nmix.net>
I have some questions on this , why isn't sub parse and sub search not
performing the way I want them too, they are supposed to go through all of
the directories and then open the files in them and then if the contents of
the file match param ('query') print the results. It's been driving me
crazy, if someone could point me in the right direction it would be great.
This is very incomplete and doesn't use all of it's data yet, so I would
appreciate comments that don't point that out, for example, what if it opens
binary files? I dunno..thanks in advance, by the way, I know that it's
somewhere in the methods search or parse, but other than that I don't have
the foggiest.
-Robin
#!/usr/bin/perl
use strict;
use warnings;
use Fcntl qw (:flock);
use CGI qw(:all);
$CGI::POST_MAX=1024 * 100; # max 100K posts
$CGI::DISABLE_UPLOADS = 1; # no uploads
$" = '';
$ENV{'PATH'} = '/bin:/usr/bin:/usr/local/bin';
my @directories = ("./", "../", "../design"); #change this to the
directories you want to have searched.
my $action = url_param ('action');
my $rootfile = url (relative=>1);
my $headerfile = "searchheader.txt";
my $footerfile = "searchfooter.txt";
my $errorfile = "ERR.txt";
my @head = getheader ($headerfile);
my @foot = getfooter ($footerfile);
my $date = getdate ();
my @errors;
if ($action eq "search")
{
search ();
}
else
{
newsearch ();
}
sub search
{
print header;
print (@head);
print <<END;
<p><strong><em>Infused Search</em></strong>
<br>
<br>
Search Results:
</p>
END
#code for parsing results
foreach my $dir (@directories)
{
opendir (DIR, $dir);
my @files_from_dir = readdir (DIR);
closedir (DIR);
foreach my $file (@files_from_dir)
{
if (! -d $file)
{
parse ($file, $dir);
}
}
}
print <<END;
<hr size="1">
</body>
</html>
END
}
sub parse
{
my ($filetoparse, $dirtoparse) = @_;
my @results;
open (FILE, $filetoparse) or push (@errors, "A file open operation
failed.");
flock (FILE, LOCK_SH) or push (@errors, "A file lock operation
failed.");
my @filecontents = <FILE>;
close (FILE);
chomp (@filecontents);
my $result;
my $filecontents = join ('', @filecontents);
if (param ('query') =~ /$filecontents/m and param ('query'))
{
$result = $filetoparse;
print "<a href=\"$dirtoparse" . "$filetoparse\">$result</a><br>";
}
}
sub newsearch
{
print header;
print (@head);
print <<END;
<strong><em>Infused Search</em></strong>
<br>
<br>
<hr size="1">
<form name="form1" method="post" action="search.pl?action=search">
<input type="text" name="query">
<input type="submit" name="Submit" value="Submit">
</form>
<hr size="1">
END
print (@foot);
}
sub checkerrors
{
if (@errors)
{
print header;
print "<html><body><center>";
print "There were errors while trying to execute Infused Search. They
are listed as follows.<br><br>\n";
foreach my $error (@errors)
{
print ($error, "<br>\n");
}
my $errflag = 0;
if (! open (ERRORF, ">>$errorfile") and flock (ERRORF, LOCK_EX))
{
print "There was an error logging the errors: file cannot be locked or
opened.<br>";
$errflag = 1;
}
else
{
print ERRORF ("Current date: $date", "\n");
foreach my $error2 (@errors)
{
print ERRORF $error2, "\n";
}
}
close (ERRORF);
if (! $errflag)
{
print "<br>", "Errors have been logged in $errorfile.";
}
print "</body></html>";
exit (0);
}
else
{
return;
}
}
sub getheader
{
my $header_sub = shift;
my (@headertoret);
if (-e $header_sub)
{
open (HEADERF, $header_sub);
flock (HEADERF, LOCK_SH);
@headertoret = <HEADERF>;
close (HEADERF);
}
else
{
open (HEADERF, ">$header_sub");
flock (HEADERF, LOCK_EX);
@headertoret = <<END;
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
body,td,th {
color: #FFA4A4;
}
body {
background-color: #000000;
}
a:link {
color: #66FFFF;
}
a:visited {
color: #66FFFF;
}
a:hover {
color: #FF9933;
}
a:active {
color: #66FFFF;
}
-->
</style></head>
<body>
END
print HEADERF @headertoret;
close (HEADERF);
}
return (@headertoret);
}
sub getfooter
{
my $footer_sub = shift;
my (@footertoret);
if (-e $footer_sub)
{
open (HEADERF, $footer_sub);
flock (HEADERF, LOCK_SH);
@footertoret = <HEADERF>;
close (HEADERF);
}
else
{
open (HEADERF, ">$footer_sub");
flock (HEADERF, LOCK_EX);
@footertoret = <<END;
</body></html>
END
print HEADERF @footertoret;
close (HEADERF);
}
return (@footertoret);
}
sub getdate
{
my ($day, $mon, $year)=(localtime)[3,4,5];
$mon++;
$year +=1900;
my $date = $mon . "/" . $day . "/" . $year;
return $date;
}
------------------------------
Date: Fri, 30 Apr 2004 03:13:12 -0400
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: search.pl
Message-Id: <Ad6dnQgBHIYXYQzdRVn-jA@adelphia.com>
Robin wrote:
> I have some questions on this , why isn't sub parse and sub search not
> performing the way I want them too, they are supposed to go through all of
> the directories and then open the files in them and then if the contents
> of the file match param ('query') print the results. It's been driving me
> crazy, if someone could point me in the right direction it would be great.
Your script passes the directory to parse(), but it doesn't look like
parse() is using it. So any file that isn't in the current directory ('./')
won't get parsed.
> open (FILE, $filetoparse) or push (@errors, "A file open operation
> failed.");
You should be using more helpful error messages. The above tells you nothing
more than that a file failed to open - it would be better if it also told
you what file and why. Including the file name and $! would make this bug
easier to find.
sherm--
--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org
------------------------------
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 V10 Issue 6491
***************************************