[26430] in Perl-Users-Digest
Perl-Users Digest, Issue: 8599 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Nov 2 18:05:31 2005
Date: Wed, 2 Nov 2005 15:05:06 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Wed, 2 Nov 2005 Volume: 10 Number: 8599
Today's topics:
FAQ 4.13 How do I find the current century or millenniu <comdog@pair.com>
FAQ 8.13 How do I trap control characters/signals? <comdog@pair.com>
Re: IIS 5.1 + Perl <flavell@ph.gla.ac.uk>
Re: IIS 5.1 + Perl <toddrw69@excite.com>
Re: IIS 5.1 + Perl <flavell@ph.gla.ac.uk>
Re: IIS 5.1 + Perl <flavell@ph.gla.ac.uk>
s/// and modifiers m and s (was: Re: s///x) <rvtol+news@isolution.nl>
Re: s///x <abigail@abigail.nl>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 2 Nov 2005 23:03:01 +0000 (UTC)
From: PerlFAQ Server <comdog@pair.com>
Subject: FAQ 4.13 How do I find the current century or millennium?
Message-Id: <dkbgj5$bms$1@reader2.panix.com>
This message is one of several periodic postings to comp.lang.perl.misc
intended to make it easier for perl programmers to find answers to
common questions. The core of this message represents an excerpt
from the documentation provided with Perl.
--------------------------------------------------------------------
4.13: How do I find the current century or millennium?
Use the following simple functions:
sub get_century {
return int((((localtime(shift || time))[5] + 1999))/100);
}
sub get_millennium {
return 1+int((((localtime(shift || time))[5] + 1899))/1000);
}
On some systems, the POSIX module's strftime() function has been
extended in a non-standard way to use a %C format, which they sometimes
claim is the "century". It isn't, because on most such systems, this is
only the first two digits of the four-digit year, and thus cannot be
used to reliably determine the current century or millennium.
--------------------------------------------------------------------
Documents such as this have been called "Answers to Frequently
Asked Questions" or FAQ for short. They represent an important
part of the Usenet tradition. They serve to reduce the volume of
redundant traffic on a news group by providing quality answers to
questions that keep coming up.
If you are some how irritated by seeing these postings you are free
to ignore them or add the sender to your killfile. If you find
errors or other problems with these postings please send corrections
or comments to the posting email address or to the maintainers as
directed in the perlfaq manual page.
Note that the FAQ text posted by this server may have been modified
from that distributed in the stable Perl release. It may have been
edited to reflect the additions, changes and corrections provided
by respondents, reviewers, and critics to previous postings of
these FAQ. Complete text of these FAQ are available on request.
The perlfaq manual page contains the following copyright notice.
AUTHOR AND COPYRIGHT
Copyright (c) 1997-2002 Tom Christiansen and Nathan
Torkington, and other contributors as noted. All rights
reserved.
This posting is provided in the hope that it will be useful but
does not represent a commitment or contract of any kind on the part
of the contributers, authors or their agents.
------------------------------
Date: Wed, 2 Nov 2005 17:03:01 +0000 (UTC)
From: PerlFAQ Server <comdog@pair.com>
Subject: FAQ 8.13 How do I trap control characters/signals?
Message-Id: <dkarg5$gke$1@reader2.panix.com>
This message is one of several periodic postings to comp.lang.perl.misc
intended to make it easier for perl programmers to find answers to
common questions. The core of this message represents an excerpt
from the documentation provided with Perl.
--------------------------------------------------------------------
8.13: How do I trap control characters/signals?
You don't actually "trap" a control character. Instead, that character
generates a signal which is sent to your terminal's currently
foregrounded process group, which you then trap in your process. Signals
are documented in "Signals" in perlipc and the section on "Signals" in
the Camel.
You can set the values of the %SIG hash to be the functions you want to
handle the signal. After perl catches the signal, it looks in %SIG for a
key with the same name as the signal, then calls the subroutine value
for that key.
# as an anonymous subroutine
$SIG{INT} = sub { syswrite(STDERR, "ouch\n", 5 ) };
# or a reference to a function
$SIG{INT} = \&ouch;
# or the name of the function as a string
$SIG{INT} = "ouch";
Perl versions before 5.8 had in its C source code signal handlers which
would catch the signal and possibly run a Perl function that you had set
in %SIG. This violated the rules of signal handling at that level
causing perl to dump core. Since version 5.8.0, perl looks at %SIG
*after* the signal has been caught, rather than while it is being
caught. Previous versions of this answer were incorrect.
--------------------------------------------------------------------
Documents such as this have been called "Answers to Frequently
Asked Questions" or FAQ for short. They represent an important
part of the Usenet tradition. They serve to reduce the volume of
redundant traffic on a news group by providing quality answers to
questions that keep coming up.
If you are some how irritated by seeing these postings you are free
to ignore them or add the sender to your killfile. If you find
errors or other problems with these postings please send corrections
or comments to the posting email address or to the maintainers as
directed in the perlfaq manual page.
Note that the FAQ text posted by this server may have been modified
from that distributed in the stable Perl release. It may have been
edited to reflect the additions, changes and corrections provided
by respondents, reviewers, and critics to previous postings of
these FAQ. Complete text of these FAQ are available on request.
The perlfaq manual page contains the following copyright notice.
AUTHOR AND COPYRIGHT
Copyright (c) 1997-2002 Tom Christiansen and Nathan
Torkington, and other contributors as noted. All rights
reserved.
This posting is provided in the hope that it will be useful but
does not represent a commitment or contract of any kind on the part
of the contributers, authors or their agents.
------------------------------
Date: Wed, 2 Nov 2005 16:29:47 +0000
From: "Alan J. Flavell" <flavell@ph.gla.ac.uk>
Subject: Re: IIS 5.1 + Perl
Message-Id: <Pine.LNX.4.62.0511021614030.26458@ppepc56.ph.gla.ac.uk>
On Wed, 2 Nov 2005, A. Sinan Unur wrote:
> "Alan J. Flavell" <flavell@ph.gla.ac.uk> wrote in
> news:Pine.LNX.4.62.0511021047440.25732@ppepc56.ph.gla.ac.uk:
>
> > On Wed, 2 Nov 2005, A. Sinan Unur wrote:
> >
> >> On my system, I get the same response if I try to access the default
> >> printenv.pl script that came with Apache.
> >
> > Sounds as if you're not up to date with MS software fixes :-{
>
> Help -> About shows:
>
> Version 6.0.2900.2180.xpsp2_gdr.050301-1519
> Update Versions:; SP2;
>
> I don't know how much more up-to-date I can be.
OK; then maybe MS haven't done what they appeared to be promising.
:-(
That "gdr" in the version string seems somehow apt...
When they said:
Note In Internet Explorer 6 for Microsoft Windows XP Service Pack 2
(SP2), the Multipurpose Internet Mail Extensions (MIME) type
"text/plain" is not ambiguous
I'm afraid I took "not ambiguous" to claim that they would now always
interpret text/plain as text/plain, whereas previously they had only
sometimes done so. Guess I should not have been so credulous.
I suppose "not ambiguous" *could* mean that they now claim always to
interpret text/plain as the same "thing", whatever that "thing" might
be, but that the "thing" is not what MIME defines to be text/plain.
Sigh.
------------------------------
Date: Wed, 02 Nov 2005 22:13:31 GMT
From: "Todd W" <toddrw69@excite.com>
Subject: Re: IIS 5.1 + Perl
Message-Id: <fSaaf.4506$Y61.1717@newssvr33.news.prodigy.com>
"John Bokma" <john@castleamber.com> wrote in message
news:Xns97022F5E3DBF0castleamber@130.133.1.4...
> ko <kuujinbo@hotmail.com> wrote:
>
> > ASP:
> > http://aspn.activestate.com/ASPN/docs/ActivePerl/5.8/Windows/
> > ActiveServerPages.html
>
> Thanks, that looks useful.
>
> The problem I had was solved by not using text/plain as Sinan pointed
> out. (So much for simple Hello, World! test scripts :-( )
>
I just played with my printenv.pl program and can also confirm the behavior
that people are seeing on Win2k SP4.
Changing the file extension to .cgi made it behave as desired, though.
Todd W.
------------------------------
Date: Wed, 2 Nov 2005 22:15:05 +0000
From: "Alan J. Flavell" <flavell@ph.gla.ac.uk>
Subject: Re: IIS 5.1 + Perl
Message-Id: <Pine.LNX.4.62.0511022200180.30649@ppepc56.ph.gla.ac.uk>
On Wed, 2 Nov 2005, John Bokma wrote:
> (Don't you love not being able to copy text from an about box).
Don't I just!!! I've considered installing text-recognition software
to read those damned things for quoting... (but never quite got a
Round Tuit).
> > When they said:
> >
> > Note In Internet Explorer 6 for Microsoft Windows XP Service Pack 2
> > (SP2), the Multipurpose Internet Mail Extensions (MIME) type
> > "text/plain" is not ambiguous
>
> Read the rest: "is never rendered as HTML in the restricted zone"
Elsewhere it says:
Note In Windows XP SP2, Internet Explorer will never upgrade a
file declared as a known type to a file type of higher privilege.
For example, a text/plain document will never be upgraded
^^^^^^^^^^^^
to text/html.
which seems to be yet another variation on their reality.
Quite what "the restricted zone" is doing in the first statement, if
the second statement is true as written, is left as an exercise to the
student.
Note the "for example", as if there are other possibilities (e.g
downgrading a text/plain document to an amorphous bag of bytes ?).
But they have promised us that text/plain is now "not ambiguous" - how
are we supposed to interpret that? If they aren't promising that it
can now only mean one thing - what *does* it mean?
Oh well, I suppose it's not worth worrying about - the only thing we
can be pretty sure about is that it still won't conform to the
interworking specifications (and probably never will).
> > Sigh.
>
> Yes!
(and so say all of us...)
cheers anyway.
------------------------------
Date: Wed, 2 Nov 2005 22:25:39 +0000
From: "Alan J. Flavell" <flavell@ph.gla.ac.uk>
Subject: Re: IIS 5.1 + Perl
Message-Id: <Pine.LNX.4.62.0511022215270.30649@ppepc56.ph.gla.ac.uk>
On Wed, 2 Nov 2005, John Bokma wrote:
> "Alan J. Flavell" <flavell@ph.gla.ac.uk> wrote:
>
> > You (and anyone else concerned) should use a www-compatible
> > browser.
>
> No,
With respect, I said "should".
> I (and anyone else concerning developing software for the public)
> should make it work.
But it *does* work, according to MS. It does what MS *want* it to do,
and their customers have chosen the MS product. Isn't that good
enough?
> There is little selling point if I can say to my customer: hey, this
> works in www compatible browsers, so 90% of your visitors have to
> switch :-D.
It's doing just what MS have decided it should do. I didn't say they
*have to* switch - I only expressed the opinion that they should.
Oh, you meant you wanted IE to do what you *intended*? That's not
necessarily the same thing as "working", though. SCNR.
cheers
------------------------------
Date: Wed, 2 Nov 2005 21:58:04 +0100
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: s/// and modifiers m and s (was: Re: s///x)
Message-Id: <dkbcph.1h8.1@news.isolution.nl>
Gunnar Hjalmarsson:
> Dr.Ruud:
>> Gunnar Hjalmarsson:
>>> Note that the /s modifier is redundant (see "perldoc perlre").
>>
>> I don't consider the /s modifier redundant. It was not needed in my
>> example, so maybe you meant "redundant here"?
>
> Okay, redundant (or extraneous...) here. I mentioned it because people
> misunderstand the meaning of it all the time, and I believe one reason
> for that is that "perldoc perlre" - unlike e.g. "perldoc perlop" - is
> the only place in the docs (to my knowledge) where its meaning is
> properly explained.
OK. It would be nice to have an educational piece of code about /m and
/s.
Let me make a start:
# a.1: without /s, the .* will match up to the first \n
$ echo 'first
second
third' | perl -pe 's/.*/#/'
#
#
#
# a.2: with /s, the .* will match until the very end
$ echo 'first
second
third' | perl -pe 's/.*/#/s'
###
# b.1: without /s or /m, the .$ will match nothing if there are
# two newlines at the end
$ echo 'first
second
third' | perl -pe '$_.="\n"; s/.$/#/'
first
second
third
# b.2: with /s, the .$ will match anything before the last \n
$ echo 'first
second
third' | perl -pe '$_.="\n"; s/.$/#/s'
first#
second#
third#
# b.3: with /m, the .$ will match anything before the first \n
$ echo 'first
second
third' | perl -pe '$_.="\n"; s/.$/#/m'
firs#
secon#
thir#
--
Affijn, Ruud
"Gewoon is een tijger."
------------------------------
Date: 02 Nov 2005 21:45:33 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: s///x
Message-Id: <slrndmicrt.jik.abigail@alexandra.abigail.nl>
Gunnar Hjalmarsson (noreply@gunnar.cc) wrote on MMMMCDXLVI September
MCMXCIII in <URL:news:3ss54cFpe3koU1@individual.net>:
** Dr.Ruud wrote:
** > Gunnar Hjalmarsson schreef:
** >>Note that the /s modifier is redundant (see "perldoc perlre").
** >
** > I don't consider the /s modifier redundant. It was not needed in my
** > example, so maybe you meant "redundant here"?
**
** Okay, redundant (or extraneous...) here. I mentioned it because people
** misunderstand the meaning of it all the time, and I believe one reason
** for that is that "perldoc perlre" - unlike e.g. "perldoc perlop" - is
** the only place in the docs (to my knowledge) where its meaning is
** properly explained.
Damian makes a good argument in PBP to always use /s and /m.
I don't think it's worth raising your finger if someone uses /s or /m
on a regex where it doesn't matter. It's like complaining someone uses
'use warnings' on a piece of code where it didn't matter.
Abigail
--
perl -we 'print split /(?=(.*))/s => "Just another Perl Hacker\n";'
------------------------------
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 8599
***************************************