[23112] in Perl-Users-Digest
Perl-Users Digest, Issue: 5333 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Aug 8 06:05:58 2003
Date: Fri, 8 Aug 2003 03:05:08 -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, 8 Aug 2003 Volume: 10 Number: 5333
Today's topics:
Re: Checkbox into an Array ? (Tad McClellan)
Re: Checkbox into an Array ? <usenet@dwall.fastmail.fm>
Re: DBI suddenly not working... <jim.bloggs@eudoramail.com>
Re: DBI suddenly not working... (Tad McClellan)
Re: Find Files By Date <grazz@pobox.com>
Re: Find Files By Date <mgjv@tradingpost.com.au>
Re: Find Files By Date <noreply@gunnar.cc>
hash <sonet.all@msa.hinet.net>
Re: hash <g4rry_sh0rt@zw4llet.com>
Re: hash <ThomasKratz@REMOVEwebCAPS.de>
Re: help needed making unicode entities <flavell@mail.cern.ch>
Re: help with regular expression <spamblock@junkmail.com>
Re: help with regular expression <krahnj@acm.org>
Re: Net-Whois-IP-0.35 returning incorrect responses? <syl@alcor.concordia.ca>
Re: Net-Whois-IP-0.35 returning incorrect responses? <syl@alcor.concordia.ca>
Perl and C APIs (Gregski)
Posting Guidelines for comp.lang.perl.misc ($Revision: tadmc@augustmail.com
Re: Replace a word if its not in an html tag <bigj@kamelfreund.de>
Return value of chomp, with alternate value in $/ <spamblock@junkmail.com>
Re: Return value of chomp, with alternate value in $/ <tassilo.parseval@rwth-aachen.de>
Re: Return value of chomp, with alternate value in $/ <spamblock@junkmail.com>
Re: Return value of chomp, with alternate value in $/ <noreply@gunnar.cc>
Re: Return value of chomp, with alternate value in $/ <tassilo.parseval@rwth-aachen.de>
Re: ssh and Perl <matthew.garrish@sympatico.ca>
Submit tabulator to console and get output? (Math55)
Re: Variables Definition File (Schaltung)
Re: <bwalton@rochester.rr.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 7 Aug 2003 21:07:54 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Checkbox into an Array ?
Message-Id: <slrnbj61fq.4i1.tadmc@magna.augustmail.com>
David K. Wall <usenet@dwall.fastmail.fm> wrote:
> <ctcgag@hotmail.com> wrote:
>> sylviestone@canada.com (Sylvie Stone) wrote:
>>> print "<input type=checkbox name=\"statuscodearray[]\"
>> Is it legal to have [] in the name of a form element?
>
> No. See http://www.w3.org/TR/html4/types.html#type-cdata
That is a _different_ NAME.
A "NAME" in SGML is what a programmer might be used to
calling an "identifier".
In:
<input name="statuscodearray[]"> </input>
^^^^^ ^^^^ ^^^^ ^^^^^
There are 4 NAMEs. They must each follow the rules at the URL you cite above.
"input" is the NAME of an element, so it is used in the start tag.
And the end tag.
"name" is the NAME of an attribute on the input element.
"nbsp" is the NAME of a general entity.
The "name" in the "Is it legal" part above is yet a third
overloaded use of the term.
_That_ name is actually a _value_ (of an attribute) as far
as the markup language is concerned.
You cannot tell what is allowed for the value of the name attribute
without access to the DTD being used.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Fri, 08 Aug 2003 03:50:19 -0000
From: "David K. Wall" <usenet@dwall.fastmail.fm>
Subject: Re: Checkbox into an Array ?
Message-Id: <Xns93D0F280540D0dkwwashere@216.168.3.30>
[rather than follow up two posts, I'll follow up myself and summarize (sort
of)]
I wrote:
> <ctcgag@hotmail.com> wrote:
>> Is it legal to have [] in the name of a form element?
>
> No. See http://www.w3.org/TR/html4/types.html#type-cdata
Andy Hassell and Tad McClellan have both demonstrated that I was wrong.
Consider the statement retracted, and, as always, thanks for the correction.
I still think I'll avoid such usage myself, unless I decided to use PHP and
absolutely have to. :-)
--
David Wall
------------------------------
Date: Fri, 8 Aug 2003 03:25:15 +0100
From: "doofus" <jim.bloggs@eudoramail.com>
Subject: Re: DBI suddenly not working...
Message-Id: <bgv1md$rcn2n$1@ID-150435.news.uni-berlin.de>
doofus wrote:
> HELP!
>
> If I put the line 'use DBI' anywhere in my program it gives up and
> produces no out put. So, for example, the prog
>
> print "jkl";
> use DBI;
>
> stops and has a think for about a half second and then exits silently.
> It is evidently loading DBI and then totally going nuts.
>
OK. Just for the record, I seem to have fixed it by reverting to 5.6.
{:/
------------------------------
Date: Thu, 7 Aug 2003 23:07:10 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: DBI suddenly not working...
Message-Id: <slrnbj68fe.1ne.tadmc@magna.augustmail.com>
doofus <jim.bloggs@eudoramail.com> wrote:
>> If I put the line 'use DBI' anywhere in my program it gives up and
> OK. Just for the record, I seem to have fixed it by reverting to 5.6.
Errr, from what?
You never told us what perl version you had.
If knew you are backing up from 5.8.0, then I'd make a guess at
why you are having the problem, but I don't so I won't.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Fri, 08 Aug 2003 04:39:22 GMT
From: Steve Grazzini <grazz@pobox.com>
Subject: Re: Find Files By Date
Message-Id: <_PFYa.1521$sb4.677@nwrdny01.gnilink.net>
Gunnar Hjalmarsson <noreply@gunnar.cc> wrote:
> Gunnar Hjalmarsson wrote:
> >
> > (stat "$dirpath/$_")[9] >= $starttime
> -------------------------------^
>
> A correction: OP asked about _creation_ date, which I for
> some inscrutable reason 'converted' to last modified date...
Probably your subconscious was telling you: "There's no such
thing as 'creation date'".
--
Steve
------------------------------
Date: 08 Aug 2003 05:17:04 GMT
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: Find Files By Date
Message-Id: <slrnbj6cij.41m.mgjv@verbruggen.comdyn.com.au>
On Fri, 08 Aug 2003 04:39:22 GMT,
Steve Grazzini <grazz@pobox.com> wrote:
> Gunnar Hjalmarsson <noreply@gunnar.cc> wrote:
>> Gunnar Hjalmarsson wrote:
>> >
>> > (stat "$dirpath/$_")[9] >= $starttime
>> -------------------------------^
>>
>> A correction: OP asked about _creation_ date, which I for
>> some inscrutable reason 'converted' to last modified date...
>
> Probably your subconscious was telling you: "There's no such
> thing as 'creation date'".
From perlport.pod, Perl 5.8.0 [1]
\begin{quote}
=item stat FILEHANDLE
=item stat EXPR
=item stat
Platforms that do not have rdev, blksize, or blocks will return these
as '', so numeric comparison or manipulation of these fields may cause
'not numeric' warnings.
mtime and atime are the same thing, and ctime is creation time instead
of inode change time. (S<Mac OS>).
ctime not supported on UFS (S<Mac OS X>).
ctime is creation time instead of inode change time (Win32).
device and inode are not meaningful. (Win32)
device and inode are not necessarily reliable. (VMS)
mtime, atime and ctime all return the last modification time. Device
and inode are not necessarily reliable. (S<RISC OS>)
dev, rdev, blksize, and blocks are not available. inode is not
meaningful and will differ between stat calls on the same file. (os2)
some versions of cygwin when doing a stat("foo") and if not finding it
may then attempt to stat("foo.exe") (Cygwin)
\end{quote}
Obviously, at least two OSes/file systems in this list keep track of
creation time, and return that as the ctime field (10) for stat().
Martien
[1] I read perlport.pod after posting my own reply, and under 5.8,
(stat())[10] is the creation time for Windows. Under 5.6.1 perlport
does not mention an exception for ctime, so I assume that before 5.8.0
the ctime field was not meaningful on Win32.
--
|
Martien Verbruggen |
Trading Post Australia | "Mr Kaplan. Paging Mr Kaplan..."
|
------------------------------
Date: Fri, 08 Aug 2003 09:42:04 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Find Files By Date
Message-Id: <bgvk8d$soh0o$1@ID-184292.news.uni-berlin.de>
Steve Grazzini wrote:
> Gunnar Hjalmarsson <noreply@gunnar.cc> wrote:
>>Gunnar Hjalmarsson wrote:
>>
>>> (stat "$dirpath/$_")[9] >= $starttime
>>
>>-------------------------------^
>>
>>A correction: OP asked about _creation_ date, which I for
>>some inscrutable reason 'converted' to last modified date...
>
> Probably your subconscious was telling you: "There's no such
> thing as 'creation date'".
Maybe... :)
But then I tested the output from stat() (with 5.8.0 on W98), and
found that (stat()[10]) is a time notation before (stat()[9]), so I
concluded that it actually shows creation time. Wasn't as clever as
Martien, though, and studied perlport...
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Fri, 8 Aug 2003 16:55:35 +0800
From: <sonet.all@msa.hinet.net>
Subject: hash
Message-Id: <bgvom9$fjq@netnews.hinet.net>
how to do $ADHash{@userArray}=1;
Known
@usrArray = [a,b,c]
Let:
$ADHach{'a'}=1
$ADHach{'b'}=1
$ADHach{'c'}=1
please mail to : sonet.all@msa.hinet.net
------------------------------
Date: Fri, 08 Aug 2003 10:08:03 +0000
From: Garry Short <g4rry_sh0rt@zw4llet.com>
Subject: Re: hash
Message-Id: <3f33687c$0$46005$65c69314@mercury.nildram.net>
sonet.all@msa.hinet.net wrote:
> how to do $ADHash{@userArray}=1;
>
>
> Known
> @usrArray = [a,b,c]
>
> Let:
> $ADHach{'a'}=1
> $ADHach{'b'}=1
> $ADHach{'c'}=1
>
>
> please mail to : sonet.all@msa.hinet.net
How about:
foreach my $elem (@usrArray) { $ADHash{$elem} = 1 }
or, even nicer (didn't know this was possible; suddenly had a flash of
inspiration, tried it, and ... )
$ADHash{$_} = 1 foreach @usrArray;
I like that one :-)
Garry
------------------------------
Date: Fri, 8 Aug 2003 11:42:12 +0200
From: "Thomas Kratz" <ThomasKratz@REMOVEwebCAPS.de>
Subject: Re: hash
Message-Id: <3f33709c.0@juno.wiesbaden.netsurf.de>
DQoiR2FycnkgU2hvcnQiIDxnNHJyeV9zaDBydEB6dzRsbGV0LmNvbT4gd3JvdGUuLi4NCj4gc29u
ZXQuYWxsQG1zYS5oaW5ldC5uZXQgd3JvdGU6DQo+IA0KPiA+IGhvdyB0byBkbyAkQURIYXNoe0B1
c2VyQXJyYXl9PTE7DQo+ID4gDQo+ID4gDQo+ID4gS25vd24NCj4gPiBAdXNyQXJyYXkgPSBbYSxi
LGNdDQo+ID4gDQo+ID4gTGV0Og0KPiA+ICRBREhhY2h7J2EnfT0xDQo+ID4gJEFESGFjaHsnYid9
PTENCj4gPiAkQURIYWNoeydjJ309MQ0KPiA+IA0KPiA+IA0KPiA+IHBsZWFzZSBtYWlsIHRvIDog
c29uZXQuYWxsQG1zYS5oaW5ldC5uZXQNCj4gDQo+IEhvdyBhYm91dDoNCj4gDQo+IGZvcmVhY2gg
bXkgJGVsZW0gKEB1c3JBcnJheSkgeyAkQURIYXNoeyRlbGVtfSA9IDEgfQ0KPiANCj4gb3IsIGV2
ZW4gbmljZXIgKGRpZG4ndCBrbm93IHRoaXMgd2FzIHBvc3NpYmxlOyBzdWRkZW5seSBoYWQgYSBm
bGFzaCBvZg0KPiBpbnNwaXJhdGlvbiwgdHJpZWQgaXQsIGFuZCAuLi4gKQ0KPiANCj4gJEFESGFz
aHskX30gPSAxIGZvcmVhY2ggQHVzckFycmF5Ow0KDQpvciBpZiB5b3Ugd2FudCB0byBhdm9pZCBh
biBleHRyYSBsaW5lIGZvciBkZWNsYXJpbmcgdGhlIGhhc2ggdW5kZXIgJ3VzZSBzdHJpY3QnOg0K
DQpteSAlQURIYXNoID0gbWFwIHsgJF8gPT4gMSB9IEB1c3JBcnJheTsNCg0KVGhvbWFz
------------------------------
Date: Fri, 8 Aug 2003 11:32:15 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: help needed making unicode entities
Message-Id: <Pine.LNX.4.53.0308081113340.31714@lxplus007.cern.ch>
Let's try again:
On Fri, Aug 8, Dan Jacobson inscribed on the eternal scroll:
> Why does
> use HTML::Entities; use utf8;
> print HTML::Entities::encode_entities_numeric("\xE7\xA9\x8D");
> print
> 積 i.e. three entities, instead of one?
I think the reason is that you've given it three characters, not one.
The effect of "use utf8;" is that when you write an 8-bit character
e.g \xE7 in your source code, Perl upgrades it to utf-8 instead of
maintaining it as an 8-bit character. So internally it becomes the
pair of octets which represent the Unicode character U+00E7, although
its ord() value is still, of course, hex E7. This is not what you
want.
What it appears you're trying to do is to construct the internal utf-8
representation yourself. I don't know why you'd want to do that, but
as far as I understand it, the following kind of code (I'm doing it
"per pedes" rather than trying any clever shortcuts) could do it.
Disclaimer: I'm still a bit of a beginner at this, but nobody else
seems particularly keen to offer answers in this area, it seems, so
I'm doing my best.
use Encode;
[...]
my $octets;
{
use bytes;
$octets = "\xE7\xA9\x8D";
}
my $string = decode_utf8($octets);
Note that not all octet sequences represent valid utf-8: this call
should throw a warning if an invalid sequence is presented.
If you want to be quick and dirty, I _think_ you can just set the
internal utf8 flag on your octet-string, taking responsibility
yourself for its validity. Further reading on this is at:
http://www.perldoc.com/perl5.8.0/lib/Encode.html
If you're just trying to compose Unicode characters into your source
code, I suppose you'd be better off using the "wide character"
notation, \x{uuuu} to represent the Unicode character U+uuuu (which
you can look up at the unicode web site, see the URLs I posted on
another recent thread re Japanese), rather than hand-coding utf-8
octets in hex. But then, you didn't explain why or how it arose that
you wanted to start from the latter notation - maybe you have your
own good reasons for wanting that...
cheers
------------------------------
Date: Thu, 7 Aug 2003 18:22:15 -0700
From: "David Oswald" <spamblock@junkmail.com>
Subject: Re: help with regular expression
Message-Id: <vj5v0ojc0nf00a@corp.supernews.com>
"Tad McClellan" <tadmc@augustmail.com> wrote in message
news:slrnbj5rg1.4e4.tadmc@magna.augustmail.com...
> the dude <jason@memorycheaper.net> wrote:
>
> > i need to write one that will search for and display:
> >
> > the letters "ABA", the text in between, until it finds the next
> > instance of "ABA" or "000"
>
>
> Assuming you have the text in $_ :
>
> print "$1\n" if /(ABA.+?)(ABA|000)/s;
Your point is well taken on assuring that there was indeed a match.
However, I still think that it should be as follows (borrowing from your
match test logic):
Assuming text is in $_:
print "$1\n" if /(ABA.*?)(ABA|000)/s;
The reason that I suggest .*? instead of .+? is that by his post I wasn't
able to determine that there was certain to actually be anything between ABA
and ABA|000. It may be the case that there will always be something
between, in which case .+? is appropriate, but his post didn't specify, and
.*? will definately work in either case.
He is going to run into trouble if there is more than one instance in the
same iteration of $_ because the second ABA|000 has been gobbled up by the
previous match. If he were to search in list context with the /g option, he
would need to use a construct like this:
/(ABA.*?)(?=ABA|000)/sg
And then he would need to be thinking in list context or iterating with a
foreach or something. But the idea I'm introducing is that he wants to
match and capture ABA.*? until he reaches the next ABA|000, but he doesn't
want to capture the second ABA|000, and in fact, doesn't even want to get
that far into his match, because he wants to preserve the second ABA|000 for
the next match iteration.
The preceeding example, assuming the match string is "ABAasdfaj asdfjasdfj
asfd jasdf ABAfastasdf000", will match "ABAasdfaj asdfjasdfj asfd jasdf "
while preserving "ABAfastasdf" for the second match. The second match will
match ABAfastasdf and will discard 000. That's the behavior his description
requested. It may not be what he wants, but it's what he was asking.... I
think. ;)
Interesting discussion nevertheless....
Dave
------------------------------
Date: Fri, 08 Aug 2003 05:17:22 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: help with regular expression
Message-Id: <3F33325C.D8D9E613@acm.org>
the dude wrote:
>
> im kind of a newbie to regular expressions, and i am stuck.
> i need to write one that will search for and display:
>
> the letters "ABA", the text in between, until it finds the next
> instance of "ABA" or "000"
>
> So if I had the text
> -----------
> alsdfjadslfjasf
> ABA001 abcdefg hijklmno
> aaaaaa bbbbbb
> ABA002
> -----------
>
> I would need it to find
> ----------------------
> ABA001 abcdefg hijklmno
> aaaaaa bbbbbb
> ------------------------
>
> so I could write the result to a database
This might be what you need:
my $data;
while ( <> ) {
next unless my $state = /ABA/ ... /ABA|000/;
if ( $state eq $state + 0 ) {
$data .= $_;
}
else {
write_to_database( $data );
$data = '';
}
}
John
--
use Perl;
program
fulfillment
------------------------------
Date: 8 Aug 2003 03:01:57 GMT
From: Sylvain Robitaille <syl@alcor.concordia.ca>
Subject: Re: Net-Whois-IP-0.35 returning incorrect responses?
Message-Id: <slrnbj64l5.384k.syl@alcor.concordia.ca>
Peter Scott wrote:
> [snip program; can be replaced by
> perl -MData::Dumper -MNet::Whois::IP=whoisip_query \
> -e 'print Dumper whoisip_query("132.205.7.51")'
> ]
Yikes! I'm pretty fond of creating one-liners myself, but it just goes
to show that I still have *lots* to learn!
> First let me thank you for posing a perfectly formed question; all the
> information needed (most of which I cut out :-) and a clear question.
Well, thank you, and J. Gleixner, for taking the time to read it and to
propose a solution. In fact, thanks to anyone who's read my original
post, even if a solution didn't come to mind...
(thanks especially to Peter, for taking the extra time to debug the
Net-Whois-IP module, submit a bug report, and propose a solution that
will likely work -- I'll give it a try and report back if I still have
problems.)
> I ran this under the debugger and found that the problem is a bug in
> Net::Whois::IP. It thinks that if the result does not include a
> TechPhone or an OrgTechPhone attribute then it should try a whois
> query for the parent handle.
Bingo! I should have thought to trace it myself!
> This is at odds with its documentation which says it keeps going until
> it gets an OrgName or CustName.
Right. I would have expected to stop on those as well.
Perhaps I need to have our Whois info modified to include a Tech phone
number, though (it would be the same as the listed AbusePhone number
anyway...)
> I have submitted a bug report.
Wow! Thank you, both for fing the problem, and for going the extra
distance to submit the bug-report.
> Unless and until the module is improved, you'll need to make a copy of
> it to go somewhere earlier in your @INC and modify it.
Or, I can just patch and re-install the module itself, but the idea is
the same ...
> I suggest you look for the line
>
> }elsif(/Parent:\s+(\S+)/) {
>
> and on the next (long) line, change TechPhone to NetName and change
> OrgTechPhone to OrgName.
Will do. Thanks a whole bunch!
--
----------------------------------------------------------------------
Sylvain Robitaille syl@alcor.concordia.ca
Systems analyst Concordia University
Instructional & Information Technology Montreal, Quebec, Canada
----------------------------------------------------------------------
------------------------------
Date: 8 Aug 2003 03:04:08 GMT
From: Sylvain Robitaille <syl@alcor.concordia.ca>
Subject: Re: Net-Whois-IP-0.35 returning incorrect responses?
Message-Id: <slrnbj64p8.384k.syl@alcor.concordia.ca>
J. Gleixner wrote:
> Try Net::Whois::Raw
Thanks. I appreciate the response. If I can't get Peter Scott's solution
to work, I'll give that a try.
--
----------------------------------------------------------------------
Sylvain Robitaille syl@alcor.concordia.ca
Systems analyst Concordia University
Instructional & Information Technology Montreal, Quebec, Canada
----------------------------------------------------------------------
------------------------------
Date: 8 Aug 2003 02:00:53 -0700
From: gregm@eit.ltd.uk (Gregski)
Subject: Perl and C APIs
Message-Id: <dbbc3646.0308080100.2bd043ff@posting.google.com>
I have an API which I wish to make accessible via Perl and I'm looking
for some advice:
Under C, I would normally set up sessions, register callbacks and then
run a control-loop API call which holds my program until the session
is broken; all processing of events is done solely through callbacks.
I'm having difficulty in getting to grips with how best to approach
this problem: if I purely tried to write a similar flow, I would never
be able to return a session handle to Perl, control would only return
once the API returned - useless because by then the session is broken.
On the other hand, if I register Perl functions for the callbacks from
C, I'm left with an un-Perl like program flow (yes, I know...),
because what *I think* I'd really like to do is use Perl to read data
in at polled intervals from the C-side called-back routines acting
effectively as data collectors. But do I?
One way round this would be to create a separate thread which enters
the control-loop, leaving another thread to do its stuff.
Additionally, since I want platform independence, I can't use fork.
1) What are my options?
2) Has anyone published a cookbook that deals with issues like these?
------------------------------
Date: Fri, 08 Aug 2003 02:22:16 -0500
From: tadmc@augustmail.com
Subject: Posting Guidelines for comp.lang.perl.misc ($Revision: 1.4 $)
Message-Id: <BVWdnW-ByPQ10q6iU-KYuQ@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, 08 Aug 2003 03:39:24 +0200
From: "Janek Schleicher" <bigj@kamelfreund.de>
Subject: Re: Replace a word if its not in an html tag
Message-Id: <pan.2003.08.08.01.35.49.351351@kamelfreund.de>
Jeff 'japhy' Pinyan wrote at Thu, 07 Aug 2003 17:21:17 -0400:
>>> How *does* one assert a negative group of multiple
>>> characters?
>>
>>
>>With a "negative look-behind assertion" (perlre.pod):
>>
>> /(?<! <\/? body )/x
>
> Last time I checked, variable-width patterns weren't allowed in a
> look-behind.
At least in this case, there's an easy workaround, expanding the variable
length negative look behind into its fixed length possibilities:
m!(?<! / body)
(?<! body)!x;
Greetings,
Janek
------------------------------
Date: Fri, 8 Aug 2003 00:47:04 -0700
From: "David Oswald" <spamblock@junkmail.com>
Subject: Return value of chomp, with alternate value in $/
Message-Id: <vj6llghhb5pp6b@corp.supernews.com>
It is my understanding that $/ contains the value that is considered to be a
newline character. I also understand that chomp removes as many newlines at
the end of a string as exist, and returns the number removed.
Therefore, I expect that the following code snippet should print 3. When I
test it, the output is 1.
use strict;
use warnings;
my $test_string = "AAABBBCCC";
$/ = "C";
print chomp ( $test_string ) , "\n" ;
I have used parenthesis to ensure that chomp is in scalar mode, not list
mode.
Programming Perl states that chomp returns the number of characters chomped.
Based on the above example, with three "C's", I expect chomp to return
three.
The common mantra is that Perl does only what one asks it to do. In that
context there obviously is a discrepancy between what I'm asking, and what
I'm expecting to be the results. If anyone could point out the flaw in my
thinking, I'd really appreciate it.
By the way, I'm aware it's ugly, abusive of the intended use of chomp and
$/, and so on. This is for my own learning process, not production code.
--
DJO
------------------------------
Date: 8 Aug 2003 08:26:46 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: Return value of chomp, with alternate value in $/
Message-Id: <bgvms6$phn$1@nets3.rz.RWTH-Aachen.DE>
Also sprach David Oswald:
> It is my understanding that $/ contains the value that is considered to be a
> newline character. I also understand that chomp removes as many newlines at
> the end of a string as exist, and returns the number removed.
Actually, the docs say:
chomp This safer version of "chop" removes any trailing string that
corresponds to the current value of $/ (also known as
$INPUT_RECORD_SEPARATOR in the "English" module). It returns the
total number of characters removed from all its arguments.
Mark that it is 'Any trailing string' and not 'Any trailing strings'
(plural). There is this special case in which it will exactly do that,
namely when $/ = '' (known as paragraph mode):
$_ = "test\n\n\n";
$/ = '';
print chomp;
__END__
3
The return value of chomp is - save for the above exception - simply
length($/) when a string has been stripped off the end.
>
> Therefore, I expect that the following code snippet should print 3. When I
> test it, the output is 1.
>
> use strict;
> use warnings;
> my $test_string = "AAABBBCCC";
> $/ = "C";
> print chomp ( $test_string ) , "\n" ;
>
> I have used parenthesis to ensure that chomp is in scalar mode, not list
> mode.
You don't need them in this case. Perl is smart enough to know that in
print chomp $string, "\n";
the arguments to chomp() can't be $string and "\n" because the latter
would result in an attempt to modify a read-only value. So it only
chomps $string.
> The common mantra is that Perl does only what one asks it to do. In that
> context there obviously is a discrepancy between what I'm asking, and what
> I'm expecting to be the results. If anyone could point out the flaw in my
> thinking, I'd really appreciate it.
It's the question how people intuitively interpretate the first
paragraph in the docs. I'd probably also assume it would chop off all
occurances of $/ from a string on casual reading. Perhaps the docs could
be clearer.
Tassilo
--
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval
------------------------------
Date: Fri, 8 Aug 2003 01:31:03 -0700
From: "David Oswald" <spamblock@junkmail.com>
Subject: Re: Return value of chomp, with alternate value in $/
Message-Id: <vj6o87l1t5bne6@corp.supernews.com>
"Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de> wrote in message
news:bgvms6$phn$1@nets3.rz.RWTH-Aachen.DE...
<snip>
> It's the question how people intuitively interpretate the first
> paragraph in the docs. I'd probably also assume it would chop off all
> occurances of $/ from a string on casual reading. Perhaps the docs could
> be clearer.
Thanks for your clarification. That was exactly what I needed.
Dave
------------------------------
Date: Fri, 08 Aug 2003 10:41:12 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Return value of chomp, with alternate value in $/
Message-Id: <bgvnnl$s5hb9$1@ID-184292.news.uni-berlin.de>
Tassilo v. Parseval wrote:
>
> $_ = "test\n\n\n";
> $/ = '';
> print chomp;
> __END__
> 3
>
> The return value of chomp is - save for the above exception -
> simply length($/) when a string has been stripped off the end.
This prints 3, though:
@lines = ("line1\n", "line2\n", "line3\n");
print chomp @lines;
But in this case, it actually chomps three strings...
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: 8 Aug 2003 08:48:00 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: Return value of chomp, with alternate value in $/
Message-Id: <bgvo40$qnl$1@nets3.rz.RWTH-Aachen.DE>
Also sprach Gunnar Hjalmarsson:
> Tassilo v. Parseval wrote:
>>
>> $_ = "test\n\n\n";
>> $/ = '';
>> print chomp;
>> __END__
>> 3
>>
>> The return value of chomp is - save for the above exception -
>> simply length($/) when a string has been stripped off the end.
>
> This prints 3, though:
>
> @lines = ("line1\n", "line2\n", "line3\n");
> print chomp @lines;
>
> But in this case, it actually chomps three strings...
Ah, right, yes, when passed a list. I wonder whether I am the only one
who finds chomp's return value rather useless. The only good thing about
is that it can be used as a boolean.
Tassilo
--
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval
------------------------------
Date: Thu, 7 Aug 2003 22:21:08 -0400
From: "Matt Garrish" <matthew.garrish@sympatico.ca>
Subject: Re: ssh and Perl
Message-Id: <jODYa.4533$_a4.844466@news20.bellglobal.com>
"Gunter Schelfhout" <nospam@please.com> wrote in message
news:VjtYa.53522$F92.5720@afrodite.telenet-ops.be...
>
> I'm also believing that there are some idiots out there who like bashing.
>
There are a few people here who could stand to read something other than the
perldocs. A little philosophy might help them realize that there is no such
thing as a Perl question. And one of those glossy magazines from the top
rack might do wonders for their pent-up frustrations...
Matt
------------------------------
Date: 8 Aug 2003 02:24:47 -0700
From: magelord@t-online.de (Math55)
Subject: Submit tabulator to console and get output?
Message-Id: <a2b8188a.0308080124.6d61965e@posting.google.com>
hello, is is possible to submit the tab press to a the console?
i have aperl program and when the user presses tab i want to send the
tab and the users input to the console. like this:
input from user: /v
this should be send: /v tab
output from concoloe: /var
this way i want to build an auto completion. is this somehow possible?
THANKS
------------------------------
Date: 7 Aug 2003 23:53:52 -0700
From: schaltung@hotmail.com (Schaltung)
Subject: Re: Variables Definition File
Message-Id: <1b56a114.0308072253.2acbab6c@posting.google.com>
thanks Shawn, 'do' works great.
I get the following warning, but it works.
Name "main::VARIABLE_NAME" used only once: possible typo at ./run.pl line 62.
a. moreno
Shawn Corey <shawn@magma.ca> wrote in message news:<Hb-dnX8fg456v62iXTWJhg@magma.ca>...
> Hi,
>
> perldoc -f do
>
> This is similar to require but require loads the file once, do does it
> very time the statement is encountered.
>
------------------------------
Date: Sat, 19 Jul 2003 01:59:56 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re:
Message-Id: <3F18A600.3040306@rochester.rr.com>
Ron wrote:
> Tried this code get a server 500 error.
>
> Anyone know what's wrong with it?
>
> if $DayName eq "Select a Day" or $RouteName eq "Select A Route") {
(---^
> dienice("Please use the back button on your browser to fill out the Day
> & Route fields.");
> }
...
> Ron
...
--
Bob Walton
------------------------------
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 5333
***************************************