[25036] in Perl-Users-Digest
Perl-Users Digest, Issue: 7286 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Oct 22 09:07:09 2004
Date: Fri, 22 Oct 2004 06: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, 22 Oct 2004 Volume: 10 Number: 7286
Today's topics:
Re: case INsensitive regular expressions (Vijai Kalyan)
Re: deciphering emails in PERL <bik.mido@tiscalinet.it>
Re: deciphering emails in PERL <bik.mido@tiscalinet.it>
Re: deciphering emails in PERL <bik.mido@tiscalinet.it>
Re: deciphering emails in PERL <tadmc@augustmail.com>
Re: fatalsToBrowser <noreply@gunnar.cc>
Guestbook hacked? <no@spam.please>
Re: Guestbook hacked? (Anno Siegel)
Re: Guestbook hacked? <tadmc@augustmail.com>
Re: Guestbook hacked? <noreply@gunnar.cc>
Re: How to insert new lines in string? <abigail@abigail.nl>
Re: How to insert new lines in string? (Anno Siegel)
Re: options to shrink-wrap a perl script <tadmc@augustmail.com>
Re: ping net pop3 (Anno Siegel)
Re: ping net pop3 <tadmc@augustmail.com>
Re: ping net pop3 <1usa@llenroc.ude.invalid>
Posting Guidelines for comp.lang.perl.misc ($Revision: tadmc@augustmail.com
Re: printing to web browser <flavell@ph.gla.ac.uk>
Re: printing to web browser <tadmc@augustmail.com>
Re: regex to clean path <bik.mido@tiscalinet.it>
Re: regex to clean path <bik.mido@tiscalinet.it>
Re: regex to clean path <tadmc@augustmail.com>
Understanding of *$self <jim.mozley@exponential-e.com>
Re: Understanding of *$self (Anno Siegel)
Re: Understanding of *$self <jim.mozley@exponential-e.com>
Re: Understanding of *$self (Anno Siegel)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 22 Oct 2004 01:47:42 -0700
From: vijai.kalyan@gmail.com (Vijai Kalyan)
Subject: Re: case INsensitive regular expressions
Message-Id: <18b36e50.0410220047.139168b@posting.google.com>
maurof78@aol.com (sabinosa) wrote in message news:<e2d435fa.0410210905.14d25ea9@posting.google.com>...
> Hi everyone,
> I am working with a RegularExpressionValidator in Visual Studio.NET.
> I would like to define a custom regular expression that ignores the
> letter case and therefore is case INsensitive. I have seen that the
> syntax might be something like "(?i)" or "/i". However, when I try to
> use that as part of my regular expression (ex. (?i)^(CSV|ZIP|TXT)$)
> the result is a javascript error. The error says: "Syntax error in
> regular expression"
> (^(CSV|ZIP|TXT)$/i does not work)
>
> Any idea what I am doing wrong? Thanks in advance for your responses!
(Javascript question in Javascript related newsgroup might get you more help.)
Simplest (and possibly the worst!) solution:
i. Convert your input into UPPERCASE. In c-talk:
int x=0;
static char s[INPUT_BUF_SIZE];
memset(s,'\x0',INPUT_BUF_SIZE);
strncpy(s,input,INPUT_BUF_SIZE];
for(; x != '\x0' && x < INPUT_BUF_SIZE ; toupper(s[x]), ++x);
ii. Check if 's' above matches.
iii. toupper is a macro, so this costs you time linear to size of your input.
BTW,
------------------------------
[>] RegExp Syntax
var myRegExp = /pattern/[switch]
In a Regular Expression /pattern/ is a Regular Expression and [switch]
(optional) indicates the mode in which the Regular Expression is to be used:
"i" - ignore case,
"g" - global search,
"gi" - global search + ignore case (case-insensitive).
After a Regular Expression is created, it is passed to a Method of a String
Object.
------------------------------
so why not try,
var input = /^(CSV|ZIP|TXT)$/[i]
?
The answer to your question (finally) is:
google case insensitive pattern matching in javascript
:)
hth,
------
vijai.
------------------------------
Date: Fri, 22 Oct 2004 13:48:11 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: deciphering emails in PERL
Message-Id: <58shn0lrrebmkf4mn0kvqbp2d340ibtu9j@4ax.com>
On Thu, 21 Oct 2004 22:14:02 -0400, "daniel kaplan"
<nospam@nospam.com> wrote:
>i reposted this, my OE never picked up my post, but now your reply showed
>up...weird
Weird (that you find it weird!) That's how usenet is supposed to work.
You'll have to live with it...
Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
.'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
------------------------------
Date: Fri, 22 Oct 2004 13:48:11 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: deciphering emails in PERL
Message-Id: <p9shn01k70st44hdavt15p88vq42qanffb@4ax.com>
On Thu, 21 Oct 2004 20:54:22 -0400, "daniel kaplan"
<nospam@nospam.com> wrote:
>i have to think, with the vast exapnse of lib. i see out there for PERL,
>someone has written something? no?
Out of curiosity: I know what "PERL" is, precisely either "Perl" or
"perl", but misspelled. But what is an "exapnse" supposed to be?
Sorry, I'm not a native English speaker...
Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
.'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
------------------------------
Date: Fri, 22 Oct 2004 13:48:12 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: deciphering emails in PERL
Message-Id: <0dshn0511kqj19nlbql6ki2iosftrfd6ue@4ax.com>
On Fri, 22 Oct 2004 00:34:57 -0400, "daniel kaplan"
<nospam@nospam.com> wrote:
>i really have bneen programming for years, C and Win32...but no C++ and no
>PERL
Well, for one thing "C" can be written either all uppercase or with
only the first letter capitalized. Perl can't!
;-)
Jokes apart, due to the nature of USENET you've been bitten in the
neck as of the other message you posted, it is usually considered
sensible to *properly* quote the relevant parts of the article you're
following up to.
Not quoting and top-posting are heavily disliked here, as in most
technical groups. So like it or not, you'd better adhere to the
posting requirements about which there's a general consensus here if
you want to receive constructive help. Most people tend to recognize
their naturality and usefulness after some time practicing them.
Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
.'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
------------------------------
Date: Fri, 22 Oct 2004 07:39:22 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: deciphering emails in PERL
Message-Id: <slrncnhvrq.ad7.tadmc@magna.augustmail.com>
Michele Dondi <bik.mido@tiscalinet.it> wrote:
> On Thu, 21 Oct 2004 20:54:22 -0400, "daniel kaplan"
><nospam@nospam.com> wrote:
>
>>i have to think, with the vast exapnse of lib. i see out there for PERL,
>>someone has written something? no?
> But what is an "exapnse" supposed to be?
> Sorry, I'm not a native English speaker...
I expect he meant "expanse".
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Fri, 22 Oct 2004 14:16:05 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: fatalsToBrowser
Message-Id: <2tsc81F24b6d7U1@uni-berlin.de>
David Efflandt wrote:
> daniel kaplan wrote:
>>
>> use CGI::Carp qw(fatalsToBrowser);
>
> That only traps errors while the script is running. It will not tell
> you precompile errors like bad shebang line, missing semicolon,
> mismatched brackets, quotes, etc.
Not true. It traps compilation errors occurring after the
use CGI::Carp qw(fatalsToBrowser);
line. So except for a bad shebang line, it traps the other things you
mentioned just fine.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Fri, 22 Oct 2004 00:13:11 +0200
From: J.Postma <no@spam.please>
Subject: Guestbook hacked?
Message-Id: <6scgn0pl7ohkjdq74tuk6munfqis6mr1ui@4ax.com>
A few times a week I find strange (spam) messages in my guestbook.
Are the spammers realy visit my site a few times a week, fill in the
form, and post a reaction in the guestbook or do the have a trick to
automaticly fill my guestbook???
I am using the perl script of Matt version 2.3.1
Thanks,
J.Postma
------------------------------
Date: 22 Oct 2004 09:24:10 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Guestbook hacked?
Message-Id: <clajjq$70m$3@mamenchi.zrz.TU-Berlin.DE>
J.Postma <no@spam.please> wrote in comp.lang.perl.misc:
> A few times a week I find strange (spam) messages in my guestbook.
> Are the spammers realy visit my site a few times a week, fill in the
> form, and post a reaction in the guestbook or do the have a trick to
> automaticly fill my guestbook???
What makes you think we know what your spammer(s) are doing?
> I am using the perl script of Matt version 2.3.1
Matt's scripts are infamous for their security holes. You can be
glad someone hasn't erased the whole guestbook and more.
Anno
------------------------------
Date: Fri, 22 Oct 2004 07:07:04 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Guestbook hacked?
Message-Id: <slrncnhtv8.a69.tadmc@magna.augustmail.com>
J.Postma <no@spam.please> wrote:
> I am using the perl script of Matt version 2.3.1
That is the cause of your problem.
(it is crap code, use something else)
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Fri, 22 Oct 2004 14:40:53 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Guestbook hacked?
Message-Id: <2tsdmsF231d61U1@uni-berlin.de>
J.Postma wrote:
> A few times a week I find strange (spam) messages in my guestbook.
> Are the spammers realy visit my site a few times a week, fill in the
> form, and post a reaction in the guestbook or do the have a trick to
> automaticly fill my guestbook???
Hard to tell.
Recently I had the same problem with my guestbook, so I put this
.htaccess file in the directory with the submit page:
# Stopping spamming idiot
Deny from 83.170.250.32
Deny from 195.38.127.26
Deny from 200.242.61.26
That did the trick for me (or the spammer got tired).
> I am using the perl script of Matt version 2.3.1
Matt's scripts have a bad reputation because of security holes, but
personally I don't think the problem has anything to do with that.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: 22 Oct 2004 07:16:30 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: How to insert new lines in string?
Message-Id: <slrncnhcue.3ac.abigail@alexandra.abigail.nl>
roach (joey01@cfl.rr.com) wrote on MMMMLXIX September MCMXCIII in
<URL:news:peXdd.19$Mc.18@tornado.tampabay.rr.com>:
`` Hi
`` I have a file that is 1 line but 1000's of characters long.
`` How can I insert a newline every nth character? or would sed be better for
`` this?
Untested:
perl -i -wle '$\ = \80; print "$_\n" while <>' your_file
Change 80 to 'n'.
Abigail
--
perl -MLWP::UserAgent -MHTML::TreeBuilder -MHTML::FormatText -wle'print +(
HTML::FormatText -> new -> format (HTML::TreeBuilder -> new -> parse (
LWP::UserAgent -> new -> request (HTTP::Request -> new ("GET",
"http://work.ucsd.edu:5141/cgi-bin/http_webster?isindex=perl")) -> content))
=~ /(.*\))[-\s]+Addition/s) [0]'
------------------------------
Date: 22 Oct 2004 08:46:05 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: How to insert new lines in string?
Message-Id: <clahcd$70m$2@mamenchi.zrz.TU-Berlin.DE>
roach <joey01@cfl.rr.com> wrote in comp.lang.perl.misc:
> Hi
> I have a file that is 1 line but 1000's of characters long.
> How can I insert a newline every nth character? or would sed be better for
> this?
my $n = 30;
substr( $long, $n*$_, 0, "\n") for reverse 1 .. length( $long)/$n;
Anno
------------------------------
Date: Fri, 22 Oct 2004 06:19:56 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: options to shrink-wrap a perl script
Message-Id: <slrncnhr6s.a69.tadmc@magna.augustmail.com>
Rocco Caputo <troc@pobox.com> wrote:
> On 21 Oct 2004 07:25:06 -0700, dan baker wrote:
>> Tad McClellan <tadmc@augustmail.com> wrote in message
>>> > didn't your mother ever teach you to keep your mouth shut if you dont
>>> > have anything nice (or helpful) to say?
>>>
>>> Where is the nice or helpful part in *your* followup, huh?
>>
>> in that I am attempting to clue you guys into acceptable public
>> behavior. You might get a lot further in life and have more friends.
>
> It's a rude tourist that lectures the natives on their behavior.
I like that analogy!
> We just don't agree.
The OP whined because Abigail did not spend 5 seconds more in
answering the question, causing the OP to spend 5 seconds of
his own time googling.
ie. He wanted Abigail to do his work for him.
This is a person qualified to lecture on how to win friends and
influence people? I think not.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 22 Oct 2004 08:24:58 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: ping net pop3
Message-Id: <clag4q$70m$1@mamenchi.zrz.TU-Berlin.DE>
daniel kaplan <nospam@nospam.com> wrote in comp.lang.perl.misc:
[no attribution, no context]
> A. Sinan Unur,
>
> honestly, you must be one of the rudest people i have ever encountered on a
> newsgroup. maybe the times have changed and all that, but whenever i looked
> for question i could answer (C related, obviosuly not Perl)....i would just
> answer the question to just help someone out. that's it. i didn't care if
You have never posted with any regularity in a major newsgroup, as
evidenced by your posting style. Don't make things up.
> it was a homework cheater, or a guy on deadline at 2am, who's brain was just
> in some stuck mode. in fact, i've never met a programmer who didn't ask
> questions that were stupid (to everyone else), but we help each other out,
> without judging.
That's fine. We do things differently here. Get used to it.
[snip]
Anno
------------------------------
Date: Fri, 22 Oct 2004 07:05:57 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: ping net pop3
Message-Id: <slrncnhtt5.a69.tadmc@magna.augustmail.com>
daniel kaplan <nospam@nospam.com> wrote:
> honestly, you must be one of the rudest people i have ever encountered on a
> newsgroup.
You do not have much experience in newsgroups.
We can tell from your use of an ineffective followup style.
> sorry to make this so public, but really, if you think i am just asking
> stupid questions, or am not worth the time, then please, just don't bother
> with my posts...
You got it bubba!
*plonk*
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 22 Oct 2004 12:24:00 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: ping net pop3
Message-Id: <Xns958A5573B9657asu1cornelledu@132.236.56.8>
"daniel kaplan" <nospam@nospam.com> wrote in
news:1098423575.840122@nntp.acecape.com:
> A. Sinan Unur,
>
> honestly, you must be one of the rudest people i have ever encountered
> on a newsgroup.
...
> we help each other out, without judging.
Yes, you are an infinitely better person than I am.
> and for the record, i would be willing to say, that you've had to ask
> questions in your moments where everyone else went, "is he kidding?"
The issue is not the difficulty level of your questions. It is the way
you ask them and then the way you react to responses. That is why you owe
it yourself to read the posting guidelines and avoid the mistakes
mentioned there when posting.
> as i said in one of my posts, am an old time C programmer,
That is no excuse.
> sorry to make this so public, but really, if you think i am just
> asking stupid questions, or am not worth the time, then please, just
> don't bother with my posts...
Every post you make where you snip all context, lose attributions, don't
use strict, don't use warnings, don't look at the FAQ list etc sets an
example for every other potential poster out there, creating the
impression that it is OK to post in your style.
Your questions are nobody's but yours, enjoy.
--
A. Sinan Unur
1usa@llenroc.ude.invalid
(remove '.invalid' and reverse each component for email address)
------------------------------
Date: 22 Oct 2004 07:22:28 GMT
From: tadmc@augustmail.com
Subject: Posting Guidelines for comp.lang.perl.misc ($Revision: 1.5 $)
Message-Id: <4178b533$0$6880$8b463f8a@news.nationwide.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, 22 Oct 2004 08:24:17 +0100
From: "Alan J. Flavell" <flavell@ph.gla.ac.uk>
Subject: Re: printing to web browser
Message-Id: <Pine.LNX.4.61.0410220814130.4003@ppepc56.ph.gla.ac.uk>
On Thu, 21 Oct 2004, Jim Gibson wrote:
> Print stuff between <pre> and </pre> tags.
Merely clamping material in a <pre> element does not, in general,
turn it into plain text. You'd need to escape the HTML-significant
characters in it (escapeHTML() in CGI.pm) too.
If you've no other reason for sending content-type text/html then I'd
still say that sending text/plain is the straightforward solution.
This of course has nothing directly to do with Perl. It would be the
same principle in any scripting language.
------------------------------
Date: Fri, 22 Oct 2004 06:15:30 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: printing to web browser
Message-Id: <slrncnhqui.a69.tadmc@magna.augustmail.com>
Paul Robson <autismuk@autismuk.freeserve.co.uk> wrote:
> On Thu, 21 Oct 2004 15:24:05 -0700, Jim Gibson wrote:
>
>> In article <1098395030.248283@nntp.acecape.com>, daniel kaplan
>> <nospam@nospam.com> wrote:
>>
>>> still new to PERL, anyway write now i do all OUTPUTTING to the web browser
>>> with:
>>
>> Experienced Perl programmers don't use all CAPS.
>
> Does <stdin> work then ?
What happened when you tried it? (yes, it does work)
Experienced Perl programmers don't spell it "PERL", because
it is not an acronym.
If you call it PERL then you do not know the secret handshake.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Fri, 22 Oct 2004 13:48:08 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: regex to clean path
Message-Id: <hsphn0pelcljn4uopejag0ocht49s1v41o@4ax.com>
On Fri, 22 Oct 2004 00:19:52 -0500, parv <parv_@yahooWhereElse.com>
wrote:
>> Inside the print(), i want to keep the quoted text to minimum
>
>Forgot to add that using printf() allows to list all the variables
>in one place, instead of being interspersed w/ print()[0], thus
>variables are much easily locatable & changeable.
Well, it is obvious that readability is not an absolute concept, and
of course an experienced C programmer will find the syntax/semantics
of printf() very intuitive. However one should not forget that most of
its conversions are there because C is a low level enough language to
require you to take care of them whereas Perl is high level enough to
do that for you and is smart enough to usually do it right too!
Personally I'd find something along this lines much more readable:
print 'Unordered: ', make_path(@paths), "\n\n";
print 'Ordered: ', make_path_ordered(@paths), "\n";
in fact it clearly separates the two things that are being printed.
And taking into account the context, of course efficiency matters as
those suggested by Uri are negligible.
OTOH I don't see how "listing all the variables in one place" would
make the whole lot more manageable.
Also, it is sensible to (C<local>ly) set $\ to "\n" or, for short
enough (one's mileage may vary, though!) scripts, to use -l. So that
probably I'd have
print 'Unordered: ', make_path @paths;
print 'Ordered: ', make_path_ordered @paths;
or, if I wanted exactly your output,
print 'Unordered: ', make_path @paths;
print '';
print 'Ordered: ', make_path_ordered @paths;
Or an alternative may be to use an HERE doc:
print <<"EOT"; # In this case @{[ ... ]} does make sense!
Unordered: @{[ make_path @paths ]}
Ordered: @{[ make_path_ordered @paths ]}
EOT
Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
.'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
------------------------------
Date: Fri, 22 Oct 2004 13:48:09 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: regex to clean path
Message-Id: <hjqhn0hn9c3sevnu6s7e3i096kr96diffe@4ax.com>
On Fri, 22 Oct 2004 00:12:41 -0500, parv <parv_@yahooWhereElse.com>
wrote:
>>> # Make path string from given list of array references or
>>> # strings
>> ^^^^^^^^^^^^^^^^
>> Why, if they're all coming from @ARGV by means of split()ting?
>
>Well, @ARGV is just one source of paths *in OP's case* & in the
>program posted.
AFAICT the OP (see <10n86m9jvqce312@corp.supernews.com>) was asking
for *a regex* to remove duplicate entries from "a path" (to be
intended as ':' separated string). Also he talked about "PATH
variable", but it didn't specify how the program would have been
supposed to work on it.
Leaving the OP aside, it seems to me that in *your* program paths are
input only through @ARGV. But then I explicitly asked you if I were
missing something. So, am I missing something?
If so, then I still see no benefit of mixing strings and arrayrefs all
the way. IMHO it would be best to uniform the data at an early stage.
>>> my %uniq;
>>> { my $i = 0;
>>> map $uniq{$_} = !exists $uniq{$_} ? $i++ : $uniq{$_}
>>> , @{ split_path( [ @paths ]) };
>>> }
>>
>> All I can say is that it is a reasonably working but definitely
>> clumsy workaround for not having chosen the "correct" algorithm in
[snip]
>Care to explain how above algorithm is not "correct"? Clumsy, i
>agree (in comparison to [0]).
It is not "correct" in that it is *overly* clumsy. For otherwise I
would have written that it is not correct, not that it is not
"correct"... ;-)
The point is that the "unordered algorihtm" would yield different
results even across different runs with a recent perl. So if there's a
compact, self-evident, self-explanatory alternative that as an added
bonus even preserves order, then I'd tend to identify *that* with the
"correct" one.
>Somebody tell me this: Is there a guarantee that grep() will always
>give the filtered output in the order in which input was received?
I'm not sure I can grasp the sense of your words ("Somebody tell me
this"). If you're asking: "is there a guarantee that grep() will
always give the filtered output in the order in which input was
received?", then the answer is: "yes". See 'perldoc -f grep'
>>> sub delimit_path
>>> { my ($paths) = @_;
>>> return \join ':' , @{$paths};
>>> }
>>
>> Why?!?
>
>To delimit the path list w/ the possibility of alternate delimiter.
"Why" was referred to the quoted portion of the text underlined with
carets. However I hardly see how a sub that is hardly something more
than a wrapper around join() can improve the manageability of using an
alternate delimiter. Had you used something like
sub delimit_path {
my ($delim, $paths)=@_;
join $delim, @{$paths};
}
it would have made much more sense. But then I would have had
something like
use constant DELIM => ':';
at the top of my script.
>(What is with "?!?" anyway? Expression of high annoyance?)
Well, to some extent... but I'd rather say educated amazement! No
offence intended, of course...
>And, thanks, generally, for your comments.
Nice to see you didn't take them as offensive...
Michele
------------------------------
Date: Fri, 22 Oct 2004 06:26:22 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: regex to clean path
Message-Id: <slrncnhriu.a69.tadmc@magna.augustmail.com>
parv <parv_@yahooWhereElse.com> wrote:
> Somebody tell me this: Is there a guarantee that grep() will always
> give the filtered output in the order in which input was received?
No.
grep() is guaranteed to give the filtered output in the order in which
the original list was provided though.
ie. the "list" may not be "input".
>> delete $hash->{$_} unless -d $_ && -x $_;
>> But then C<$_> is not necessary and can be omitted
>
> Thanks for the reminder about '_';
The reminder was about $_, not about _, they are not the same thing .
The above will execute faster if you *do* use _ :
delete $hash->{$_} unless -d $_ && -x _;
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Fri, 22 Oct 2004 11:59:07 +0100
From: Jim Mozley <jim.mozley@exponential-e.com>
Subject: Understanding of *$self
Message-Id: <2ts7e1F226h5oU1@uni-berlin.de>
I am writing a sub class of Net::Telnet that is specific for our
companies network devices. I have looked at Net::Telnet::Cisco as an
example of this and have what I want working. However, I have done this
by copying what is done in that module but I don't understand it! As
this is a bad thing I am seeking understanding of what it does and why.
In the Net::Telnet::Cisco new method...
$self = $class->SUPER::new(@_) or return;
*$self->{net_telnet_cisco} = {
<snip hash key => values>
};
And in order to access the hash in other methods...
$ {*$self}{net_telnet_cisco}{last_cmd}
(^ the space above is in the module code)
Can someone please explain the use of *$self in creating the object
instance and retrieving it's attributes? I'm assuming this is something
to do with filehandles and having to use typeglobs?
Jim Mozley
------------------------------
Date: 22 Oct 2004 11:15:20 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Understanding of *$self
Message-Id: <claq48$ei3$1@mamenchi.zrz.TU-Berlin.DE>
Jim Mozley <jim.mozley@exponential-e.com> wrote in comp.lang.perl.misc:
> I am writing a sub class of Net::Telnet that is specific for our
> companies network devices. I have looked at Net::Telnet::Cisco as an
> example of this and have what I want working. However, I have done this
> by copying what is done in that module but I don't understand it! As
> this is a bad thing I am seeking understanding of what it does and why.
>
> In the Net::Telnet::Cisco new method...
>
> $self = $class->SUPER::new(@_) or return;
> *$self->{net_telnet_cisco} = {
> <snip hash key => values>
> };
>
> And in order to access the hash in other methods...
>
> $ {*$self}{net_telnet_cisco}{last_cmd}
>
> (^ the space above is in the module code)
>
> Can someone please explain the use of *$self in creating the object
> instance and retrieving it's attributes? I'm assuming this is something
> to do with filehandles and having to use typeglobs?
This is explained in perldata, section "Typeglobs and Filehandles".
Anno
------------------------------
Date: Fri, 22 Oct 2004 13:17:38 +0100
From: Jim Mozley <jim.mozley@exponential-e.com>
Subject: Re: Understanding of *$self
Message-Id: <2tsc17F234lsgU1@uni-berlin.de>
Anno Siegel wrote:
> This is explained in perldata, section "Typeglobs and Filehandles".
I had looked at this before posting and have just looked again, but I
still don't understand I'm afraid.
I can see that if I use...
*$self->{hash_ref} = $hash_ref;
in my new method and...
my $hash_ref = ${*$self}{hash_ref};
for ( sort keys %$hash_ref ) {
print "$_ ", $hash_ref->{ $_ }, "\n";
}
to access the data it works.
But if I change this to...
$self->{hash_ref} = $hash_ref; # in new
my $hash_ref = $self->{hash_ref}; # in accessor
I get the error:
"Not a HASH reference at.."
Using Data::Dumper on my instance variable I get...
$VAR1 = bless( \*Symbol::GEN0, 'Ee::Net::Device' );
So I assume that as the error tells me my instance is not a ref to a
hash. That's where my understanding ends at the moment.
Jim Mozley
------------------------------
Date: 22 Oct 2004 12:28:55 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Understanding of *$self
Message-Id: <claue7$gde$1@mamenchi.zrz.TU-Berlin.DE>
Jim Mozley <jim.mozley@exponential-e.com> wrote in comp.lang.perl.misc:
> Anno Siegel wrote:
>
> > This is explained in perldata, section "Typeglobs and Filehandles".
>
> I had looked at this before posting and have just looked again, but I
> still don't understand I'm afraid.
>
> I can see that if I use...
>
> *$self->{hash_ref} = $hash_ref;
>
> in my new method and...
>
> my $hash_ref = ${*$self}{hash_ref};
> for ( sort keys %$hash_ref ) {
> print "$_ ", $hash_ref->{ $_ }, "\n";
> }
>
> to access the data it works.
>
> But if I change this to...
>
> $self->{hash_ref} = $hash_ref; # in new
> my $hash_ref = $self->{hash_ref}; # in accessor
Why would you want to make that change? It doesn't make sense.
> I get the error:
>
> "Not a HASH reference at.."
Of course. Your objects are globs, so you must access them as
globs. You'd see the same error if they were scalars or arrays or
what-have-you.
> Using Data::Dumper on my instance variable I get...
>
> $VAR1 = bless( \*Symbol::GEN0, 'Ee::Net::Device' );
>
> So I assume that as the error tells me my instance is not a ref to a
> hash. That's where my understanding ends at the moment.
Then ask concrete questions. The complete explanation is in the
docs. If all you say is "I don't get it", there is little we can
do.
Anno
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc. For subscription or unsubscription requests, send
#the single line:
#
# subscribe perl-users
#or:
# unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.
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 7286
***************************************