[29264] in Perl-Users-Digest
Perl-Users Digest, Issue: 508 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jun 12 06:10:10 2007
Date: Tue, 12 Jun 2007 03:09:07 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Tue, 12 Jun 2007 Volume: 11 Number: 508
Today's topics:
Any cross-platform function to obtain the machine name? <ilias@lazaridis.com>
Re: Does anybody know why mx1.hotmail.com doesn't respo (Randal L. Schwartz)
Find replace : Regular expression <mailursubbu@gmail.com>
Re: Find replace : Regular expression <mailursubbu@gmail.com>
Re: Find replace : Regular expression <noreply@gunnar.cc>
Re: Find replace : Regular expression <skye.shaw@gmail.com>
Re: How can I use the string variable expansion for OO <ilias@lazaridis.com>
Re: lookahead bug (at least in 5.8.4) <hjp-usenet2@hjp.at>
new CPAN modules on Tue Jun 12 2007 (Randal Schwartz)
perl vs C for CGI saran.jegan@gmail.com
Re: perl vs C for CGI <scobloke2@infotop.co.uk>
Posting Guidelines for comp.lang.perl.misc ($Revision: tadmc@seesig.invalid
Re: Recovering from system call errors <ced@blv-sam-01.ca.boeing.com>
Re: The Concepts and Confusions of Prefix, Infix, Postf <tburdick@gmail.com>
Re: The Concepts and Confusions of Prefix, Infix, Postf <jo@durchholz.org>
Re: Useless use of array element in void context <mstep@podiuminternational.org>
Re: Useless use of array element in void context <joe@inwap.com>
Re: Useless use of array element in void context <mstep@podiuminternational.org>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 12 Jun 2007 10:08:43 -0000
From: Ilias Lazaridis <ilias@lazaridis.com>
Subject: Any cross-platform function to obtain the machine name?
Message-Id: <1181642923.986502.314220@n15g2000prd.googlegroups.com>
looking for something like
use system;
print system->machineName();
this should work across platforms.
I was not able to locate something.
.
--
http://dev.lazaridis.com/lang/wiki/Perl
------------------------------
Date: Tue, 12 Jun 2007 00:07:15 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Does anybody know why mx1.hotmail.com doesn't response correctly? Thanks
Message-Id: <86r6oh4png.fsf@blue.stonehenge.com>
>>>>> "mike" == mike <needpassion@gmail.com> writes:
mike> Actually, I just found that hotmail.com sucks. Once I append "\r\n" to
mike> the end of the string, then everything worked fine.
No, that means you "suck" as a programmer. The SMTP protocol officially
requires \cM\cJ.
This is why I said you shouldn't be writing this code from scratch!
Sigh. Kids.
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
--
Posted via a free Usenet account from http://www.teranews.com
------------------------------
Date: Mon, 11 Jun 2007 22:41:26 -0700
From: Subra <mailursubbu@gmail.com>
Subject: Find replace : Regular expression
Message-Id: <1181626886.733787.47350@j4g2000prf.googlegroups.com>
Hi,
I have to replace the strings "LINUX", "__linux__", "linux" with
"__linux". Please help me to correct the below script.
My input file is of type below
#ifdef LINUX
DO SOME THING
#end if
#ifdef __linux
DO SOME THING
#endif
#ifdef linux
DO SOME THING
#endif
#ifdef __linux__
DO SOME THING
#endif
My o/p file should be
#ifdef __linux
DO SOME THING
#end if
#ifdef __linux
DO SOME THING
#endif
#ifdef __linux
DO SOME THING
#endif
#ifdef __linux
DO SOME THING
#endif
My script (Which needs correction)
#!/tools/opt/bin/perl
$fileCount = 0;
while($fileCount <= @ARGV-1)
{
open(FileHandle,$ARGV[$fileCount]) || die ("File not present
$ARGV[$fileCount]");
open(OpFile,">OpFile.$ARGV[$fileCount]") || die ("OpFile not
present");
while($line=<FileHandle>)
{
#$line=~s/(^#.*)LINUX(.*)/$1__linux$2/g;
$line=~s/(^#.*)linux(.*)/$1__linux$2/g;
#$line=~s/(^#.*)__linux__(.*)/$1__linux$2/g;
print OpFile $line;
}
close(FileHandle);
$fileCount++;
}
------------------------------
Date: Mon, 11 Jun 2007 22:59:57 -0700
From: Subra <mailursubbu@gmail.com>
Subject: Re: Find replace : Regular expression
Message-Id: <1181627997.808263.221650@i38g2000prf.googlegroups.com>
I think the below script works
$fileCount = 0;
while($fileCount <= @ARGV-1)
{
open(FileHandle,$ARGV[$fileCount]) || die ("File not present
$ARGV[$fileCount]");
open(OpFile,">OpFile.$ARGV[$fileCount]") || die ("OpFile not
present");
while($line=<FileHandle>)
{
$line=~s/(^#.*)__linux__(.*)/$1__linux$2/g;
$line=~s/(^#.*)LINUX(.*)/$1__linux$2/g;
$line=~s/(^#.*)[\s]+linux(.*)/$1 __linux $2/g;
print OpFile $line;
}
close(FileHandle);
$fileCount++;
}
------------------------------
Date: Tue, 12 Jun 2007 08:22:26 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Find replace : Regular expression
Message-Id: <5d6si9F309l86U1@mid.individual.net>
Subra wrote:
>
> $line=~s/(^#.*)__linux__(.*)/$1__linux$2/g;
> $line=~s/(^#.*)LINUX(.*)/$1__linux$2/g;
> $line=~s/(^#.*)[\s]+linux(.*)/$1 __linux $2/g;
That could possibly be written:
$line =~ s/(^#.*?)(?:__)?linux(?:__)?/$1__linux/gi;
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Tue, 12 Jun 2007 06:41:33 -0000
From: "Skye Shaw!@#$" <skye.shaw@gmail.com>
Subject: Re: Find replace : Regular expression
Message-Id: <1181630493.164068.302400@g37g2000prf.googlegroups.com>
On Jun 11, 10:41 pm, Subra <mailursu...@gmail.com> wrote:
> Hi,
>
> I have to replace the strings "LINUX", "__linux__", "linux" with
> "__linux". Please help me to correct the below script.
Maybe try this:
[sshaw@localhost ruby]$ perl -i.og -pe'/^#ifdef/ && s/(?:__)?
linux(?:__)?/__linux__/i' file1 file2
file1, file2 will contain the changes. The original files will be save
with a .og extension
I say /^#ifdef/ just in case you are really using `perl -P` on your
source files, <:^|
On another note, has anyone ever used the preprocessor with their perl
programs?
------------------------------
Date: Tue, 12 Jun 2007 10:03:30 -0000
From: Ilias Lazaridis <ilias@lazaridis.com>
Subject: Re: How can I use the string variable expansion for OO "$self->attribute"
Message-Id: <1181642610.731781.133160@g37g2000prf.googlegroups.com>
On Jun 9, 3:52 pm, "Dr.Ruud" <rvtol+n...@isolution.nl> wrote:
> Ilias Lazaridis schreef:
>
> > return "$self->label: $self->val($attrib)";
> > is ther ANY way of achieving this, whilst using ONLY the string?
>
> Just play with it:
[...] examples.
I really meant to process this string.
As asked in my other reply:
is there any stand-alone function available (something like
"stringeval"), which would process the string correctly?
If yes (or if I write my own), is there a way to override the default
string-processing behaviour of perl on a per-package basis?
.
--
http://dev.lazaridis.com/lang/ticket/13
------------------------------
Date: Tue, 12 Jun 2007 08:01:58 +0200
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: lookahead bug (at least in 5.8.4)
Message-Id: <slrnf6sdmm.gqa.hjp-usenet2@zeno.hjp.at>
On 2007-06-11 17:56, use63net@yahoo.com <use63net@yahoo.com> wrote:
> Nope, not my expectations. It's how I took it worked
What you "take how it works" are your expectations, no?
> from the Perl Cookbook - near the bottom of page 212:
> -----------------
> True if both /ALPHA/ and /BETA/ match, but may overlap ...
So far it's correct
> like /ALPHA/ && /BETA/"
But this is at least ambiguous. What it meant is that both match at the
same position.
> /^(?=.*ALPHA)BETA/s
> ----------------
>
> # I'd remove the "^", but it still doesn't match anything like
> "ALPHABETA"
>
There is no position in "ALPHABETA" where both /.*ALPHA/ and /BETA/ match:
At position 0, /.*ALPHA/ matches, but /BETA/ doesn't.
At position 5, /BETA/ matches, but /.*ALPHA/ doesn't.
At all other positions, neither /.*ALPHA/ or /BETA/ match.
OTOH, in the string "BETAALPHA",
At position 0, /.*ALPHA/ matches "BETAALPHA", and /BETA/ matches BETA.
At position 1, /.*ALPHA/ matches "ETAALPHA", but /BETA/ doesn't match.
At position 2, /.*ALPHA/ matches "TAALPHA", but /BETA/ doesn't match.
At position 3, /.*ALPHA/ matches "AALPHA", but /BETA/ doesn't match.
At position 4, /.*ALPHA/ matches "ALPHA", but /BETA/ doesn't match.
At all other positions, neither /.*ALPHA/ or /BETA/ match.
(of course, since we already had a match at position 0, the whole
pattern matches and the other positions aren't tried)
hp
--
_ | Peter J. Holzer | I know I'd be respectful of a pirate
|_|_) | Sysadmin WSR | with an emu on his shoulder.
| | | hjp@hjp.at |
__/ | http://www.hjp.at/ | -- Sam in "Freefall"
------------------------------
Date: Tue, 12 Jun 2007 04:42:13 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Tue Jun 12 2007
Message-Id: <JJIAED.3qK@zorch.sf-bay.org>
The following modules have recently been added to or updated in the
Comprehensive Perl Archive Network (CPAN). You can install them using the
instructions in the 'perlmodinstall' page included with your Perl
distribution.
Bio-DOOP-DOOP-0.24
http://search.cpan.org/~tibi/Bio-DOOP-DOOP-0.24/
DOOP API main module
----
Bio-ECell-0.02
http://search.cpan.org/~gaou/Bio-ECell-0.02/
Perl interface for E-Cell Simulation Environment.
----
Bundle-Dependencies-Catalyst-0.05
http://search.cpan.org/~ski/Bundle-Dependencies-Catalyst-0.05/
installs non-Catalyst prereqs
----
Catalyst-Model-CacheFunky-Loader-0.01
http://search.cpan.org/~tomyhero/Catalyst-Model-CacheFunky-Loader-0.01/
Load Cache::Funky Modules.
----
Class-Component-0.05
http://search.cpan.org/~yappo/Class-Component-0.05/
pluggable component framework
----
Config-Basic-1.84
http://search.cpan.org/~fdulau/Config-Basic-1.84/
----
DBIx-Simple-UTF8Columns-0.02
http://search.cpan.org/~banb/DBIx-Simple-UTF8Columns-0.02/
Force UTF-8 flag for DBIx::Simple data
----
DBIx-SimplePerl-1.8
http://search.cpan.org/~landman/DBIx-SimplePerl-1.8/
Perlish access to DBI
----
Devel-PDB-0.04
http://search.cpan.org/~ivanwong/Devel-PDB-0.04/
A simple Curses-based Perl Debugger
----
EasyTool-1.0.7
http://search.cpan.org/~foolfish/EasyTool-1.0.7/
The Library of Perl Functions in Common Usage
----
Finance-Bank-Smile-0.03
http://search.cpan.org/~rpanman/Finance-Bank-Smile-0.03/
Check your Smile bank accounts from Perl
----
Form-Processor-0.08
http://search.cpan.org/~hank/Form-Processor-0.08/
validate and process form data
----
Form-Processor-Model-CDBI-0.04
http://search.cpan.org/~hank/Form-Processor-Model-CDBI-0.04/
model class for Form::Processor based on Class::DBI
----
GD-Chart-Radial-0.02
http://search.cpan.org/~barbie/GD-Chart-Radial-0.02/
plot and output Radial or Radar charts using the GD library.
----
GD-Chart-Radial-0.03
http://search.cpan.org/~barbie/GD-Chart-Radial-0.03/
plot and output Radial or Radar charts using the GD library.
----
Geo-Point-0.06
http://search.cpan.org/~markov/Geo-Point-0.06/
a point on the globe
----
Graph-Convert-0.05
http://search.cpan.org/~tels/Graph-Convert-0.05/
Convert between graph formats: Graph and Graph::Easy
----
HTML-ListScraper-0.04
http://search.cpan.org/~vbar/HTML-ListScraper-0.04/
generic web page scraping support
----
HTML-ListScraper-0.05
http://search.cpan.org/~vbar/HTML-ListScraper-0.05/
generic web page scraping support
----
HTML-Selector-XPath-Simple-v0.0.1
http://search.cpan.org/~takeru/HTML-Selector-XPath-Simple-v0.0.1/
Simple CSS Selector to XPath compiler
----
HTML-Template-Compiled-0.86
http://search.cpan.org/~tinita/HTML-Template-Compiled-0.86/
Template System Compiles HTML::Template files to Perl code
----
Iterator-Simple-0.01
http://search.cpan.org/~rintaro/Iterator-Simple-0.01/
Simple iterator and utilities
----
Iterator-Simple-0.02
http://search.cpan.org/~rintaro/Iterator-Simple-0.02/
Simple iterator and utilities
----
Iterator-Simple-0.03
http://search.cpan.org/~rintaro/Iterator-Simple-0.03/
Simple iterator and utilities
----
JE-0.015
http://search.cpan.org/~sprout/JE-0.015/
Pure-Perl ECMAScript (JavaScript) Engine
----
MIME-AltWords-0.12
http://search.cpan.org/~pts/MIME-AltWords-0.12/
properly deal with RFC-1522 encoded words
----
POE-Component-IRC-5.31_05
http://search.cpan.org/~bingos/POE-Component-IRC-5.31_05/
a fully event-driven IRC client module.
----
Sort-Key-Radix-0.13
http://search.cpan.org/~salva/Sort-Key-Radix-0.13/
Radix sort implementation in XS
----
String-Similarity-1.03
http://search.cpan.org/~mlehmann/String-Similarity-1.03/
calculate the similarity of two strings
----
Test-Run-0.0110
http://search.cpan.org/~shlomif/Test-Run-0.0110/
----
Test-Run-CmdLine-0.0105
http://search.cpan.org/~shlomif/Test-Run-CmdLine-0.0105/
Analyze tests from the command line using Test::Run
----
Test-Run-Plugin-AlternateInterpreters-0.0103
http://search.cpan.org/~shlomif/Test-Run-Plugin-AlternateInterpreters-0.0103/
Define different interpreters for different test scripts with Test::Run.
----
Test-Run-Plugin-ColorFileVerdicts-0.0101
http://search.cpan.org/~shlomif/Test-Run-Plugin-ColorFileVerdicts-0.0101/
make the file verdict ("ok", "NOT OK") colorful.
----
Tie-File-FixedRecLen-0.2
http://search.cpan.org/~oliver/Tie-File-FixedRecLen-0.2/
Fixed Length Record support for Tie:File
----
Tie-Hash-ImmutableKeys-1.11
http://search.cpan.org/~fdulau/Tie-Hash-ImmutableKeys-1.11/
Perl module to create a HASH where keys are immutable but not the leaf data. It is possible to modify the key by FORCE_STORE or FORCE_DELETE. It is working on all the tree key created (keys and subkey
----
WWW-Fuel-US-Prices-0.0.3
http://search.cpan.org/~ashoooo/WWW-Fuel-US-Prices-0.0.3/
Perl Module to get the gas prices around a particular zip code in the US
----
WWW-Search-Jobs-2.026
http://search.cpan.org/~mthurn/WWW-Search-Jobs-2.026/
----
WebService-Nestoria-Search-0.09
http://search.cpan.org/~kaoru/WebService-Nestoria-Search-0.09/
Perl interface to the Nestoria Search public API.
----
XML-Grammar-Screenplay-0.04
http://search.cpan.org/~shlomif/XML-Grammar-Screenplay-0.04/
CPAN distribution implementing an XML grammar for screenplays.
----
boolean-0.11
http://search.cpan.org/~ingy/boolean-0.11/
Boolean support for Perl
----
perlec-0.08
http://search.cpan.org/~hio/perlec-0.08/
Perl Easy Call Interface
If you're an author of one of these modules, please submit a detailed
announcement to comp.lang.perl.announce, and we'll pass it along.
This message was generated by a Perl program described in my Linux
Magazine column, which can be found on-line (along with more than
200 other freely available past column articles) at
http://www.stonehenge.com/merlyn/LinuxMag/col82.html
print "Just another Perl hacker," # the original
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
Date: Tue, 12 Jun 2007 00:01:04 -0700
From: saran.jegan@gmail.com
Subject: perl vs C for CGI
Message-Id: <1181631664.923688.235750@a26g2000pre.googlegroups.com>
Hello,
am having a program in C which throws "internal server error"
reason is premature end of script headers but i checked my http header
& syntax of the program too , its fine. but when am re-program the
same in perl it works fine
i need to know the reason for the problem with C ,do any memory
problem cause this error ,can any suggest me on this.thanks for your
time
server:apache
------------------------------
Date: Tue, 12 Jun 2007 09:54:50 +0100
From: Ian Wilson <scobloke2@infotop.co.uk>
Subject: Re: perl vs C for CGI
Message-Id: <466e5f61$0$5859$da0feed9@news.zen.co.uk>
saran.jegan@gmail.com wrote:
> Hello,
> am having a program in C which throws "internal server error"
> reason is premature end of script headers but i checked my http header
> & syntax of the program too , its fine.
If Apache says your C program suffers froma premature end of script
headers I'd believe it. Probably you are not properly separating headers
from content or are not emitting headers.
You might like to re-read the CGI specs and see what they say about line
terminators and separating HTTP headers from the content.
> but when am re-program the
> same in perl it works fine
I'd run both programs from the command line, redirect output to files
and diff the files.
> i need to know the reason for the problem with C ,do any memory
> problem cause this error ,can any suggest me on this.thanks for your
> time
It's not a Perl problem so its not appropriate to a Perl newsgroup, I'd
try writing a "hello world" CGI program in C and if I got the same
errors, include the C source in a posting to a C newsgroup
It may be that you misunderstand CGI in which case asking in a CGI
newsgroup would be appropriate.
>
> server:apache
>
------------------------------
Date: Tue, 12 Jun 2007 07:10:30 GMT
From: tadmc@seesig.invalid
Subject: Posting Guidelines for comp.lang.perl.misc ($Revision: 1.8 $)
Message-Id: <GFrbi.12326$y_7.3963@newssvr27.news.prodigy.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.8 $)
This newsgroup, commonly called clpmisc, is a technical newsgroup
intended to be used for discussion of Perl related issues (except job
postings), whether it be comments or questions.
As you would expect, clpmisc discussions are usually very technical in
nature and there are conventions for conduct in technical newsgroups
going somewhat beyond those in non-technical newsgroups.
The article at:
http://www.catb.org/~esr/faqs/smart-questions.html
describes how to get answers from technical people in general.
This article describes things that you should, and should not, do to
increase your chances of getting an answer to your Perl question. It is
available in POD, HTML and plain text formats at:
http://www.rehabitation.com/clpmisc.shtml
For more information about netiquette in general, see the "Netiquette
Guidelines" at:
http://andrew2.andrew.cmu.edu/rfc/rfc1855.html
A note to newsgroup "regulars":
Do not use these guidelines as a "license to flame" or other
meanness. It is possible that a poster is unaware of things
discussed here. Give them the benefit of the doubt, and just
help them learn how to post, rather than assume that they do
know and are being the "bad kind" of Lazy.
A note about technical terms used here:
In this document, we use words like "must" and "should" as
they're used in technical conversation (such as you will
encounter in this newsgroup). When we say that you *must* do
something, we mean that if you don't do that something, then
it's unlikely that you will benefit much from this group.
We're not bossing you around; we're making the point without
lots of words.
Do *NOT* send email to the maintainer of these guidelines. It will be
discarded unread. The guidelines belong to the newsgroup so all
discussion should appear in the newsgroup. I am just the secretary that
writes down the consensus of the group.
Before posting to comp.lang.perl.misc
Must
This section describes things that you *must* do before posting to
clpmisc, in order to maximize your chances of getting meaningful replies
to your inquiry and to avoid getting flamed for being lazy and trying to
have others do your work.
The perl distribution includes documentation that is copied to your hard
drive when you install perl. Also installed is a program for looking
things up in that (and other) documentation named 'perldoc'.
You should either find out where the docs got installed on your system,
or use perldoc to find them for you. Type "perldoc perldoc" to learn how
to use perldoc itself. Type "perldoc perl" to start reading Perl's
standard documentation.
Check the Perl Frequently Asked Questions (FAQ)
Checking the FAQ before posting is required in Big 8 newsgroups in
general, there is nothing clpmisc-specific about this requirement.
You are expected to do this in nearly all newsgroups.
You can use the "-q" switch with perldoc to do a word search of the
questions in the Perl FAQs.
Check the other standard Perl docs (*.pod)
The perl distribution comes with much more documentation than is
available for most other newsgroups, so in clpmisc you should also
see if you can find an answer in the other (non-FAQ) standard docs
before posting.
It is *not* required, or even expected, that you actually *read* all of
Perl's standard docs, only that you spend a few minutes searching them
before posting.
Try doing a word-search in the standard docs for some words/phrases
taken from your problem statement or from your very carefully worded
"Subject:" header.
Really Really Should
This section describes things that you *really should* do before posting
to clpmisc.
Lurk for a while before posting
This is very important and expected in all newsgroups. Lurking means
to monitor a newsgroup for a period to become familiar with local
customs. Each newsgroup has specific customs and rituals. Knowing
these before you participate will help avoid embarrassing social
situations. Consider yourself to be a foreigner at first!
Search a Usenet archive
There are tens of thousands of Perl programmers. It is very likely
that your question has already been asked (and answered). See if you
can find where it has already been answered.
One such searchable archive is:
http://groups.google.com/advanced_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 and many others on the comp.lang.perl.misc newsgroup.
--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"
------------------------------
Date: Mon, 11 Jun 2007 21:41:15 -0700
From: "comp.llang.perl.moderated" <ced@blv-sam-01.ca.boeing.com>
Subject: Re: Recovering from system call errors
Message-Id: <1181623275.683321.61080@i38g2000prf.googlegroups.com>
On Jun 8, 6:44 am, novaho...@gmail.com wrote:
> In my perl script I make several system calls to start scripts. These
> scripts launch other applications, e.g. one of the applications is a
> java application and the java application in turn launches a C++
> application. The problem I am having is that if the C++ application
> crashes (which it has been known to do) my script still waits for the
> system call to return. And I can't modify the java + c++
> applications. Is there a way for me to watch these processes and be
> able to handle a crash via perl?
If Java isn't detecting and returning an error
when C++ crashes, there probably aren't any easy
solutions. Unix can provide Proc::ProcessTable
to scan the process table for id's and ppid's.
You could conceivably start a separate thread or
process that'd intermittently check processes to ensure Java and C++
are still running. In that
case you may possibly be better off manually
forking or using IPC::Open2/3 to get the Java process id.
What happens to the parent if C++ crashes.. if
Java just hangs in that case and there's a reasonable expected time
framework for Java-C++
to complete, you could just set an alarm and bail out if C++ goes
south.
hth,
--
Charles DeRykus
------------------------------
Date: Tue, 12 Jun 2007 08:15:52 -0000
From: "Thomas F. Burdick" <tburdick@gmail.com>
Subject: Re: The Concepts and Confusions of Prefix, Infix, Postfix and Fully Functional Notations
Message-Id: <1181636152.035125.152390@r19g2000prf.googlegroups.com>
On Jun 11, 11:36 pm, Tim Bradshaw <tfb+goo...@tfeb.org> wrote:
> On Jun 11, 8:02 am, Twisted <twisted...@gmail.com> wrote:
>
> > On Jun 11, 2:42 am, Joachim Durchholz <j...@durchholz.org> wrote:
>
> > > It is possible to write maintainable Perl.
>
> > Interesting (spoken in the tone of someone hearing about a purported
> > sighting of Bigfoot, or maybe a UFO).
>
> I think it's just obvious that this is the case. What would *stop*
> you writing maintainable Perl?
The constantly shifting target of a language. Hell, even the parser
has changed over time. Fortunately this seems to have been solved by
Perl 6 [*].
[*] Stopping work on Perl 5 to focus on the probably never-to-be Perl
6 brought a surprising stability to the language.
------------------------------
Date: Tue, 12 Jun 2007 09:50:14 +0200
From: Joachim Durchholz <jo@durchholz.org>
Subject: Re: The Concepts and Confusions of Prefix, Infix, Postfix and Fully Functional Notations
Message-Id: <f4lj0r$ccb$1@online.de>
Twisted schrieb:
> On Jun 11, 5:36 pm, Tim Bradshaw <tfb+goo...@tfeb.org> wrote:
>> I think it's just obvious that this is the case. What would *stop*
>> you writing maintainable Perl?
>
> For starters, the fact that there are about six zillion obscure
> operators represented by punctuation marks, instead of a dozen or so.
> More generally, the fact that it comes out looking like modem barf,
> and modem barf is unmaintainable. ;)
You can write Perl that uses just a dozen or so punctuation marks, so
that doesn't stop you (or anybody else) from writing maintainable Perl.
You haven't looked into the Webmin code that I gave for an example, have
you? You'd have seen code that's quite far from line noise. (But
sticking with prejudice can be more fun, I know...)
If anything, the real criticism is that it's easy to write
unmaintainable Perl, so there's too much of unmaintainable Perl around.
The other criticism is that Perl's learning curve is needlessly
prolonged because you need time to pick up all those idioms that are
possible - nice for those who're doing Perl and just Perl, horror for
those who usually work in other languages.
I don't know of any other serious design flaws in the language, given
its design goals. (When designing a scripting/glue language today, I'd
set up slightly different design goals, of course. Perl is far from the
optimum that should be used today, its main merits are its ubiquity and
completeness, not the language qualities.)
Regards,
Jo
------------------------------
Date: Mon, 11 Jun 2007 22:54:35 -0700
From: Marek <mstep@podiuminternational.org>
Subject: Re: Useless use of array element in void context
Message-Id: <1181627675.088835.78210@j4g2000prf.googlegroups.com>
On Jun 12, 3:55 am, Paul Lalli <mri...@gmail.com> wrote:
> On Jun 11, 7:01 pm, "Dr.Ruud" <rvtol+n...@isolution.nl> wrote:
>
> > Marek schreef:
> > > This is looking really genius! But this gives me a syntax
> > > error! I probably misunderstood something?
>
> > What did you try,
>
> Er. Presumably the line of quote directly above the text that you
> just quoted...
> my $result[$_] = $out_line[$_] - $old_line[$_] for 2..6;
>
> > and what was the syntax error?
>
> Looking at it, I'd say the syntax error would be to the effect that
> you can't declare an array element with 'my'.
>
> Paul Lalli
Probably I am doing a terrible beginner's error, but I get this
message:
syntax error at excel_uebung.pl line .., near "$result["
Here the script with the line my $result[$_] = $out_line[$_] -
$old_line[$_] for 2..6;:
#! /usr/bin/perl/
use warnings;
use strict;
my @out_lines = split(
/\n/,
'Mit, 16.05.2007 992.50 44284.40 2688 69.50
10110.90 Name1
Don, 17.05.2007 1148.90 44364.80 2707 69.50
10307.60 Name2
Fre, 18.05.2007 1408.50 44496.50 2714 69.50
10512.90 Name1
Sam, 19.05.2007 1736.60 44665.00 2738 69.50
10864.50 Name2
Son, 20.05.2007 2003.41 44769.00 2746 69.50
11037.70 Name1
Mon, 21.05.2007 2294.10 44907.40 2754 70.50
11256.30 Name1
Die, 22.05.2007 2683.10 45151.10 2762 70.50
11607.90 Name1
Mit, 23.05.2007 2994.30 45284.10 2765 70.50
11808.00 Name1
Don, 24.05.2007 3092.10 45336.50 2777 70.50
11953.40 Name1
Fre, 25.05.2007 3092.10 45336.50 2777 70.50
11953.40 Name2
Sam, 26.05.2007 3092.10 45336.50 2777 70.50
11953.40 Name2
Son, 27.05.2007 3092.10 45336.50 2777 70.50
11953.40 Name2
Mon, 28.05.2007 3494.70 45498.30 2816 70.50
12358.30 Name2
Die, 29.05.2007 3896.20 45617.80 2821 70.50
12535.40 Name1
Mit, 30.05.2007 4226.30 45851.00 2829 70.50
12875.60 Name1
Don, 31.05.2007 4465.80 45920.90 2834 70.50
12974.20 Name1'
);
my $old_line;
foreach my $out_line (@out_lines) {
if ($old_line) {
$old_line =~ s/\s+[-a-z\d]+$//i;
my @old_line = split( /\s+/, $old_line );
my @out_line = split( /\s+/, $out_line );
my $same = 1;
$same = $same && $old_line[$_] == $out_line[$_] for ( 2 ..
6 );
if ($same) {
print "same numbers:\n";
print join( "\t", @old_line ) . "\n";
print join( "\t", @out_line ) . "\n";
print "TOTAL\t\t0.00\t0.00\t0.00\t0.00\t0.00\n";
}
else {
print "different numbers\n";
# my @result = map $out_line[$_] -
$old_line[$_], 2 .. 6;
my $result[$_] = $out_line[$_] - $old_line[$_] for 2 .. 6;
print join( "\t", @old_line ) . "\n";
print join( "\t", @out_line ) . "\n";
printf( "TOTAL\t\t%.2f\t%.2f\t%.2f\t%.2f\t%.2f\n",
@result[ 2 .. 6 ] );
}
$old_line = $out_line;
}
else {
$old_line = $out_line;
}
}
------------------------------
Date: Tue, 12 Jun 2007 01:45:15 -0700
From: Joe Smith <joe@inwap.com>
Subject: Re: Useless use of array element in void context
Message-Id: <y7adnVHikqSBwPPbnZ2dnUVZ_j-dnZ2d@comcast.com>
Marek wrote:
> On Jun 12, 3:55 am, Paul Lalli <mri...@gmail.com> wrote:
>> On Jun 11, 7:01 pm, "Dr.Ruud" <rvtol+n...@isolution.nl> wrote:
>>
>>> Marek schreef:
>>>> This is looking really genius! But this gives me a syntax
>>>> error! I probably misunderstood something?
>>> What did you try,
>> Er. Presumably the line of quote directly above the text that you
>> just quoted...
>> my $result[$_] = $out_line[$_] - $old_line[$_] for 2..6;
>>
>>> and what was the syntax error?
>> Looking at it, I'd say the syntax error would be to the effect that
>> you can't declare an array element with 'my'.
>>
>> Paul Lalli
>
>
>
> Probably I am doing a terrible beginner's error, but I get this
> message:
>
>
> syntax error at excel_uebung.pl line .., near "$result["
>
>
> Here the script with the line my $result[$_] = $out_line[$_] -
> $old_line[$_] for 2..6;:
How many times do we have to repeat it?
"That is a syntax error; you CANNOT declare an array element with 'my'".
Do you know what an "array element" is?????
You can declare an entire array with 'my', you cannot declare
individual elements with 'my'.
1) Put "my @result;" on a line by itself.
2) Use "$result[$_]" without 'my'.
-Joe
------------------------------
Date: Tue, 12 Jun 2007 01:58:50 -0700
From: Marek <mstep@podiuminternational.org>
Subject: Re: Useless use of array element in void context
Message-Id: <1181638730.293734.298390@g37g2000prf.googlegroups.com>
Sorry, Joe, I have had the feeling, when posting the last message,
that there is something terrible wrong!
I am blushing!
Thanx to all, having so much patience with me
marek
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc. For subscription or unsubscription requests, send
#the single line:
#
# subscribe perl-users
#or:
# unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.
#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V11 Issue 508
**************************************