[24490] in Perl-Users-Digest
Perl-Users Digest, Issue: 6670 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jun 9 11:05:59 2004
Date: Wed, 9 Jun 2004 08:05:09 -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 Wed, 9 Jun 2004 Volume: 10 Number: 6670
Today's topics:
Re: Beginner needs help with script :) nobull@mail.com
Re: CGI::Cookie Setting Expiry chris-usenet@roaima.co.uk
Re: CGI::Cookie Setting Expiry <ducott_99@yahoo.com>
Re: CGI::Cookie Setting Expiry <1usa@llenroc.ude>
convert accented characters to root character? <bigal187.invalid@adexec.com>
Re: convert accented characters to root character? <ittyspam@yahoo.com>
Re: convert accented characters to root character? <pinyaj@rpi.edu>
Re: convert accented characters to root character? <thundergnat@hotmail.com>
Re: convert accented characters to root character? <jurgenex@hotmail.com>
Re: Converting a string to multiple search patterns <tore@aursand.no>
Re: Converting a string to multiple search patterns (Anno Siegel)
Re: Converting a string to multiple search patterns (Anno Siegel)
Re: Cute bit of Perl to Assign $1,$2 to named variables <bik.mido@tiscalinet.it>
Re: Cute bit of Perl to Assign $1,$2 to named variables (Christopher Hamel)
Re: Cute bit of Perl to Assign $1,$2 to named variables <uri@stemsystems.com>
Re: killing my children (Oliver)
Re: Magic var for Current "Index" in array within loop? <lawrence.tierney@bipsolutions.com>
Re: Magic var for Current "Index" in array within loop? <bik.mido@tiscalinet.it>
Re: Magic var for Current "Index" in array within loop? <bik.mido@tiscalinet.it>
Re: match aaa but not 123aaa <ken_sington@nospam_abcdefg.com>
Re: match aaa but not 123aaa <fatted@spymac.com>
Re: New to Perl: Need help with a script (Jim Moser)
Re: No-install Perl Interpretor <mick.lan@laposte.net>
Re: No-install Perl Interpretor (Richard Williams)
Perl cgi on Windows 2003 Server fails (Hallvard ?strem)
search engine (Nitin Thakur)
Re: signal not being caught when re-exec()d <pinyaj@rpi.edu>
Re: sub returning nothing <nobull@mail.com>
Re: sub returning nothing (Anno Siegel)
Threads and shared blessed references <vetro@online.no>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 9 Jun 2004 05:13:30 -0700
From: nobull@mail.com
Subject: Re: Beginner needs help with script :)
Message-Id: <4dafc536.0406090413.2106b642@posting.google.com>
"Andrew DeFaria" <Andrew@DeFaria.com> wrote in message news:<89626$40c66fea$c09cfc9$23187@msgid.meganewsservers.com>...
> "Player" <notachance@inhell.com> wrote in message
> news:ca5p3a$di0$1@newsg4.svr.pol.co.uk...
> >
> > > Sorry Tad I can't let that go unchallnged.
> > >
> > > On entering any new social situation (club, workplace, country) one is
> > > expected to research (or at least try to observe) what is accepted
> > > behaviour. Not doing so would be classed as bein rude by any normal
> > > person.
> > >
> > > Usenet is no different at all. We should not give 'Player' the get
> > > out clause of preteding that what he did would not be seen as rude in
> > > the 'real world'.
> >
> > I wouldn't, many a person says, "I beg your pardon" or words to similar
> > effect when confronted with replies similar to what experienced, and that
> > is more or less how I replied.
>
> Or perhaps, "Excuse me, where's the bathroom".
Note for non-English speakers (and people unable to read intonation in
plaintext :-) )...
In English (and especially American English, IIRC) the phrase "I beg
your pardon" has two distinct meanings depending on tone of voice. In
one tone it means "I'm sorry, what have I done wrong?". In another it
is roughly equivalent to "screw you!".
Andrew, I suspect you are mis-reading Player's statement that his
response was '"I beg your pardon" or words to similar effect' as
meaning that he politely enquired what he had done wrong (which would,
of course, have been acceptable[1]).
This indeed is how I initially read his statement and I thought: how
can this guy think he can get away with making such obviously false
assertions about his previous behaviour when the truth is archived for
all to see?
If you go back look at Player's response you'll realise that when he
says that his words were to similar a effect as "I beg your pardon" he
is, in fact, referring to the use of this phrase in the tone of voice
where it means "screw you!".
So Player is being quite honest when he says that his response to
being advised that had acted in a way contray to local custom was
words to the effect of "screw you!". He is also right that there many
people who react will like that. He is wrong in his assertion
(delusion?) that those people are not generally considered rude[2].
[1] Barely acceptable - it is better to take a step back, look around
you and try to figure out what you'd done wrong and then just say
sorry.
[2] I'm sure there are specialised cultures where it is considered
acceptable.
------------------------------
Date: Wed, 9 Jun 2004 09:03:57 +0100
From: chris-usenet@roaima.co.uk
Subject: Re: CGI::Cookie Setting Expiry
Message-Id: <dssip1-0rg.ln1@moldev.cmagroup.co.uk>
Tad McClellan <tadmc@augustmail.com> wrote:
> If you have perl installed, you should have all its docs installed
> right along with it.
I agree with "should". However, on Debian's GNU/Linux distribution you
have to install a separate documentation package.
Just FYI.
Chris
------------------------------
Date: Wed, 09 Jun 2004 08:40:58 GMT
From: "Robert TV" <ducott_99@yahoo.com>
Subject: Re: CGI::Cookie Setting Expiry
Message-Id: <u2Axc.678607$Pk3.221641@pd7tw1no>
"Tad McClellan" <tadmc@augustmail.com> wrote
> Robert TV <ducott_99@yahoo.com> wrote:
>
> Why is that?
>
I just build and run my scripts out of the cgi-bin on my hosting server. I
dont run a server or have anything "installed".
RV
------------------------------
Date: 9 Jun 2004 10:40:53 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude>
Subject: Re: CGI::Cookie Setting Expiry
Message-Id: <Xns950343F7787A8asu1cornelledu@132.236.56.8>
"Robert TV" <ducott_99@yahoo.com> wrote in
news:u2Axc.678607$Pk3.221641@pd7tw1no:
> "Tad McClellan" <tadmc@augustmail.com> wrote
>> Robert TV <ducott_99@yahoo.com> wrote:
>>
>> Why is that?
>>
> I just build and run my scripts out of the cgi-bin on my hosting
> server. I dont run a server or have anything "installed".
That is not smart. I'd recommend downloading Apache and ActivePerl (since
you seem to be on Windows) and installing them locally.
--
A. Sinan Unur
1usa@llenroc.ude (reverse each component for email address)
------------------------------
Date: Wed, 9 Jun 2004 06:08:06 -0700
From: "187" <bigal187.invalid@adexec.com>
Subject: convert accented characters to root character?
Message-Id: <2iogdoFp9jsiU1@uni-berlin.de>
I'm wondering if theres a nice clean way to convert accented characters
to the root character, like 'À' (A with mark above it) to 'A', or 'Ð' (D
with a horizontal line in the middle) to 'D' or 'Ñ' (spanish N with
tilde above it) to 'N'.
Or is it bettter to make a conversion table (hash) to map them? (I would
like to avoid this if theres a better way.)
Thank you.
------------------------------
Date: Wed, 9 Jun 2004 09:16:09 -0400
From: Paul Lalli <ittyspam@yahoo.com>
Subject: Re: convert accented characters to root character?
Message-Id: <20040609091240.O8971@dishwasher.cs.rpi.edu>
On Wed, 9 Jun 2004, 187 wrote:
> I'm wondering if theres a nice clean way to convert accented characters
> to the root character, like '=C0' (A with mark above it) to 'A', or '=D0'=
(D
> with a horizontal line in the middle) to 'D' or '=D1' (spanish N with
> tilde above it) to 'N'.
>
> Or is it bettter to make a conversion table (hash) to map them? (I would
> like to avoid this if theres a better way.)
>
Unless you're asking something I'm not understanding (to which I will
always admit the possibility), we *just* had a thread on this. As in,
within the past two days. Common usenet courtesy dictates that you at
least browse a newsgroup for a bit before posting. The original message
in the thread can be found (among other places) at
http://groups.google.com/groups?hl=3Den&lr=3D&ie=3DUTF-8&safe=3Doff&selm=3D=
ca0va1%24o5l%241%40planja.arnes.si
or search for a message with the title "convert unicode string" sent on
June 6, 2004.
If this thread does not answer your question, please explain how your
question is different.
Paul Lalli
------------------------------
Date: Wed, 9 Jun 2004 09:35:08 -0400
From: Jeff 'japhy' Pinyan <pinyaj@rpi.edu>
Subject: Re: convert accented characters to root character?
Message-Id: <Pine.SGI.3.96.1040609093340.32334A-100000@vcmr-64.server.rpi.edu>
On Wed, 9 Jun 2004, 187 wrote:
>I'm wondering if theres a nice clean way to convert accented characters
>to the root character, like '=C0' (A with mark above it) to 'A', or '=D0' =
(D
>with a horizontal line in the middle) to 'D' or '=D1' (spanish N with
>tilde above it) to 'N'.
>
>Or is it bettter to make a conversion table (hash) to map them? (I would
>like to avoid this if theres a better way.)
I copied this out of the source code for sirc:
tr{\x80-\xff}
{\x00-\x1f!cLxY|$_ca<\-\-R_o+23\'mp.,1o>123?AAAAAAACEEEEIIIIDNOOOOO*0UU=
UUYPBaaaaaaaceeeeiiiidnooooo:0uuuuypy};
--=20
Jeff Pinyan RPI Acacia Brother #734 RPI Acacia Corp Secretar=
y
"And I vos head of Gestapo for ten | Michael Palin (as Heinrich Bimmler=
)
years. Ah! Five years! Nein! No! | in: The North Minehead Bye-Electio=
n
Oh. Was NOT head of Gestapo AT ALL!" | (Monty Python's Flying Circus)
------------------------------
Date: Wed, 09 Jun 2004 10:17:06 -0400
From: thundergnat <thundergnat@hotmail.com>
Subject: Re: convert accented characters to root character?
Message-Id: <40c71bde$0$11941$61fed72c@news.rcn.com>
187 wrote:
> I'm wondering if theres a nice clean way to convert accented characters
> to the root character, like 'À' (A with mark above it) to 'A', or 'Ð' (D
> with a horizontal line in the middle) to 'D' or 'Ñ' (spanish N with
> tilde above it) to 'N'.
>
> Or is it bettter to make a conversion table (hash) to map them? (I would
> like to avoid this if theres a better way.)
>
> Thank you.
I wrote a small sub to do just this for a program I wrote that needed to
sort lists of words into a sort of faux alphabetical order. It is
obviously NOT going to work for unicode text containing characters above
255 but it is pretty effective as long as the characters fall within
the Latin-1 (ISO 8859-1) range.
It may be more efficient to remove the short circuit line that checks to
see if there IS a character that needs to be transliterated, depending
on your mix of words. If many (most) of the words need the transform, it
is just adding overhead. If the words that need transform are sparse in
your list, it can cut down significantly on unnecessary transforms and
substitutions.
I used the sub for sorting, but it is easily adapted for other uses.
@sorted = sort { deaccent(lc($a)) cmp deaccent(lc($b)) } @list;
sub deaccent{
my $phrase = shift;
return $phrase unless ($phrase =~ m/[\xC0-\xFF]/);
$phrase =~
tr/ÀÁÂÃÄÅàáâãäåÇçÈÉÊËèéêëÌÍÎÏìíîïÒÓÔÕÖØòóôõöøÑñÙÚÛÜùúûüÝÿý/AAAAAAaaaaaaCcEEEEeeeeIIIIiiiiOOOOOOooooooNnUUUUuuuuYyy/;
$phrase =~ s/\xC6/AE/g;
$phrase =~ s/\xE6/ae/g;
return $phrase;
}
------------------------------
Date: Wed, 09 Jun 2004 15:01:33 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: convert accented characters to root character?
Message-Id: <hDFxc.33$H65.22@nwrddc02.gnilink.net>
187 wrote:
> I'm wondering if theres a nice clean way to convert accented
> characters to the root character, like 'À' (A with mark above it) to
> 'A', or 'Ð' (D with a horizontal line in the middle) to 'D' or 'Ñ'
> (spanish N with tilde above it) to 'N'.
Didn't we just (like two days ago) have this discussion in the thread "
Re: Convert unicode string to "basic characters"
"?
Is there anything that you believe was not covered in that discussion? Then
you may want to point out specifically which issues you like to discuss in
more detail.
As has been pointed out there, are you certain you want to convert e.g. "to
hear" ("höra") into "whore" ("hora") or "Austria" ("Österreich") into
"Easter Empire" ("Osterreich")?
jue
------------------------------
Date: Wed, 09 Jun 2004 10:52:40 +0200
From: Tore Aursand <tore@aursand.no>
Subject: Re: Converting a string to multiple search patterns
Message-Id: <pan.2004.06.09.08.42.34.164489@aursand.no>
On Tue, 08 Jun 2004 21:49:08 -0400, Brad Baxter wrote:
>>> Of course, my interpretation may simply be wrong.
>> Or mine. It's Tore's problem, let him worry about it. :-)
> Indeed. He has certainly gotten some food for thought.
No shit, Sherlock?! :) I thought I had the way I wanted the patterns all
laid out, but you've really made me unsure; all the suggestions and
comments I get in this group is really helpful.
--
Tore Aursand <tore@aursand.no>
"What we see depends mainly on what we look for." (Sir John Lubbock)
------------------------------
Date: 9 Jun 2004 09:25:33 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Converting a string to multiple search patterns
Message-Id: <ca6l2d$55l$1@mamenchi.zrz.TU-Berlin.DE>
Tore Aursand <tore@aursand.no> wrote in comp.lang.perl.misc:
> On Tue, 08 Jun 2004 14:18:22 -0700, Randal L. Schwartz wrote:
> > It appears as though you are sorting on "edit distance", which is a
> > well-defined term, and even has a module, String::Approx, to compute
> > it.
> > [...]
>
> Hmm. I've already had a look at String::Approx, but I don't think it will
> help me solve this.
>
> Remember that 'A B C D' really are four _words_;
>
> my $query = 'A B C D'; # What the user wants to search for
> my @words = split( /\s+/, $query );
>
> Is there really no module which lets you do something like the following?
>
> my @words = ( whatever );
> foreach ( @Documents ) {
> my $score = search( $_->text(), \@words );
> }
>
> Or something? I want it! :)
There's Text::Scan, advertising "Fast search for very large numbers of
keys in a body of text".
There must be stacks of literature about text searches, but if I had
to tackle the problem from scratch I'd first extract all matches and
their positions and take it from there.
my $rex = join '|', map "\\b$_\\b", @words;
my @matches;
push @matches, [ $1, $-[ 0]] while $text =~ /($rex)/g;
Now @matches contains all information about the distribution of
the words in the text. The rest is fun with combinatorics :)
Anno
------------------------------
Date: 9 Jun 2004 10:50:58 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Converting a string to multiple search patterns
Message-Id: <ca6q2i$8k4$1@mamenchi.zrz.TU-Berlin.DE>
Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote in comp.lang.perl.misc:
> Jeff 'japhy' Pinyan <pinyaj@rpi.edu> wrote in comp.lang.perl.misc:
[...]
> > Run that code through '| sort -n', and you'll get:
> >
> > 2 A
> > 2 B
> > 2 C
> > 2 D
> > 2 E
> > 4 AC
> > 4 AD
> > 4 AE
> > 4 BD
> > 4 BE
> > 4 CE
> > 6 AB
> > 6 ACE
> > 6 BC
> > 6 CD
> > 6 DE
> > 8 ABD
> > 8 ABE
> > 8 ACD
> > 8 ADE
> > 8 BCE
> > 8 BDE
>
> [...]
>
> >
> > which I think is consistent with the rules.
>
> Consistent, yes, and the fact that it sorts all combinations of n before
> those of n+1 is significant.
...or would be, if it were a fact. But "ACE" and "AB" both have scores
of 6, so it isn't. (It is true for all combinations of "A" .. "D".)
I'm afraid, the proposed scoring system is a remarkably close match
to the intended sequence, but it doesn't produce it for larger n.
Anno
------------------------------
Date: Wed, 09 Jun 2004 12:36:06 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Cute bit of Perl to Assign $1,$2 to named variables
Message-Id: <crodc0l3pchucfroqmd6v3u4da8huf72qt@4ax.com>
On 8 Jun 2004 08:07:00 -0700, genericax@hotmail.com (Sara) wrote:
>Unfortunately it's taboo here to be a long-time Perl programmer and
>not know every possible language construct, or every line of every
>Perldoc. Right or wrong, that's the nature of your set of critics
>here.
Let me express better my opinion on this case: what you say may be
correct, to some extent. But only to some extent: in fact we're not
talking *here* of some arcane language construct that is probably well
documented somewhere in the docs but reasonably not known to
everybody. We're talking of a (two, really) basic feature(s) of perl
that one can hardly imagine to be oversighted for much time.
To make a comparison, it's *not* like one popping out saying "Hey, I
just discovered that this car has a special safety device that you can
activate with a button under the steering wheel", but saying instead
"Hey, I just discovered that this car has a cool device called
steering-wheel that results to be very useful indeed!".
This is MHO, anyway...
Michele
--
you'll see that it shouldn't be so. AND, the writting as usuall is
fantastic incompetent. To illustrate, i quote:
- Xah Lee trolling on clpmisc,
"perl bug File::Basename and Perl's nature"
------------------------------
Date: 9 Jun 2004 06:06:05 -0700
From: hamelcd@hotmail.com (Christopher Hamel)
Subject: Re: Cute bit of Perl to Assign $1,$2 to named variables
Message-Id: <4f60d5b3.0406090506.10823a01@posting.google.com>
Uri Guttman <uri@stemsystems.com> wrote in message news:<x73c55ir4u.fsf@mail.sysarch.com>...
> CH> I, for one, love &&=. Most others seem to feel it's as useless and
> CH> obscure as the "reset" function, but I think it's quite useful and
> CH> very Perl-esque.
>
> i have used it in one place i can find where i will zero out a flag if
> another flag is zero:
>
> $entry->{'flag'} &&= $flag_val ;
>
> show some of your uses of that.
>
> uri
I know that program execution speed is not generally viewed as a
strong selling point of Perl, but for what I do, speed is very
important, and Perl is quite nice. Bear that in mind when you read
why I like &&= and are asking why I don't just use a database.
The most common application is when I have a file with lots of records
(millions) and I only actually need a subset (thousands, typically)
for any given run of the program (these programs run daily, and the
data changes daily). Those that I need have been identified earlier
in the program, something like this:
# This is a part I'm concerned with:
$part_info{$part} = [ ];
When I'm reading the huge file, I need to pull data elements related
to each part number, but I only need them for the small set of records
I've identified:
while (<INFILE>) {
my ($part, $description, $cost, $lead_time) = (split)[0, 5..7];
## fill the hash here
}
I suppose I could do:
$part_info{$part} = [ $description, $cost, $lead_time ]
if $part_info{$part}
or
if (my $ref = $part_info{$part}) {
@$ref = ($description, $cost, $lead_time)
}
But I like the look of:
$part_info{$part} &&= [ $description, $cost, $lead_time ]
I use it other places as well, but it's typically based on the same
concept. I have identified a set of [something] that I need to gather
more info on the elements.
If anyone has a better way to achieve this, I'm game.
Thanks,
Chris
------------------------------
Date: Wed, 09 Jun 2004 13:51:02 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Cute bit of Perl to Assign $1,$2 to named variables
Message-Id: <x71xkog7qt.fsf@mail.sysarch.com>
>>>>> "CH" == Christopher Hamel <hamelcd@hotmail.com> writes:
CH> Uri Guttman <uri@stemsystems.com> wrote in message news:<x73c55ir4u.fsf@mail.sysarch.com>...
>>
>> $entry->{'flag'} &&= $flag_val ;
CH> The most common application is when I have a file with lots of records
CH> (millions) and I only actually need a subset (thousands, typically)
CH> for any given run of the program (these programs run daily, and the
CH> data changes daily). Those that I need have been identified earlier
CH> in the program, something like this:
so i presume $part_info{$part} was stuffed with [] earlier when you
decided that $part was an interesting part.
CH> I suppose I could do:
CH> $part_info{$part} = [ $description, $cost, $lead_time ]
CH> if $part_info{$part}
CH> or
CH> if (my $ref = $part_info{$part}) {
CH> @$ref = ($description, $cost, $lead_time)
CH> }
that is my typical style. i do plenty of grab a ref from a hash and if
we have one, mung it.
CH> But I like the look of:
CH> $part_info{$part} &&= [ $description, $cost, $lead_time ]
hmmm. amusing. i think i could use that in some of my cases. but i think
it is a little too obscure for typical coders to grok at first
glance. there are plenty of times when i post you need to code beyond
baby perl but that one gets into huh? perl as it is such a rarely used
idiom. it could become a better idiom.
CH> I use it other places as well, but it's typically based on the
CH> same concept. I have identified a set of [something] that I need
CH> to gather more info on the elements.
now that you explained your use it makes sense. i might still steer
clear of &&= but it is good to see more logical uses for it.
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: 9 Jun 2004 02:15:21 -0700
From: spacehopper_man@yahoo.com (Oliver)
Subject: Re: killing my children
Message-Id: <5818fca8.0406090115.5741171e@posting.google.com>
> If the child inherits large data structures from the parent, it can
> take a *long* time to clean these up upon normal exit.
ahh - I feel enlightened - there shouldn't be large datastructures,
but maybe filehandles...or something
> Are the children burning CPU, or just sitting around idle?
just sitting around idle...
------------------------------
Date: Wed, 9 Jun 2004 08:59:37 +0100
From: "Lord0" <lawrence.tierney@bipsolutions.com>
Subject: Re: Magic var for Current "Index" in array within loop?
Message-Id: <frzxc.315$gp1.95@newsfe6-win>
> This question has been asked twice in .misc and once in .moderated in
> the last week^H^H^H^H fourtnight.
>
> Invisible Array Loop Counter?
> Basic newbie questions
> On "for (@foo)"
>
Oops sorry, I must admit I didn't think to look. That won't happen
again..........
As for my reason for asking the question - well rest assured it was nothing
to do with homework. I was just looking at a bit of code and was trying to
refactor it to remove the ugly "counters" etc. I thought that as we had $#
and $[ (knowledge of which I guess would preclude homework) we should
logically have a magic variable for the actual current array index, when
used in a loop. I did RTFM and couldn't find anything - which again
should've been a clue.
I quite like the
for(0..$#foo){
$foo[$_] do blah;
}
solution. Only prob is you have to refer to the array by name which you
don't using the following method:
for(@foo){
# I wish I had a cool magic to use here
$_ do blah
}
Anyway thanks for all the help
Lord0
http://ltierney.demon.co.uk
------------------------------
Date: Wed, 09 Jun 2004 12:36:07 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Magic var for Current "Index" in array within loop?
Message-Id: <dgodc0prt14ducn2j3om2g69l9en68ns93@4ax.com>
On Tue, 8 Jun 2004 16:47:18 +0100, "Lord0"
<lawrence.tierney@bipsolutions.com> wrote:
>Is there a magic variable which will return the current index of an array if
>used in a loop?
This has been asked exactly a week ago, and IMHO it is a faq, so that
maybe it may be considered for inclusion in the faq. I even remember
having asked the very same question myself once: the answer in any
case is "no"!
It is worth pointing out that on the one hand such a magic variable
would be less useful that one could initially think and that there are
probably "better WTDI", but on the other hand there are still a *few*
cases in which it would actually be mildly useful.
Michele
--
you'll see that it shouldn't be so. AND, the writting as usuall is
fantastic incompetent. To illustrate, i quote:
- Xah Lee trolling on clpmisc,
"perl bug File::Basename and Perl's nature"
------------------------------
Date: Wed, 09 Jun 2004 14:17:42 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Magic var for Current "Index" in array within loop?
Message-Id: <dgvdc0tr0qgtcu0ntu5ia11eo8rrftonig@4ax.com>
On Wed, 9 Jun 2004 08:59:37 +0100, "Lord0"
<lawrence.tierney@bipsolutions.com> wrote:
>refactor it to remove the ugly "counters" etc. I thought that as we had $#
>and $[ (knowledge of which I guess would preclude homework) we should
>logically have a magic variable for the actual current array index, when
^^^^^
^^^^^
The fact is that loops do not have to do *only* with arrays, and in
fact you generally do *not* loop over (lists that actually come from
single) arrays:
for (@a, @b, qw/foo bar baz/) {
$a[$myhypotheticalmagicvar]}=something($_);
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
}
Is that what I really want? May well be, but most often it won't!
>used in a loop. I did RTFM and couldn't find anything - which again
Again, as I wrote in my other post, IMHO there is a minority of cases
in which the hypothetical magic var would indeed come in handy...
Michele
--
you'll see that it shouldn't be so. AND, the writting as usuall is
fantastic incompetent. To illustrate, i quote:
- Xah Lee trolling on clpmisc,
"perl bug File::Basename and Perl's nature"
------------------------------
Date: Wed, 09 Jun 2004 06:52:16 -0400
From: Ken Sington <ken_sington@nospam_abcdefg.com>
Subject: Re: match aaa but not 123aaa
Message-Id: <fxednS2BPJJAdlvdRWPC-w@speakeasy.net>
Jay Tilton wrote:
> Ken Sington <ken_sington@nospam_abcdefg.com> wrote:
>
......
>
> /(?<!123)YaaaY/
>
> : my one liner didn't work
> : $x =~ s/(!\123)(Y)(a{3})(Y)/$1$2$3$4/g;
> : the ! doesn't seem to negate it.
>
> What did you read in perlre that made you believe it would?
isn't ! suppose to negate (and [^] of course)??
I thought I saw it used in regex somewhere, but I can't find it again.
Has anyone seen such a thing?
Or am I having one of my many delusions?
------------------------------
Date: Wed, 09 Jun 2004 13:57:57 +0200
From: Fatted <fatted@spymac.com>
Subject: Re: match aaa but not 123aaa
Message-Id: <2ioc3kFpseulU1@uni-berlin.de>
Ken Sington wrote:
> i have these arbitary strings
> "YaaaY" and "123YaaaY"
> I'm having trouble matching only if "aaa" exist between Ys without
> having 123 preceeding it.
>
> example:
> "YaaaY" --> pass
> " YaaaY " --> pass
> "XXXYaaaYXXX" --> pass
> "alskdjlkajf 123YaaaY laskdjf" --> fail
I think this will take care of the simple match:
my $string = '667999123YaaaY44adadfYaaaY';
while($string =~ /(123|)YaaaY/g)
{
unless($1 eq '123')
{
print "Found\n";
}
}
> for an extra bonus, how about if I wanted "aaa" to go between "[" and
> "]"? or ( and )?
If you mean That match string then becomes Y(aaa)Y or Y[aaa]Y, then:
my $string = '667999123YaaaY44adadfYaaaY Y[aaa]Y';
$string .= ' adagf123Y(aaa)Yblah33Y((aaa))YsausagesY(aaa)Y';
while($string =~ /(123|)Y([\(|\[]?)aaa([\)|\]]?)Y/g)
{
unless($1 eq '123')
{
if($2 eq '' && $3 eq '')
{
print "Found\n";
}
elsif($2 eq '(' && $3 eq ')')
{
print "Found\n";
}
elsif($2 eq '[' && $3 eq ']')
{
print "Found\n";
}
}
}
seems to work (matches 3 times).
------------------------------
Date: 9 Jun 2004 05:33:17 -0700
From: jamesmmoser@yahoo.com (Jim Moser)
Subject: Re: New to Perl: Need help with a script
Message-Id: <d3b7b1c8.0406090433.5a80f676@posting.google.com>
Wow Jeff,
Thanks for all the great input. I appreciate the pointers.
------------------------------
Date: Wed, 09 Jun 2004 16:13:47 +0200
From: Micla <mick.lan@laposte.net>
Subject: Re: No-install Perl Interpretor
Message-Id: <ca75up$m4o$1@s1.read.news.oleane.net>
Michele Dondi a écrit :
> On Mon, 07 Jun 2004 13:45:42 +0200, Micla <mick.lan@laposte.net>
> wrote:
>
>
>>Would anybody know a Perl version usable without any prior installation?
>>
>>One of the goals foreseen for it would be to have some "personal"
>>scripts on a USB memory key, immediately usable on any computer that I
>>have the opportunity to go on.
>>
>>But there are also other reasons to try to use Perl scripts without
>>installing Perl previously.
>
>
> IMHO it's unreasonable to think that you won't need at least some of
> the core modules. Now one possibility I have been thinking of for
> other reasons and with which I would like to make some experiments
> anyway is to spot the possibility[1] to put code in @INC to move
> *most*[2] of perl lib into, say, a zip archive. Of course this would
> be yet another instance of "trading time for space"...
>
>
>
> [1] That I recently mentioned in another thread, BTW!
> [2] It's obvious that a bunch of modules should remain available in a
> physical directory to make the thing work...
>
>
> Michele
Hi Michele,
... I just write this (n+1)th answer not to let you orphan while I will
be sleeping, since you strangely use precisely these hours to make your
replies ...
My question wasn't to use or not modules, but if necessary how to use
them without any prior "make install" if I have to run my scripts on a
machine on which I have no rights to install anything. So if Perl
modulesare needed, my only question is : how can I do that without any
install ? And in the good example, but not the exclusive case, of a USB
memory key, are there difficulties to put these damned modules on a key?
Thank's to help me (and the remaining part of the planet) solve this
problem definitely ...!!!
:-)))
Micla.
------------------------------
Date: Wed, 9 Jun 2004 14:29:03 +0000 (UTC)
From: rdwillia@hgmp.mrc.ac.uk (Richard Williams)
Subject: Re: No-install Perl Interpretor
Message-Id: <ca76rf$doa$1@helium.hgmp.mrc.ac.uk>
In article <lj8cc05ch2oo57hq69bke78nc6aobvgaes@4ax.com>,
Michele Dondi <bik.mido@tiscalinet.it> wrote:
>IMHO it's unreasonable to think that you won't need at least some of
>the core modules. Now one possibility I have been thinking of for
>other reasons and with which I would like to make some experiments
>anyway is to spot the possibility[1] to put code in @INC to move
>*most*[2] of perl lib into, say, a zip archive. Of course this would
>be yet another instance of "trading time for space"...
>[2] It's obvious that a bunch of modules should remain available in a
>physical directory to make the thing work...
Tinyperl for Windows rather cleverly manages to use dozens of modules, yet
the complete distribution is just 3 files (executable, 'PerlLib' as a
.dll, and a zipfile of modules), plus docs. The .dll contains the
Compress::Zlib XS module, which handles unpacking any other required
modules from the zipfile into a temporary directory on the fly. The
unpacked modules are deleted after use.
http://tinyperl.sourceforge.net/
Richard.
------------------------------
Date: 9 Jun 2004 02:28:21 -0700
From: hallvardost@hotmail.com (Hallvard ?strem)
Subject: Perl cgi on Windows 2003 Server fails
Message-Id: <79b0e251.0406090128.2536cc08@posting.google.com>
My well tested Perl CGI scripts will not run on my web server after
moving it from Windows NT 4.0 to a brand new Windows 2003 Server. The
web server software is FirstClass Server 7.1 from Open Text Corp.
(http://www.opentext.com/products/firstclass/), and the web server
setup is identical with the setup on NT, which should be OK. Perl
version on Windows 2003 Server is 5.806. Here are some of my
observations:
1. Scripts are running OK from the command prompt on the server, and
the Perl installation looks OK. I've been through the more classical
Perl for win32 pitfalls checks.
2. Client browser returns this message:
---
1.1 200 OK Server: FirstClass/7.1 Content-type: text/html Don't know
how to run /cgi-bin/example.pl
---
(Example.pl is a simple "Hello World" demo which runs OK from the
prompt -- and normally on any web server with CGI-capabillity.)
3. Compiled CGI scripts, e.g. EXE-files, runs OK on the server.
4. Checked out the system PATH environment variable, and it points at
C:\Perl\bin like it should.
5. Web server service is set up with the Local System user account,
and should have the proper access rights.
6. I've installed an Apache test server in order to rule out the
possibility that the problem somehow could be related to my FirstClass
Server setup. The symptoms were almost identical, allthough Apache
returned an not specified "Internal Server Error" message. Compiled
CGI ran OK on Apache as well.
In other words, there must be something in the Windows 2003 Server
setup that I've missed? It seems like FirstClass Server can't find the
Perl interpreter, even though the system PATH is OK. I've been through
loads of FAQs and documentation, but haven't come across a solution so
far. So I'll appreciate a helping hand on this.
Regards,
Hallvard Østrem
------------------------------
Date: 9 Jun 2004 04:31:57 -0700
From: nitinthakur@hotmail.com (Nitin Thakur)
Subject: search engine
Message-Id: <f65ac990.0406090331.78d70f8@posting.google.com>
Hi,
I have written a script, which lists text files from a directory on a
web page on our intranet site. I want to add search functionality to
this page so that users can grep a regular expression and it lists
those files. Is there any simple cgi/perl script available or can
somebody give me some pointers as to how to make one.
A speedy response would be appreciated.
Cheers
Nitin
Here is the code for the listing the files
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
#!/usr/bin/perl -w
#Set Dir path.
$dir = "/reports/";
use CGI qw/:all/;
$query = new CGI;
@months=qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec);
chdir $dir;
#Open dir and start listing and take time.
opendir (DIR, "$dir") || die "Can not Reports: $!";
foreach (readdir DIR) {
($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size, $atime,
$mtime, $ctime) = stat $_;
next if !$dev;
next if /^\./;
$dates{$_} = $mtime;
$rdev = " ";
$gid = " ";
$ino = " ";
$size = " ";
$uid = " ";
$mode = " ";
$atime = " ";
$ctime = " ";
$nlink = " ";
}
closedir DIR || die "Can not close Dir: $!";
print $query->header;
print $query->title('Reports');
print <<EOF;
<H2> Previously Sent Mails: </H2>
EOF
print "<TABLE>\n";
foreach (sort { $dates{$b} <=> $dates{$a}} keys %dates) {
print "<TR><TD>\n";
print "<b>";
{
$href="$dir$_";
$href=~s%//%/%g;
print (qq%<A HREF="/reports/$_">$_/</A>%);
}
print "</b>";
$date = (localtime($dates{$_}))[3] . " " .
$months[(localtime($dates{$_}))[4]] . " " .
(localtime($dates{$_}))[5]. " " .
(localtime($dates{$_}))[2] . ":" .
sprintf("%02d", (localtime($dates{$_}))[1]);
print "<TD>";
print qq% [$date]%;
print "<BR>\n";
print "</TR>\n";
}
print "</TABLE>\n";
print $query->end_html;
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
------------------------------
Date: Wed, 9 Jun 2004 09:35:53 -0400
From: Jeff 'japhy' Pinyan <pinyaj@rpi.edu>
Subject: Re: signal not being caught when re-exec()d
Message-Id: <Pine.SGI.3.96.1040609093522.32334B-100000@vcmr-64.server.rpi.edu>
On 8 Jun 2004, Michal Wojciechowski wrote:
>When the signal handler is triggered, the signal that caused it to run
>gets blocked. The new program called with exec inherits the signal
>mask, and therefore blocks the USR1 signal. To be able to catch it
>again, you need to reset the signal mask. Use the POSIX sigprocmask
>function:
>
> use POSIX qw(:signal_h);
>
> $sigset = POSIX::SigSet->new;
> sigprocmask(SIG_SETMASK, $sigset);
Ah ha. Thanks very much.
--
Jeff Pinyan RPI Acacia Brother #734 RPI Acacia Corp Secretary
"And I vos head of Gestapo for ten | Michael Palin (as Heinrich Bimmler)
years. Ah! Five years! Nein! No! | in: The North Minehead Bye-Election
Oh. Was NOT head of Gestapo AT ALL!" | (Monty Python's Flying Circus)
------------------------------
Date: 09 Jun 2004 09:02:32 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: sub returning nothing
Message-Id: <u9r7spnopz.fsf@wcl-l.bham.ac.uk>
Gunnar Strand <MyFirstnameHere.News1@gustra.org> writes:
> Brian McCauley wrote:
> > Gunnar Strand <MyFirstnameHere.News1@gustra.org> writes:
> [...]
> >>sub myvoid {
> >>}
> > That is not a subroutine returning nothing.
> > That is an empty function.
> > In a list context an empty function retunrns its arguments.
>
> It returns an empty list in a list context according to perlmod,
> and perl -e 'sub a{};print a(1, 2, 3)' prints nothing.
You are right, it does in 5.8. I was unaware that it has changed.
> > How ever I wouldn't consider this to be defined bevaviour. I
> > would be inclined to consider the behaviour of an empty function
> > wrt what it returns to be undefined.
Which, of course, is now bourne out to be very good advice wrt 5.6
because the behaviour in 5.8 is indeed different.
You say the new behaviour is documented in perlmod? I think you meant
perlsub. :-)
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: 9 Jun 2004 12:10:21 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: sub returning nothing
Message-Id: <ca6und$c8p$1@mamenchi.zrz.TU-Berlin.DE>
Brian McCauley <nobull@mail.com> wrote in comp.lang.perl.misc:
> Gunnar Strand <MyFirstnameHere.News1@gustra.org> writes:
>
> > Brian McCauley wrote:
> > > Gunnar Strand <MyFirstnameHere.News1@gustra.org> writes:
> > [...]
> > >>sub myvoid {
> > >>}
> > > That is not a subroutine returning nothing.
> > > That is an empty function.
> > > In a list context an empty function retunrns its arguments.
> >
> > It returns an empty list in a list context according to perlmod,
> > and perl -e 'sub a{};print a(1, 2, 3)' prints nothing.
>
> You are right, it does in 5.8. I was unaware that it has changed.
It doesn't for me in 5.8.1, that is, it prints "123". (I'll check
5.8.3 later). I cannot imagine that an incompatible change like this
would be made. Could some shell deviltry be obscuring the output?
> > > How ever I wouldn't consider this to be defined bevaviour. I
> > > would be inclined to consider the behaviour of an empty function
> > > wrt what it returns to be undefined.
>
> Which, of course, is now bourne out to be very good advice wrt 5.6
> because the behaviour in 5.8 is indeed different.
>
> You say the new behaviour is documented in perlmod? I think you meant
> perlsub. :-)
I can't find the *old* (and, I suspect, still current) behavior described
in the corresponding version of perldoc, and I was never aware of it
until now. (Speak of not knowing about fundamental language details...)
It could be taken as a consequence of the "last expression evaluated"
rule, though the argument list is nowhere visibly evaluated in the sub.
Anno
------------------------------
Date: Wed, 09 Jun 2004 15:55:04 +0200
From: "Vetle Roeim" <vetro@online.no>
Subject: Threads and shared blessed references
Message-Id: <opr9bx92bs3hk3cf@quickfix.opera.com>
Quote from threads::shared (Perl 5.8.3):
"bless" is not supported on shared references. In the current version,
"bless" will only bless the thread local reference and the blessing
will not
propagate to the other threads.
In other words, it's not possible to share references to objects. I.e.
the
following shouldn't work:
package Foo::Bar;
use threads;
use threads::shared;
sub new { my $self = &share( {} ); bless $self, shift; }
sub zot { print "zot\n"; }
my $foo = Foo::Bar->new;
threads->create( sub {
$foo->zot;
}
)->join;
Is that a correct interpretation? Because the code example does actually
work
without any problems.
I also found a mail that indicates that blessing of sharede references
should
indeed work:
<URL:http://groups.google.com/groups?selm=200306091100.h59B05PA018110%40smtp3.ActiveState.com&output=gplain>
Umm... So I guess my question is: is it safe to share blessed references
among
threads? :)
--
Touch eyeballs to screen for cheap laser surgery!
------------------------------
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 6670
***************************************