[29643] in Perl-Users-Digest
Perl-Users Digest, Issue: 887 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Sep 28 06:09:42 2007
Date: Fri, 28 Sep 2007 03:09: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, 28 Sep 2007 Volume: 11 Number: 887
Today's topics:
Re: FAQ 4.51 How do I permute N elements of a list? <bik.mido@tiscalinet.it>
How to get some specify lines in a block of a file? <jdxyw2004@gmail.com>
Re: Invalid top directory at d:\perl\lib\file\find.pm l <ninad.29@gmail.com>
new CPAN modules on Fri Sep 28 2007 (Randal Schwartz)
Posting Guidelines for comp.lang.perl.misc ($Revision: tadmc@seesig.invalid
Re: Regex confusion... <ben@morrow.me.uk>
Re: Regex confusion... sln@netherlands.co
Re: Regex confusion... <ced@blv-sam-01.ca.boeing.com>
Re: Regex confusion... <abigail@abigail.be>
Re: regexp for bracket expression sln@netherlands.co
Re: Small doubt in perl <anilkumar.iitm@gmail.com>
Re: Small doubt in perl <anilkumar.iitm@gmail.com>
Re: string concatentation vs. interpolation: which one <rihad@mail.ru>
Re: why are references so slow ? sln@netherlands.co
Re: why are references so slow ? sln@netherlands.co
Re: why are references so slow ? <elvis-85363@notatla.org.uk>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 28 Sep 2007 12:06:21 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: FAQ 4.51 How do I permute N elements of a list?
Message-Id: <vekpf35i77k5407524du3fkup5rgdje32n@4ax.com>
On Wed, 19 Sep 2007 09:09:45 -0700, brian d foy
<brian.d.foy@gmail.com> wrote:
>> If there's some interest in this I may try to concoct a patch to the
>> faq entry.
>
>Yes, please do. You can post it here and I should find it.
Here it is, HTH:
: --- perlfaq4.pod Tue Jan 03 08:01:16 2006
: +++ perlfaq4-new.pod Fri Sep 28 12:02:06 2007
: @@ -1552,6 +1552,19 @@
: Algorithm::Permute::permute {
: print "next permutation: (@array)\n";
: } @array;
: +
: +The Algorithm::Loops module also provides the C<NextPermute> and
: +C<NextPermuteNum> functions which efficiently find all unique permutations
: +of an array, even if it contains duplicate values, modifying it in-place:
: +if its elements are in reverse-sorted order then the array is reversed,
: +making it sorted, and a false value is returned; otherwise the next
: +permutation is returned.
: +
: +C<NextPermute> uses string order and C<NextPermuteNum> numeric order, so
: +one could enumerate all the permutations of C<0..9> like thus:
: +
: + my @list= 0..9;
: + do { print "@list\n" } while NextPermuteNum @list;
:
: Here's a little program that generates all permutations of
: all the words on each line of input. The algorithm embodied
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, 28 Sep 2007 08:19:39 -0000
From: dolphin <jdxyw2004@gmail.com>
Subject: How to get some specify lines in a block of a file?
Message-Id: <1190967579.248901.77780@r29g2000hsg.googlegroups.com>
Hi Eveyone
I have a question now,How to get some specify lines in a block of a
file?
For example , I have a big file just like below
................
.............
..........
..........
.........
ABC
{
.................
...............
................
...............
..............
}
..............
.................
I just want to get some specify lines in the block of ABC{ }.
What should I do?
------------------------------
Date: Fri, 28 Sep 2007 09:12:18 -0000
From: Perler <ninad.29@gmail.com>
Subject: Re: Invalid top directory at d:\perl\lib\file\find.pm line 562
Message-Id: <1190970738.314331.193190@o80g2000hse.googlegroups.com>
On Sep 27, 2:45 pm, use...@DavidFilmer.com wrote:
> On Sep 27, 1:29 am, ninad...@gmail.com (Perler) wrote:
>
> > [a multipost]
>
> Please don't multipost.
>
> --
> The best way to get a good answer is to ask a good question.
> David Filmer (http://DavidFilmer.com)
I am really sorry for multiposting but i was getting an error of mail
delievery failure many times.
Wont happen again.
------------------------------
Date: Fri, 28 Sep 2007 04:42:14 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Fri Sep 28 2007
Message-Id: <Jp2AEE.zy8@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.
Apache2-Filter-Minifier-JavaScript-1.03_01
http://search.cpan.org/~gtermars/Apache2-Filter-Minifier-JavaScript-1.03_01/
JS minifying output filter
----
Atompub-0.1.6
http://search.cpan.org/~takeru/Atompub-0.1.6/
Atom Publishing Protocol implementation
----
Atompub-0.1.7
http://search.cpan.org/~takeru/Atompub-0.1.7/
Atom Publishing Protocol implementation
----
Audio-M4P-0.38
http://search.cpan.org/~billh/Audio-M4P-0.38/
Perl QuickTime / MP4 / iTunes Music Store audio / video file tools
----
BSD-Process-0.03
http://search.cpan.org/~dland/BSD-Process-0.03/
Information about running processes on BSD platforms
----
Bio-DOOP-DOOP-0.28
http://search.cpan.org/~tibi/Bio-DOOP-DOOP-0.28/
DOOP API main module
----
Business-PayPal-API-0.52
http://search.cpan.org/~scottw/Business-PayPal-API-0.52/
PayPal API
----
CPAN-1.9201
http://search.cpan.org/~andk/CPAN-1.9201/
query, download and build perl modules from CPAN sites
----
CPAN-Reporter-0.99_13
http://search.cpan.org/~dagolden/CPAN-Reporter-0.99_13/
Adds CPAN Testers reporting to CPAN.pm
----
CPAN-Test-Dummy-Perl5-Make-PLExit-1.00
http://search.cpan.org/~dagolden/CPAN-Test-Dummy-Perl5-Make-PLExit-1.00/
CPAN Test Dummy
----
Cairo-1.042
http://search.cpan.org/~tsch/Cairo-1.042/
Perl interface to the cairo library
----
Catalyst-Controller-Atompub-0.1.6
http://search.cpan.org/~takeru/Catalyst-Controller-Atompub-0.1.6/
A Catalyst controller for the Atom Publishing Protocol
----
Catalyst-Controller-Atompub-0.1.7
http://search.cpan.org/~takeru/Catalyst-Controller-Atompub-0.1.7/
A Catalyst controller for the Atom Publishing Protocol
----
Catalyst-Model-DBIDM-0.01
http://search.cpan.org/~cbouvi/Catalyst-Model-DBIDM-0.01/
DBIx::DataModel model class
----
Catalyst-Plugin-Alarm-0.02
http://search.cpan.org/~karman/Catalyst-Plugin-Alarm-0.02/
call an action with a timeout value
----
Class-DBI-FormTools-0.0.6
http://search.cpan.org/~djo/Class-DBI-FormTools-0.0.6/
Build forms with multiple interconnected objects.
----
ClearCase-SyncTree-0.41
http://search.cpan.org/~dsb/ClearCase-SyncTree-0.41/
Synchronize a tree of files with a tree of elements
----
Combine-3.7
http://search.cpan.org/~aardo/Combine-3.7/
----
Data-Integer-0.002
http://search.cpan.org/~zefram/Data-Integer-0.002/
details of the native integer data type
----
File-Rename-0.04
http://search.cpan.org/~rmbarker/File-Rename-0.04/
Perl extension for renaming multiple files
----
File-Stat-Moose-0.0102
http://search.cpan.org/~dexter/File-Stat-Moose-0.0102/
Status info for a file - Moose-based
----
Games-WoW-Armory-0.0.7
http://search.cpan.org/~franckc/Games-WoW-Armory-0.0.7/
Access to the WoW Armory
----
Gungho-0.08006
http://search.cpan.org/~dmaki/Gungho-0.08006/
Yet Another High Performance Web Crawler Framework
----
HTML-Rainbow-0.05
http://search.cpan.org/~dland/HTML-Rainbow-0.05/
Put colour into your HTML
----
HTML-Template-Filter-TT2-0.01
http://search.cpan.org/~saper/HTML-Template-Filter-TT2-0.01/
Template Toolkit 2 syntax for HTML::Template
----
HTML-WikiConverter-Confluence-0.01
http://search.cpan.org/~diberri/HTML-WikiConverter-Confluence-0.01/
Convert HTML to Confluence markup
----
IPC-Signal-Force-0.002
http://search.cpan.org/~zefram/IPC-Signal-Force-0.002/
force default handling of a signal
----
KeyedMutex-0.01
http://search.cpan.org/~kazuho/KeyedMutex-0.01/
An interprocess keyed mutex
----
LWP-Protocol-https-SocksChain-1.4
http://search.cpan.org/~gosha/LWP-Protocol-https-SocksChain-1.4/
Speak HTTPs through Net::SC
----
LWP-Protocol-https-SocksChain10-1.3
http://search.cpan.org/~gosha/LWP-Protocol-https-SocksChain10-1.3/
Speak HTTPs through Net::SC
----
Lucene-0.18
http://search.cpan.org/~tbusch/Lucene-0.18/
API to the C++ port of the Lucene search engine
----
MIME-tools-5.423
http://search.cpan.org/~doneill/MIME-tools-5.423/
----
Mail-Karmasphere-Client-2.13
http://search.cpan.org/~shevek/Mail-Karmasphere-Client-2.13/
Client for Karmasphere Reputation Server
----
MogileFS-Plugin-MultiHook-0.01
http://search.cpan.org/~zigorou/MogileFS-Plugin-MultiHook-0.01/
MogileFS plugins for using multiple hooks
----
Moose-0.26
http://search.cpan.org/~stevan/Moose-0.26/
A complete modern object system for Perl 5
----
MooseX-GlobRef-Object-0.01
http://search.cpan.org/~dexter/MooseX-GlobRef-Object-0.01/
Store a Moose object in glob reference
----
MooseX-Storage-0.07
http://search.cpan.org/~stevan/MooseX-Storage-0.07/
An serialization framework for Moose classes
----
Net-Jaiku-0.0500
http://search.cpan.org/~rickm/Net-Jaiku-0.0500/
A perl interface to jaiku.com's API
----
Net-Jaiku-0.0501
http://search.cpan.org/~rickm/Net-Jaiku-0.0501/
A perl interface to jaiku.com's API
----
Net-Social-Service-Twitter-0.1
http://search.cpan.org/~simonw/Net-Social-Service-Twitter-0.1/
handle friends from Twitter for Net::Social
----
Parse-Eyapp-1.081
http://search.cpan.org/~casiano/Parse-Eyapp-1.081/
Extensions for Parse::Yapp
----
PlotCalendar-1.4
http://search.cpan.org/~ajackson/PlotCalendar-1.4/
----
Test-Moose-MockObjectCompile-0.2.1
http://search.cpan.org/~zaphar/Test-Moose-MockObjectCompile-0.2.1/
A Module to help when testing compile time Moose
----
Test-Unit-Lite-0.0402
http://search.cpan.org/~dexter/Test-Unit-Lite-0.0402/
Unit testing without external dependencies
----
TinyAuth-0.94
http://search.cpan.org/~adamk/TinyAuth-0.94/
Extremely light-weight web-based authentication manager
----
Tripletail-0.35
http://search.cpan.org/~hio/Tripletail-0.35/
Tripletail, Framework for Japanese Web Application
----
Tripletail-0.36
http://search.cpan.org/~hio/Tripletail-0.36/
Tripletail, Framework for Japanese Web Application
----
WWW-Bugzilla-1.2
http://search.cpan.org/~bmc/WWW-Bugzilla-1.2/
Handles submission/update of bugzilla bugs via WWW::Mechanize.
----
YAML-0.66
http://search.cpan.org/~ingy/YAML-0.66/
YAML Ain't Markup Language (tm)
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: Fri, 28 Sep 2007 07:10:20 GMT
From: tadmc@seesig.invalid
Subject: Posting Guidelines for comp.lang.perl.misc ($Revision: 1.8 $)
Message-Id: <wN1Li.1765$P21.453@newssvr19.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: Fri, 28 Sep 2007 00:10:42 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Regex confusion...
Message-Id: <ispts4-lia.ln1@osiris.mauzo.dyndns.org>
Quoth guthrie <guthrie@mum.edu>:
> sorry for the beginner question, but...
>
> With this code
> my $img = "0-12345-abc";
> print " Match.1 ", (defined $img);
> print " Match.2 ", ($img =~ /\S/);
> print " Matched::", $1;
You should never use the $N variables without checking the match
succeeded. In any case, your pattern has no capturing parens, so $1 will
be empty.
Others have already noted that \S and \w only match single characters.
> The actual code I'm trying for is:
> if(defined $img and $img =~ /\S/) {
> if ($img =~ /^(\d)-(\d+)-(\w)$/)
> { my ($t, $zip, $type) = ($1, $2, $3); }
This can be simplified to
if (
my ($t, $zip, $type) =
$img =~ /^(\d)-(\d+)-(\w+)$/
) {
which avoids the need to use the $N variables altogether.
Ben
------------------------------
Date: Thu, 27 Sep 2007 18:43:01 -0700
From: sln@netherlands.co
Subject: Re: Regex confusion...
Message-Id: <fnmof355vp963ba7occdgmgm9o3pc4ht4n@4ax.com>
On Fri, 28 Sep 2007 00:10:42 +0100, Ben Morrow <ben@morrow.me.uk> wrote:
>
>Quoth guthrie <guthrie@mum.edu>:
>> sorry for the beginner question, but...
>>
>> With this code
>> my $img = "0-12345-abc";
>> print " Match.1 ", (defined $img);
>> print " Match.2 ", ($img =~ /\S/);
>> print " Matched::", $1;
>
>You should never use the $N variables without checking the match
>succeeded. In any case, your pattern has no capturing parens, so $1 will
>be empty.
>
>Others have already noted that \S and \w only match single characters.
>
>> The actual code I'm trying for is:
>> if(defined $img and $img =~ /\S/) {
>> if ($img =~ /^(\d)-(\d+)-(\w)$/)
>> { my ($t, $zip, $type) = ($1, $2, $3); }
>
>This can be simplified to
>
> if (
> my ($t, $zip, $type) =
> $img =~ /^(\d)-(\d+)-(\w+)$/
> ) {
>
>which avoids the need to use the $N variables altogether.
>
>Ben
It might be quicker to check for sucess first then do the asignment
$_ = "......";
if ( /^(\d)-(\d+)-(\w+)$/ )
{
#use $1,2,3 or asign
($t, $zip, $type) = ($1, $2, $3);
}
------------------------------
Date: Thu, 27 Sep 2007 22:04:40 -0700
From: "comp.llang.perl.moderated" <ced@blv-sam-01.ca.boeing.com>
Subject: Re: Regex confusion...
Message-Id: <1190955880.866692.228110@r29g2000hsg.googlegroups.com>
On Sep 27, 6:43 pm, s...@netherlands.co wrote:
> On Fri, 28 Sep 2007 00:10:42 +0100, Ben Morrow <b...@morrow.me.uk> wrote:
>
> ...
>
> >This can be simplified to
>
> > if (
> > my ($t, $zip, $type) =
> > $img =~ /^(\d)-(\d+)-(\w+)$/
> > ) {
>
> >which avoids the need to use the $N variables altogether.
>
> >Ben
>
> It might be quicker to check for sucess first then do the asignment
>
> $_ = "......";
> if ( /^(\d)-(\d+)-(\w+)$/ )
> {
> #use $1,2,3 or asign
> ($t, $zip, $type) = ($1, $2,
^^^^^^^^^^^^^^^^^^^^^^^^^^
Are you sure... wouldn't your solution require an extra copy from
$N.
--
Charles DeRykus
------------------------------
Date: 28 Sep 2007 07:28:56 GMT
From: Abigail <abigail@abigail.be>
Subject: Re: Regex confusion...
Message-Id: <slrnffpb7v.i0.abigail@alexandra.abigail.be>
_
sln@netherlands.co (sln@netherlands.co) wrote on VCXLI September MCMXCIII
in <URL:news:fnmof355vp963ba7occdgmgm9o3pc4ht4n@4ax.com>:
-- On Fri, 28 Sep 2007 00:10:42 +0100, Ben Morrow <ben@morrow.me.uk> wrote:
--
-- >
-- >This can be simplified to
-- >
-- > if (
-- > my ($t, $zip, $type) =
-- > $img =~ /^(\d)-(\d+)-(\w+)$/
-- > ) {
-- >
-- >which avoids the need to use the $N variables altogether.
-- >
--
-- It might be quicker to check for sucess first then do the asignment
--
-- $_ = "......";
-- if ( /^(\d)-(\d+)-(\w+)$/ )
-- {
-- #use $1,2,3 or asign
-- ($t, $zip, $type) = ($1, $2, $3);
-- }
--
Do you have some figures to back up this claim? I get a marginal
difference, with the direct assignment being faster if the pattern
matches, and the delayed assignment being faster if the pattern doesn't
match. Considering that the difference is less than 1 microseconds,
I wouldn't base my decision which code to use based on speed.
Abigail
--
perl -wle\$_=\<\<EOT\;y/\\n/\ /\;print\; -eJust -eanother -ePerl -eHacker -eEOT
------------------------------
Date: Thu, 27 Sep 2007 19:51:17 -0700
From: sln@netherlands.co
Subject: Re: regexp for bracket expression
Message-Id: <i7pof3dgna3e4u8dujncuo4g998rogc9fc@4ax.com>
On Wed, 19 Sep 2007 13:39:42 +0200, rembremading <rembremading@gmx.net> wrote:
>Paul Lalli wrote:
>
>> On Sep 19, 6:55 am, rembremading <rembremad...@gmx.net> wrote:
>>> Hi all!
>>>
>>> I am using regular expressions quite a lot.
>>> But somthing I don't know, so far, is if there exists an
>>> regexp matching anything which has equally many opening and closing
>>> brackets, e.g.
>>>
>>> (.(..)..(...(...))..)
>>
>> You have asked a Frequently Asked Question.
>> $ perldoc -q balance
>> Found in /software/perl-5.8.5-0/pkg/lib/5.8.5/pod/perlfaq6.pod
>> Can I use Perl regular expressions to match balanced text?
>>
>>> Any idea?
>>
>> As the FAQ answer states, check out Regexp::Common and Text::Balanced.
>That helped me, thank you!
>
>>
>>> Sorry for cross posting
>>
>> You did not cross post this message. It was sent only to
>> comp.lang.perl.misc. If you also sent it to other groups, you must
>> have done it via multiposting, not crossposting. Please don't do that
>> again. It's extremely rude.
>The reason was, that I first posted the same (english) text accidentally in
>the german .perl.misc group. This is probably a bad idea. I didn't do it on
>purpose.
>
>>
>> Paul Lalli
(.(..)..(...(...))..) is a result of a regular expression and is dynamic?
And you wan't to match that in a regular expression stream?
From perlre.html:
(??{ code })
... the rules to determine where the code ends are currently somewhat convoluted
(example)
$re = qr{
\(
(?:
(?> [^()]+ ) # Non-parens without backtracking
|
(??{ $re }) # Group with matching parens
)*
\)
}x;
I'm not sure what this means actually. Are you trying to match nested parenthesis data?
I haven't looked into it, but the faq referenced Regexp::Common and Text::Balanced for
common pattern matching. This kind of leads me to think you could do it yourself with
something like this:
@UC_Nstart = (
"\\x{C0}-\\x{D6}",
"\\x{D8}-\\x{F6}",
"\\x{F8}-\\x{2FF}",
"\\x{370}-\\x{37D}",
"\\x{37F}-\\x{1FFF}",
"\\x{200C}-\\x{200D}",
"\\x{2070}-\\x{218F}",
"\\x{2C00}-\\x{2FEF}",
"\\x{3001}-\\x{D7FF}",
"\\x{F900}-\\x{FDCF}",
"\\x{FDF0}-\\x{FFFD}",
"\\x{10000}-\\x{EFFFF}",
);
@UC_Nchar = (
"\\x{B7}",
"\\x{0300}-\\x{036F}",
"\\x{203F}-\\x{2040}",
);
$Nstrt = "[A-Za-z_:".join ('',@UC_Nstart)."]";
$Nchar = "[-\\w:\\.".join ('',@UC_Nchar).join ('',@UC_Nstart)."]";
$Name = "(?:$Nstrt$Nchar*?)";
#die "$Name\n";
$RxParseXP1 =
qr/(?:<(?:(?:(\/*)($Name)\s*(\/*))|(?:META(.*?))|(?:($Name)((?:\s+$Name\s*=\s*["'][^<]*['"])+)\s*(\/*))|(?:\?(.*?)\?)|(?:!(?:(?:DOCTYPE(.*?))|(?:\[CDATA\[(.*?)\]\])|(?:--(.*?[^-])--)|(?:ATTLIST(.*?))|(?:ENTITY(.*?)))))>)|(.+?)/s;
# ( <( ( 1 12 2 3 3)|( 4 4)|( 5 56( ) 6 7 7)|( 8 8 )|( !( ( 9 9)|( 0 0 )|( 1 1 )|(
2 2)|( 3 3))))>)|4 4
$RxAttr = qr/^\s+($Name)\s*=\s*("|')/;
$RxAttr_DL1 = qr/^(?:([^'&]*?)|([^']*?))'/;
$RxAttr_DL2 = qr/^(?:([^"&]*?)|([^"]*?))"/;
$RxAttr_RM = qr/[^\s\n]+/;
$RxPi = qr/^($Name)\s+(.*?)$/s;
------------------------------
Date: Thu, 27 Sep 2007 22:14:44 -0700
From: anil <anilkumar.iitm@gmail.com>
Subject: Re: Small doubt in perl
Message-Id: <1190956484.187711.60170@50g2000hsm.googlegroups.com>
On Sep 27, 12:34 pm, "John W. Krahn" <du...@example.com> wrote:
> anil wrote:
> > Hi,
> > I need a small help, how shall i call shell script and java
> > program in the perl?
>
> > I am using the following snippet of code,
>
> > system("sample.sh");
> > system("java test");
>
> Open two xterms (or your favourite terminal program) and run "sample.sh" in
> one and "java test" in the other. This is essentially what you are doing there.
>
> > In the "sample.sh" i have set some environmental variables, but the
> > environment variables which are set in the sample.sh are not used by
> > the java pgm.
>
> How do you set them?
>
> > Is there any other way to achieve this functionality?
>
> open SHELL, '>>', 'sample.sh' or die "Cannot open 'sample.sh' $!";
> print SHELL "java test\n";
> close SHELL;
> system( '/bin/sh', 'sample.sh' ) == 0 or die "system '/bin/sh sample.sh'
> failed: $?";
>
> John
> --
> Perl isn't a toolbox, but a small machine shop where you
> can special-order certain sorts of tools at low cost and
> in short order. -- Larry Wall
Thank You very much for ur valuable replies......
------------------------------
Date: Thu, 27 Sep 2007 22:36:04 -0700
From: anil <anilkumar.iitm@gmail.com>
Subject: Re: Small doubt in perl
Message-Id: <1190957764.122560.215770@19g2000hsx.googlegroups.com>
On Sep 27, 12:34 pm, "John W. Krahn" <du...@example.com> wrote:
> anil wrote:
> > Hi,
> > I need a small help, how shall i call shell script and java
> > program in the perl?
>
> > I am using the following snippet of code,
>
> > system("sample.sh");
> > system("java test");
>
> Open two xterms (or your favourite terminal program) and run "sample.sh" in
> one and "java test" in the other. This is essentially what you are doing there.
>
> > In the "sample.sh" i have set some environmental variables, but the
> > environment variables which are set in the sample.sh are not used by
> > the java pgm.
>
> How do you set them?
>
> > Is there any other way to achieve this functionality?
>
> open SHELL, '>>', 'sample.sh' or die "Cannot open 'sample.sh' $!";
> print SHELL "java test\n";
> close SHELL;
> system( '/bin/sh', 'sample.sh' ) == 0 or die "system '/bin/sh sample.sh'
> failed: $?";
>
> John
> --
> Perl isn't a toolbox, but a small machine shop where you
> can special-order certain sorts of tools at low cost and
> in short order. -- Larry Wall
Hi john,
Thanks for your reply, but your method is corrupting the
sample.sh, I don't want to corrupt the sample.sh, because this perl
program i have to execute several times, then that java program runs
several times..which degrades the performance of my program.
Thanks
Anil.
------------------------------
Date: Fri, 28 Sep 2007 01:26:08 -0700
From: rihad <rihad@mail.ru>
Subject: Re: string concatentation vs. interpolation: which one is more optimal?
Message-Id: <1190967968.110236.162090@y42g2000hsy.googlegroups.com>
On Sep 28, 2:03 am, brian d foy <brian.d....@gmail.com> wrote:
> In article <1190824931.665621.151...@50g2000hsm.googlegroups.com>,
>
> rihad <ri...@mail.ru> wrote:
> > Programming Perl (The Camel Book) states that "String concatenation is
> > also implied by the interpolation that happens in double-quoted
> > strings."
> > Can someone experienced in Perl source code confirm that they are
> > identical in terms of raw speed and memory use or not?
>
> When you start looking at the speed of things like this and actaully
> caring about the answer, you'll probably find that Perl is not the
> right tool for the job. Perl is really fast, but if this sort of
> operation is too slow for you, then the bigger tasks in Perl, uch as
> using a module, will just kill your performance (relatively).
>
Hi, brian d foy (I like the way your name is spelled that makes you
stand out from the rest throughout "Learning Perl" and the Perl FAQ -
it must be you really deserve this distinction :))
It's not that I want Perl to be as fast as assembly, no. I just don't
want to be using suboptimal patterns from the start if it can be done
better AND if the loss of programming convenience does not outweigh
performance gains. IOW, I wouldn't write CGI's in assembly because web
servers being normally written in C would probably be the
bottleneck :) (greatly simplifying, of course)
Besides, interpolation is almost always more legible than
concatenation, the fact that rarely goes hand in hand with efficiency.
It would be a sin not to exploit their being identical (not to be
taken literally). Sadly, most strings I've seen are being built up
disregarding interpolation. This struck my curiosity enough to ask
here.
> Before anyone gets too concerned about small details like this
> (especially when Perl is not constrained to implement them in any way
> and the next release of Perl might do it differently), try profiling
> the application that you are concerned about. You'll find easier and
> slower things to fix and worry about :)
Ok this seems to be coming from the innards of great developing
experience. Again, the reason I asked is based on my strive for
perfection, not that I was counting on an answer here to make more
money or anything.
/Here I reread what's been written, and .../
Still... why shouldn't Perl (or language Foo) programmers care about
efficiency if OS programmers _do_ care?
------------------------------
Date: Thu, 27 Sep 2007 20:10:34 -0700
From: sln@netherlands.co
Subject: Re: why are references so slow ?
Message-Id: <rvrof3tt6u8b7609vpd3nhsh4havh3nn30@4ax.com>
On Wed, 26 Sep 2007 04:49:19 +0200, Daniel Dünker <dduenker@uni-koblenz.de> wrote:
>I have a script, with lots of deep recursion and noticed, that with the usage of references the whole programm becomes *much* slower (i noticed that in an earlier state, when i wanted to put something often used into a sub. The programm took at first less than 1 second, after i created the sub it took more than 5 seconds to complete.)
>Now i am at a point where i want to use recursion, and perl says its even a deep recursion.
>So, should i throw away all the parameters and just use global variables to get rid of referencing and dereferencing ?
Yes, you should throw away \@references or \$references, and pass by value always.
Should I get rid of pointers and go to dot net?
------------------------------
Date: Thu, 27 Sep 2007 20:13:59 -0700
From: sln@netherlands.co
Subject: Re: why are references so slow ?
Message-Id: <aasof39ocpue9420o05eul0du6inn1rqcq@4ax.com>
On Wed, 26 Sep 2007 04:49:19 +0200, Daniel Dünker <dduenker@uni-koblenz.de> wrote:
>I have a script, with lots of deep recursion and noticed, that with the usage of references the whole programm becomes *much* slower (i noticed that in an earlier state, when i wanted to put something often used into a sub. The programm took at first less than 1 second, after i created the sub it took more than 5 seconds to complete.)
>Now i am at a point where i want to use recursion, and perl says its even a deep recursion.
>So, should i throw away all the parameters and just use global variables to get rid of referencing and dereferencing ?
You should use nothing BUT global variables. Throw away subroutine parameters alltogether!
------------------------------
Date: 28 Sep 2007 09:35:24 GMT
From: all mail refused <elvis-85363@notatla.org.uk>
Subject: Re: why are references so slow ?
Message-Id: <slrnffpifs.30t.elvis-85363@notatla.org.uk>
On 2007-09-28, sln@netherlands.co <sln@netherlands.co> wrote:
> On Wed, 26 Sep 2007 04:49:19 +0200, Daniel Dünker <dduenker@uni-koblenz.de> wrote:
>>So, should i throw away all the parameters and just use global variables to get rid of referencing and dereferencing ?
>
> You should use nothing BUT global variables. Throw away subroutine parameters alltogether!
Precompute all your programs and then for each situation run eithr /bin/true or /bin/false.
--
Elvis Notargiacomo master AT barefaced DOT cheek
http://www.notatla.org.uk/goen/
------------------------------
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 887
**************************************