[24417] in Perl-Users-Digest
Perl-Users Digest, Issue: 6605 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue May 25 06:05:48 2004
Date: Tue, 25 May 2004 03:05:06 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Tue, 25 May 2004 Volume: 10 Number: 6605
Today's topics:
Re: ActiveState Perl mangles text files <mothra@mothra.com>
Re: ActiveState Perl mangles text files <usenet@morrow.me.uk>
Re: Map or Regex and Sorting <schaumfestiger@gmx.de>
Re: Map or Regex and Sorting <schaumfestiger@gmx.de>
Re: NET::IMAP problems <Joe.Smith@inwap.com>
Re: open file error <me@privacy.net>
Re: open file error <bjg@network-theory.co.uk>
Re: Password scheme/Persistent session... <uri@stemsystems.com>
Re: Perl work? <ebohlman@earthlink.net>
Posting Guidelines for comp.lang.perl.misc ($Revision: tadmc@augustmail.com
Re: Regex srch & repl only executing once <Joe.Smith@inwap.com>
Re: Request for help with search & replace script <tore@aursand.no>
Re: Using Cookies With Perl <uri@stemsystems.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 25 May 2004 07:33:07 GMT
From: Mothra <mothra@mothra.com>
Subject: Re: ActiveState Perl mangles text files
Message-Id: <TECsc.16096868$Id.2671028@news.easynews.com>
Ben Morrow wrote:
> Quoth Mothra <mothra@mothra.com>:
>
>>>
>>
>>Being awkward now, but is there a way I do this with IO::File?
>
>
> Why? Perl's lexical filehandles (the 'open my $IN' in my example) make
> IO::File obsolete, AFAICS.
>
Hmm... I always thought of it the other way round - IO::File did come
later after all. Using IO:File can be useful where you actually want
your file object to be restricted by scope (filehandles are
automatically global). So I've just gotten into the habit of always
using it.
------------------------------
Date: Tue, 25 May 2004 08:27:14 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: ActiveState Perl mangles text files
Message-Id: <c8v012$8g2$1@wisteria.csv.warwick.ac.uk>
Quoth Mothra <mothra@mothra.com>:
> Ben Morrow wrote:
>
> > Quoth Mothra <mothra@mothra.com>:
> >
> >>>
> >>
> >>Being awkward now, but is there a way I do this with IO::File?
> >
> >
> > Why? Perl's lexical filehandles (the 'open my $IN' in my example) make
> > IO::File obsolete, AFAICS.
> >
> Hmm... I always thought of it the other way round - IO::File did come
> later after all. Using IO:File can be useful where you actually want
> your file object to be restricted by scope (filehandles are
> automatically global). So I've just gotten into the habit of always
> using it.
Really? I'm surprised...
The point about lexical FHs is that they *are* scoped. In my code:
my @lines = do {
open my $IN, '<', 'file' or die ...;
<$IN>
};
the FH is closed at the end of the scope.
Ben
--
"If a book is worth reading when you are six, * ben@morrow.me.uk
it is worth reading when you are sixty." - C.S.Lewis
------------------------------
Date: Tue, 25 May 2004 08:31:02 +0200
From: Herr Hardy <schaumfestiger@gmx.de>
Subject: Re: Map or Regex and Sorting
Message-Id: <nfp5b0p1ajv8tq5gco12pkq799vfshp8fb@4ax.com>
On Tue, 25 May 2004 01:16:36 GMT, "John W. Krahn" <krahnj@acm.org>
wrote:
Let me comment to understand, from bottom to top
>push @{ /OPEN/ ? \@openlist : \@clsdlist }, $_ for
# ^ 4. OPEN 2 openlist, !OPEN 2 clsdlist
> map substr( $_, 3 ),
# ^ 3. delete leading 'mark'-digits
> sort
# ^ 2. simple Perl sort on the 'marks'
> map sprintf( '%03d%s', /(\d{1,3})/, $_ ),
# ^ 1. 'marking' each line with \d{1,3} as leading digits
# or 0nn or 00n if less than 3 digits in \d{1,3}
> <DATA>;
>
>print @openlist, @clsdlist;
>
That's pretty, John.
------------------------------
Date: Tue, 25 May 2004 09:55:57 +0200
From: Herr Hardy <schaumfestiger@gmx.de>
Subject: Re: Map or Regex and Sorting
Message-Id: <qvu5b0hioj7s0fhusga9alie3f8j71m3b5@4ax.com>
On Tue, 25 May 2004 08:31:02 +0200, Herr Hardy <schaumfestiger@gmx.de>
wrote:
Taking your funny line
>>push @{ /OPEN/ ? \@openlist : \@clsdlist }, $_ for
without mapping
push @{ /OPEN/ ? \@openlist : \@clsdlist }, $_ for
sort {
my($x) = ($a=~/(\d{1,3})/);
my($y) = ($b=~/(\d{1,3})/);
$x <=> $y;
}
<DATA>;
------------------------------
Date: Tue, 25 May 2004 08:09:06 GMT
From: Joe Smith <Joe.Smith@inwap.com>
Subject: Re: NET::IMAP problems
Message-Id: <CaDsc.56423$gr.5576131@attbi_s52>
mk-2@corena.de wrote:
> Hallo!
>
> I try to use Net::IMAP to access our IMAP servers.
>
> ~~~~~~
> use Net::IMAP;
>
> # open a connection to the IMAP server
> $server = new Net::IMAP( 'localhost',
> Synchronous => 1,
> Debug => 1,
> )
> || die ("no server");
>
> ~~~~~~
> The server is 2.1.16 in Debian Linux testing.
> Apparently the script connects, but does not return a valid handle.
>
> ~~~~~~
> mk@orcus:~/tmp> perl -w conn2
> Name "main::server" used only once: possible typo at conn2 line 4.
> <- Net::IMAP=HASH(0x82c9cac) 18:24:04 [* OK orcus Cyrus IMAP4
> v2.1.16-IPv6-Debian-2.1.16-4 server ready]
> no server at conn2 line 4.
> ~~~~~~
>
> Any other operations later on this handle are failing.
> Any idea what is wrong?
I get more output than that on Red Hat 9.
<- Net::IMAP=HASH(0x831bdd8) 01:25:04 [* OK [CAPABILITY IMAP4REV1
LOGIN-REFERRALS STARTTLS AUTH=LOGIN] localhost IMAP4rev1 2001.315rh at Tue, 25
May 2004 01:04:51 -0700 (PDT)]
-> Net::IMAP=HASH(0x831bdd8) 01:25:04 [1 capability]
-> Net::IMAP=HASH(0x831bdd8) 01:25:04 [eol]
<- Net::IMAP=HASH(0x831bdd8) 01:25:04 [* CAPABILITY IMAP4REV1 IDLE NAMESPACE
MAILBOX-REFERRALS SCAN SORT THREAD=REFERENCES THREAD=ORDEREDSUBJECT
MULTIAPPEND LOGIN-REFERRALS STARTTLS AUTH=LOGIN]
<- Net::IMAP=HASH(0x831bdd8) 01:25:04 [untagged resp callback returned
Net::IMAP::Capability=HASH(0x82c1be8)]
<- Net::IMAP=HASH(0x831bdd8) 01:25:04 [1 OK CAPABILITY completed]
<- Net::IMAP=HASH(0x831bdd8) 01:25:04 [callback returned
Net::IMAP::Response=HASH(0x82c1db0)]
------------------------------
Date: Tue, 25 May 2004 19:53:18 +1200
From: "Tintin" <me@privacy.net>
Subject: Re: open file error
Message-Id: <2hgceuFcri4bU1@uni-berlin.de>
"Emanuele Matli" <emanuele.matli@cern.ch> wrote in message
news:c8sk83$95r$1@sunnews.cern.ch...
> Hi all,
>
> I have a, probably, stupid problem, but I'm new to perl (not to
> programming) and I can't see where the problem is.
It's not specific to Perl, so I'm surprised that you say you have
programming experience and can't narrow down the issue.
>
> A simple program containing this command:
>
> open(FH, "test.txt") || die $!;
>
> gives the following answer:
>
> "No such file or directory"
As it will when it can't find the file or directory.
>
> The file is there and the permissions on the sever dir are ok.
> On the other hand, if I try to open a file to write I get a permission
> error because I don't have the right to write in the same dir.
The file is somewhere, but it certainly isn't where you run the script on.
Add
use Cwd;
print "My current directory is: " . cwd() . "\n";
That should give you a *big* clue.
Moral of the story is don't make assumptions about your current dir in a CGI
environment (which I'm sure this question is about) and use absolute paths
to make absolutely sure you point to the right location.
------------------------------
Date: 25 May 2004 10:22:54 +0100
From: Brian Gough <bjg@network-theory.co.uk>
Subject: Re: open file error
Message-Id: <87isekvp1t.fsf@network-theory.co.uk>
Tad McClellan <tadmc@augustmail.com> writes:
> Where in the std docs did you see it say that?
Sorry, it was a totally incoherent error due to lack of coffee, or
something... I cancelled the message immediately after :-(
--
Brian Gough
Network Theory Ltd,
Publishing Free Software Manuals --- http://www.network-theory.co.uk/
------------------------------
Date: Tue, 25 May 2004 04:05:35 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Password scheme/Persistent session...
Message-Id: <x77jv1noc0.fsf@mail.sysarch.com>
>>>>> "k" == krakle <krakle@visto.com> writes:
k> "Alan J. Flavell" <flavell@ph.gla.ac.uk> wrote in message news:<Pine.LNX.4.53.0405222219170.31304@ppepc56.ph.gla.ac.uk>...
>> On Sat, 22 May 2004, norfernuman wrote:
>>
>> > Wow, this same guy still got answers from this group. You all either
>> > didn't know of him, remember him, or your very forgiving. He's got some
>> > nerve even showing his 'face' back here.
>>
>> What you're missing is that the regulars are responding as much for
>> the potential benefit of the rest of the Usenet audience, as for the
>> individual who provoked the issue.
k> :)
k> All my posts are on topic and never go offtopic unless someone brings
k> it off. Like this one.
wow. that is so dense. try saying that in other groups. i don't kill
file but you are on a major shit list.
i would pursue another profession, if you can't do the basic separation
of problem spaces. you are like a guy who uses pipe wrenches under the
sink to fixs the tv. hell, the three stooges did it and they were always
on topic.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: 25 May 2004 05:36:06 GMT
From: Eric Bohlman <ebohlman@earthlink.net>
Subject: Re: Perl work?
Message-Id: <Xns94F46CBE74DAebohlmanomsdevcom@130.133.1.4>
krakle@visto.com (krakle) wrote in
news:237aaff8.0405241501.403d735@posting.google.com:
> Charlton Wilbur <cwilbur@mithril.chromatico.net> wrote in message
> news:<87lljj24hm.fsf@mithril.chromatico.net>...
>> They're also people in foreign countries where $2/hour is a very good
>> wage. Someone who lives in a region where $2000/year is a
>> comfortable income is probably doing quite well to be making $3 or $4
>> an hour.
>
> ermmm.. I would have to disagree. I don't think someone who makes
> $2,000 a year able to live off from $3 an hour even has a computer
> with internet access and a programming education background to do the
> work. I would of thought common sense would of ruled that out...
You're being ethnocentric (the term has two related but not identical
meanings: the belief that one's own culture is superior, and the assumption
that the way things work in one's own culture is the way things work all
over the world; I'm using the term in the second sense). You're assuming
that anyone making $2000 a year anywhere in the world has the
characteristics that you'd associate with someone making $2000 a year in
the developed West. As Charlton pointed out, that simply isn't true; in
many parts of the world, $2000 buys a *great* deal more than it does in the
US.
If you still have trouble understanding this (that the value of a given
amount of money can vary from place to place), then consider how it can
vary from time to time in the same place. Would you consider an American
making $50K/year to be "rich"? I certainly would, if we were talking about
an American who lived 100 years ago. $50K in 1904 bought about what $1M
buys in 2004, and most people would regard a contemporary American making
$1M/year as "rich." And obversely, an American who was making $2000/year
in 1904 could be expected to have a similar background to an American
making $40K/year in 2004.
------------------------------
Date: Tue, 25 May 2004 02:23:26 -0500
From: tadmc@augustmail.com
Subject: Posting Guidelines for comp.lang.perl.misc ($Revision: 1.5 $)
Message-Id: <WuidnbRaj9nzaS_dRVn-jw@august.net>
Outline
Before posting to comp.lang.perl.misc
Must
- Check the Perl Frequently Asked Questions (FAQ)
- Check the other standard Perl docs (*.pod)
Really Really Should
- Lurk for a while before posting
- Search a Usenet archive
If You Like
- Check Other Resources
Posting to comp.lang.perl.misc
Is there a better place to ask your question?
- Question should be about Perl, not about the application area
How to participate (post) in the clpmisc community
- Carefully choose the contents of your Subject header
- Use an effective followup style
- Speak Perl rather than English, when possible
- Ask perl to help you
- Do not re-type Perl code
- Provide enough information
- Do not provide too much information
- Do not post binaries, HTML, or MIME
Social faux pas to avoid
- Asking a Frequently Asked Question
- Asking a question easily answered by a cursory doc search
- Asking for emailed answers
- Beware of saying "doesn't work"
- Sending a "stealth" Cc copy
Be extra cautious when you get upset
- Count to ten before composing a followup when you are upset
- Count to ten after composing and before posting when you are upset
-----------------------------------------------------------------
Posting Guidelines for comp.lang.perl.misc ($Revision: 1.5 $)
This newsgroup, commonly called clpmisc, is a technical newsgroup
intended to be used for discussion of Perl related issues (except job
postings), whether it be comments or questions.
As you would expect, clpmisc discussions are usually very technical in
nature and there are conventions for conduct in technical newsgroups
going somewhat beyond those in non-technical newsgroups.
The article at:
http://www.catb.org/~esr/faqs/smart-questions.html
describes how to get answers from technical people in general.
This article describes things that you should, and should not, do to
increase your chances of getting an answer to your Perl question. It is
available in POD, HTML and plain text formats at:
http://mail.augustmail.com/~tadmc/clpmisc.shtml
For more information about netiquette in general, see the "Netiquette
Guidelines" at:
http://andrew2.andrew.cmu.edu/rfc/rfc1855.html
A note to newsgroup "regulars":
Do not use these guidelines as a "license to flame" or other
meanness. It is possible that a poster is unaware of things
discussed here. Give them the benefit of the doubt, and just
help them learn how to post, rather than assume
A note about technical terms used here:
In this document, we use words like "must" and "should" as
they're used in technical conversation (such as you will
encounter in this newsgroup). When we say that you *must* do
something, we mean that if you don't do that something, then
it's unlikely that you will benefit much from this group.
We're not bossing you around; we're making the point without
lots of words.
Do *NOT* send email to the maintainer of these guidelines. It will be
discarded unread. The guidelines belong to the newsgroup so all
discussion should appear in the newsgroup. I am just the secretary that
writes down the consensus of the group.
Before posting to comp.lang.perl.misc
Must
This section describes things that you *must* do before posting to
clpmisc, in order to maximize your chances of getting meaningful replies
to your inquiry and to avoid getting flamed for being lazy and trying to
have others do your work.
The perl distribution includes documentation that is copied to your hard
drive when you install perl. Also installed is a program for looking
things up in that (and other) documentation named 'perldoc'.
You should either find out where the docs got installed on your system,
or use perldoc to find them for you. Type "perldoc perldoc" to learn how
to use perldoc itself. Type "perldoc perl" to start reading Perl's
standard documentation.
Check the Perl Frequently Asked Questions (FAQ)
Checking the FAQ before posting is required in Big 8 newsgroups in
general, there is nothing clpmisc-specific about this requirement.
You are expected to do this in nearly all newsgroups.
You can use the "-q" switch with perldoc to do a word search of the
questions in the Perl FAQs.
Check the other standard Perl docs (*.pod)
The perl distribution comes with much more documentation than is
available for most other newsgroups, so in clpmisc you should also
see if you can find an answer in the other (non-FAQ) standard docs
before posting.
It is *not* required, or even expected, that you actually *read* all of
Perl's standard docs, only that you spend a few minutes searching them
before posting.
Try doing a word-search in the standard docs for some words/phrases
taken from your problem statement or from your very carefully worded
"Subject:" header.
Really Really Should
This section describes things that you *really should* do before posting
to clpmisc.
Lurk for a while before posting
This is very important and expected in all newsgroups. Lurking means
to monitor a newsgroup for a period to become familiar with local
customs. Each newsgroup has specific customs and rituals. Knowing
these before you participate will help avoid embarrassing social
situations. Consider yourself to be a foreigner at first!
Search a Usenet archive
There are tens of thousands of Perl programmers. It is very likely
that your question has already been asked (and answered). See if you
can find where it has already been answered.
One such searchable archive is:
http://groups.google.com/advanced_group_search
If You Like
This section describes things that you *can* do before posting to
clpmisc.
Check Other Resources
You may want to check in books or on web sites to see if you can
find the answer to your question.
But you need to consider the source of such information: there are a
lot of very poor Perl books and web sites, and several good ones
too, of course.
Posting to comp.lang.perl.misc
There can be 200 messages in clpmisc in a single day. Nobody is going to
read every article. They must decide somehow which articles they are
going to read, and which they will skip.
Your post is in competition with 199 other posts. You need to "win"
before a person who can help you will even read your question.
These sections describe how you can help keep your article from being
one of the "skipped" ones.
Is there a better place to ask your question?
Question should be about Perl, not about the application area
It can be difficult to separate out where your problem really is,
but you should make a conscious effort to post to the most
applicable newsgroup. That is, after all, where you are the most
likely to find the people who know how to answer your question.
Being able to "partition" a problem is an essential skill for
effectively troubleshooting programming problems. If you don't get
that right, you end up looking for answers in the wrong places.
It should be understood that you may not know that the root of your
problem is not Perl-related (the two most frequent ones are CGI and
Operating System related), so off-topic postings will happen from
time to time. Be gracious when someone helps you find a better place
to ask your question by pointing you to a more applicable newsgroup.
How to participate (post) in the clpmisc community
Carefully choose the contents of your Subject header
You have 40 precious characters of Subject to win out and be one of
the posts that gets read. Don't waste them. Take care while
composing them, they are the key that opens the door to getting an
answer.
Spend them indicating what aspect of Perl others will find if they
should decide to read your article.
Do not spend them indicating "experience level" (guru, newbie...).
Do not spend them pleading (please read, urgent, help!...).
Do not spend them on non-Subjects (Perl question, one-word
Subject...)
For more information on choosing a Subject see "Choosing Good
Subject Lines":
http://www.cpan.org/authors/id/D/DM/DMR/subjects.post
Part of the beauty of newsgroup dynamics, is that you can contribute
to the community with your very first post! If your choice of
Subject leads a fellow Perler to find the thread you are starting,
then even asking a question helps us all.
Use an effective followup style
When composing a followup, quote only enough text to establish the
context for the comments that you will add. Always indicate who
wrote the quoted material. Never quote an entire article. Never
quote a .signature (unless that is what you are commenting on).
Intersperse your comments *following* each section of quoted text to
which they relate. Unappreciated followup styles are referred to as
"top-posting", "Jeopardy" (because the answer comes before the
question), or "TOFU" (Text Over, Fullquote Under).
Reversing the chronology of the dialog makes it much harder to
understand (some folks won't even read it if written in that style).
For more information on quoting style, see:
http://web.presby.edu/~nnqadmin/nnq/nquote.html
Speak Perl rather than English, when possible
Perl is much more precise than natural language. Saying it in Perl
instead will avoid misunderstanding your question or problem.
Do not say: I have variable with "foo\tbar" in it.
Instead say: I have $var = "foo\tbar", or I have $var = 'foo\tbar',
or I have $var = <DATA> (and show the data line).
Ask perl to help you
You can ask perl itself to help you find common programming mistakes
by doing two things: enable warnings (perldoc warnings) and enable
"strict"ures (perldoc strict).
You should not bother the hundreds/thousands of readers of the
newsgroup without first seeing if a machine can help you find your
problem. It is demeaning to be asked to do the work of a machine. It
will annoy the readers of your article.
You can look up any of the messages that perl might issue to find
out what the message means and how to resolve the potential mistake
(perldoc perldiag). If you would like perl to look them up for you,
you can put "use diagnostics;" near the top of your program.
Do not re-type Perl code
Use copy/paste or your editor's "import" function rather than
attempting to type in your code. If you make a typo you will get
followups about your typos instead of about the question you are
trying to get answered.
Provide enough information
If you do the things in this item, you will have an Extremely Good
chance of getting people to try and help you with your problem!
These features are a really big bonus toward your question winning
out over all of the other posts that you are competing with.
First make a short (less than 20-30 lines) and *complete* program
that illustrates the problem you are having. People should be able
to run your program by copy/pasting the code from your article. (You
will find that doing this step very often reveals your problem
directly. Leading to an answer much more quickly and reliably than
posting to Usenet.)
Describe *precisely* the input to your program. Also provide example
input data for your program. If you need to show file input, use the
__DATA__ token (perldata.pod) to provide the file contents inside of
your Perl program.
Show the output (including the verbatim text of any messages) of
your program.
Describe how you want the output to be different from what you are
getting.
If you have no idea at all of how to code up your situation, be sure
to at least describe the 2 things that you *do* know: input and
desired output.
Do not provide too much information
Do not just post your entire program for debugging. Most especially
do not post someone *else's* entire program.
Do not post binaries, HTML, or MIME
clpmisc is a text only newsgroup. If you have images or binaries
that explain your question, put them in a publically accessible
place (like a Web server) and provide a pointer to that location. If
you include code, cut and paste it directly in the message body.
Don't attach anything to the message. Don't post vcards or HTML.
Many people (and even some Usenet servers) will automatically filter
out such messages. Many people will not be able to easily read your
post. Plain text is something everyone can read.
Social faux pas to avoid
The first two below are symptoms of lots of FAQ asking here in clpmisc.
It happens so often that folks will assume that it is happening yet
again. If you have looked but not found, or found but didn't understand
the docs, say so in your article.
Asking a Frequently Asked Question
It should be understood that you may have missed the applicable FAQ
when you checked, which is not a big deal. But if the Frequently
Asked Question is worded similar to your question, folks will assume
that you did not look at all. Don't become indignant at pointers to
the FAQ, particularly if it solves your problem.
Asking a question easily answered by a cursory doc search
If folks think you have not even tried the obvious step of reading
the docs applicable to your problem, they are likely to become
annoyed.
If you are flamed for not checking when you *did* check, then just
shrug it off (and take the answer that you got).
Asking for emailed answers
Emailed answers benefit one person. Posted answers benefit the
entire community. If folks can take the time to answer your
question, then you can take the time to go get the answer in the
same place where you asked the question.
It is OK to ask for a *copy* of the answer to be emailed, but many
will ignore such requests anyway. If you munge your address, you
should never expect (or ask) to get email in response to a Usenet
post.
Ask the question here, get the answer here (maybe).
Beware of saying "doesn't work"
This is a "red flag" phrase. If you find yourself writing that,
pause and see if you can't describe what is not working without
saying "doesn't work". That is, describe how it is not what you
want.
Sending a "stealth" Cc copy
A "stealth Cc" is when you both email and post a reply without
indicating *in the body* that you are doing so.
Be extra cautious when you get upset
Count to ten before composing a followup when you are upset
This is recommended in all Usenet newsgroups. Here in clpmisc, most
flaming sub-threads are not about any feature of Perl at all! They
are most often for what was seen as a breach of netiquette. If you
have lurked for a bit, then you will know what is expected and won't
make such posts in the first place.
But if you get upset, wait a while before writing your followup. I
recommend waiting at least 30 minutes.
Count to ten after composing and before posting when you are upset
After you have written your followup, wait *another* 30 minutes
before committing yourself by posting it. You cannot take it back
once it has been said.
AUTHOR
Tad McClellan <tadmc@augustmail.com> and many others on the
comp.lang.perl.misc newsgroup.
------------------------------
Date: Tue, 25 May 2004 07:18:39 GMT
From: Joe Smith <Joe.Smith@inwap.com>
Subject: Re: Regex srch & repl only executing once
Message-Id: <irCsc.39733$zw.21273@attbi_s01>
Ethan wrote:
> file the first occurance of the search string IS replaced, but NONE of
> the others are replaced.
>
> $line =~ s/\.jsp/.htm/; # Only works the first time
Perl will do one substitution per line because you told it to, by leaving
out the /g modifier. Check the docs for s///g and s///i.
$line =~ /s\.jsp/.htm/ig; # Do all occurrances of '.jsp' and '.JSP'
-Joe
------------------------------
Date: Tue, 25 May 2004 06:17:41 +0200
From: Tore Aursand <tore@aursand.no>
Subject: Re: Request for help with search & replace script
Message-Id: <pan.2004.05.25.04.16.50.656839@aursand.no>
On Mon, 24 May 2004 18:15:54 -0700, Ethan wrote:
> sub doReplace
> {
> my @outLines; #Data we are going to output
> my $line; #Data we are reading line by line
>
> # Only parse files that end in .htm
> if ( $File::Find::name =~ /\.htm$/ )
> {
> print "\nprocessing $_\n";
Think about just skipping the files you don't want to process instead, as
it (IMO) eases the readability;
sub doReplcae {
next unless ( $File::Find::name =~ /\.htm$/ );
# ...
> while ( $line = <FILE> )
You shouldn't have declared $line outside of this scope;
while ( my $line = <FILE> ) {
# ...
}
In this case, you don't even need $line, _and_ it eases the readability;
while ( <FILE> ) {
s/<jsp:setProperty.+>//;
s/<jsp:useBean.+>//;
push( @outLines, $_ );
}
> $line =~ s/<jsp:setProperty.+\>//i;
> $line =~ s/<jsp:useBean.+\>//i;
You're escaping characters that don't need escaping;
> undef( @outLines );
No need to, really. Perl takes care of cleaning up your mess (most of the
time). :)
--
Tore Aursand <tore@aursand.no>
"Fighting terrorism is like being a goalkeeper. You can make a hundred
brilliant saves but the only shot that people remember is the one that
gets past you." (Paul Wilkinson)
------------------------------
Date: Tue, 25 May 2004 04:20:55 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Using Cookies With Perl
Message-Id: <x71xl9nnmg.fsf@mail.sysarch.com>
>>>>> "k" == krakle <krakle@visto.com> writes:
k> "James Hunt" <jameskorea2003@hotmail.com> wrote in message news:<d6udnXeKBqsK9y_dRVn-hQ@comcast.com>...
>> Does anyone have a good web reference for setting up and accessing cookies
>> with Perl?
>>
>> - James Hunt
k> This isn't a Perl question and has no excuse to be here.
k> Right on Tad?
nope. you lose again. he asked a specific question about how to do
something in perl. you ask for how to do sessions in apache. but you
won't see the difference. just to emphasize the point, i will answer
this query.
get the LWP module (comes with 5.8+) and read its cookbook and some of
it main docs (LWP.pm itself has a list of the other docs).
in particular, the HTTP::Cookie module will show you how to create, send
and get back cookies from a browser via the user agent. it is very
simple to do. the harder part is actually maintaining a session and that
requires some way of keeping state (the session itself) and some way of
guiding the browser future requests to this session. this is usually
done by keeping state in a server or on disk and using a cookie to map
the user to the session. there are many ways to generate and manage
cookies and how you tie them (and thereby the browser) to a session.
so see how a direct question gets a direct answer? the OP partitioned
the problem so it was about perl and not about the apache server. try to
learn from this. but i think i saw some of your old posts dragged up so
it seems you won't change. you are wrong but refuse to see it. stay
blind but stay out of here.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc. For subscription or unsubscription requests, send
#the single line:
#
# subscribe perl-users
#or:
# unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.
#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 6605
***************************************