[17966] in Perl-Users-Digest
Perl-Users Digest, Issue: 126 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jan 23 11:10:43 2001
Date: Tue, 23 Jan 2001 08:10:19 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <980266218-v10-i126@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Tue, 23 Jan 2001 Volume: 10 Number: 126
Today's topics:
Re: Perl Crashes on my Win2k Box <gracenews@optusnet.com.au>
Re: Perl Crashes on my Win2k Box (Anno Siegel)
Re: Perl IPC: Unix domain sockets problem <bas@integrators.demon.nl>
POE oppinion (Miguel Manso)
Re: Posting email from PERL to Outlook (Exchange)??? (Dan)
Re: Powerful Technique 3606 <andrew@erlenstar.demon.co.uk>
Question about DBM write access and subprocesses <hafner-usenet@ze.tu-muenchen.de>
Re: Quick Newbie Qeustion please... <krahnj@acm.org>
Re: Random Numbers with a Twist Gordon.Haverland@agric.gov.ab.ca
read win-archive-bit with stat? <cnielsen@sinik.de>
Re: read win-archive-bit with stat? <wyzelli@yahoo.com>
Re: redirect system command to an array <ccx138@coventry.ac.uk>
Re: redirect system command to an array (Tad McClellan)
s/// inconsistency <roman@topologix.de>
Re: s/// inconsistency (Bernard El-Hagin)
Re: s/// inconsistency <wuerz@yahoo.com>
Re: s/// inconsistency (Martien Verbruggen)
Re: s/// inconsistency <wuerz@yahoo.com>
Re: s/// inconsistency <wuerz@yahoo.com>
Re: s/// inconsistency (Bernard El-Hagin)
Re: s/// inconsistency (Martien Verbruggen)
Re: s/// inconsistency <roman@topologix.de>
Socket error sgi_ripe@my-deja.com
Re: spawning a process that is a perl program <gracenews@optusnet.com.au>
Re: stability of threads + interpreter performance <not@defined.com>
Re: Still Can't Get MIME Lite To Send Attachment... (Villy Kruse)
Why <marekpow@email.hinet.hr>
Re: Why <meisl@amvt.tu-graz.ac.at>
Re: Why <angenent@kabelfoon.nl>
Re: Why <james@NOSPAM.demon.co.uk>
Re: Why <james@NOSPAM.demon.co.uk>
Re: Why (Tad McClellan)
Re: Why (Jens)
Re: Words - Pulling Hair <iboreham@my-deja.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 23 Jan 2001 22:56:39 +1000
From: "Jeffrey Grace" <gracenews@optusnet.com.au>
Subject: Re: Perl Crashes on my Win2k Box
Message-Id: <3a6d7f99$0$16376$7f31c96c@news01.syd.optusnet.com.au>
"H C" <carvdawg@patriot.net> wrote in message
news:3A6CED5C.DDBC8A8A@patriot.net...
> > >I am attempting to run a script and I get an
> > >error that says Perl has generated an error
> > >and must be shut down. Anybody have any
> > >idea why this is?
>
> Why bother speculating or even responding? The OP gave no information
> regarding Perl distro, and didn't even post the script. There no info
> on what
> the error was, or who the script was run.
>
> "I have a car. It doesn't work. Any ideas?" Ah...duh!
>
Yes it was a rather vague question, but if he's a newbie at Perl a curt
response will just give him a negative impression of this newsgroup and
possible the Perl community as a whole, besides it gets a typical response
from the original poster, which just extends the thread. I know the
netiquette (forgive the spelling) rule of "lurk for a month before posting"
is often quoted, but I could have sworn there was another (Been a little
while since I read them, and have since lost the link) to the effect of
"treat online messages the same as if you were sitting next to the
recipient", besides you never know, he could be a future employer.
It would have to be a pretty serious error to get the error he described ,
which is a windows error message (normally an illegal instruction or illegal
memory access) not a perl error message. I know a flock() error is shown by
perl, has anyone come across an error that caused Windows to forcibly kill
perl before? Hogan I suggest you search the ActivePerl web page to see if
there is any known issues with Windows 2000, or your installation may have a
corrupt file, or a DLL conflict.
--
Jeffrey Grace
~~~~~~~~~~~~~~~~~~~~
Queensland, Australia
------------------------------
Date: 23 Jan 2001 14:40:53 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Perl Crashes on my Win2k Box
Message-Id: <94k55l$ema$2@mamenchi.zrz.TU-Berlin.DE>
Hawk <someguyREMOVE@REMOVEsunflower.com> wrote in comp.lang.perl.misc:
>This forum is to help people.
Wrong. This newsgroup is for people who have an interest in the
Perl language.
> If you can not do that without your
>condescending remarks, I'd like to be the first to suggest that you take an
>extended leave of absence.
Wrong again. If you want free help, you'll have to take it at the
terms given, including what your perceived condescending remarks.
Or you have a choice?
The fact that no actual help was offered besides education in the
mores of this group may have to do with the fact that your problem
description was next to null.
Perhaps the ones that need to be "beaten off with
>a spoon" are the regulars with a god complex.
Oh yeah. Drive out the regulars, good idea.
Anno
------------------------------
Date: Tue, 23 Jan 2001 09:01:56 +0100
From: "Bas A. Schulte" <bas@integrators.demon.nl>
Subject: Re: Perl IPC: Unix domain sockets problem
Message-Id: <bas-230118.09015623012001@news.demon.nl>
In article <3A6C31D0.6012A2D8@mit.edu>, Nobody <karlm@mit.edu> wrote:
> while (1){
> print STDOUT "Server about to read\n"; #this gets executed.
> $input = <Client>; #This is where we hang.
> print STDOUT "Server read: $input\n"; #never reached.
You're probably being bitten by buffering. Try this on your socket:
my $old = select(SOCK); $| = 1; select($old);
Bas.
------------------------------
Date: Tue, 23 Jan 2001 15:40:29 GMT
From: mmanso@localhost.localdomain (Miguel Manso)
Subject: POE oppinion
Message-Id: <slrn96r9nq.cp.mmanso@localhost.localdomain>
Hi ppl.
I've beed reading some documents about a moddule named POE and it seems
very good for applications like daemons and stuff.
Did anyone tried this modulle already? Any oppinion about its usage on
big projects?
Thanks.
--
Miguel Manso
------------------------------
Date: Tue, 23 Jan 2001 10:40:43 -0500
From: "Daniel (Dan) Rosenzweig" <danr@att.com>
Subject: Re: Posting email from PERL to Outlook (Exchange)???
Message-Id: <3A6DA5FB.BB0449F8@att.com>
Rob,
Your counting code works (the version that you posted later)- as long as
you do:
use Win32::OLE qw(in with)
It gave me a quick start to this OLE stuff --- and the basis to what I was
working on.
Now to find a good ref page for Win32 OLE!
Thanks alot!
------------------------------
Date: 23 Jan 2001 15:09:48 +0000
From: Andrew Gierth <andrew@erlenstar.demon.co.uk>
Subject: Re: Powerful Technique 3606
Message-Id: <877l3mnw3n.fsf@erlenstar.demon.co.uk>
>>>>> "EtB" == Eli the Bearded <elijah@workspot.net> writes:
EtB> # Methodology: In normal English usage The frequencies of KQXJZ are
EtB> # at about 1.1% or all letters, while the vowels are at about 36.1%.
EtB> # (source http://144.118.28.202/class/insys300/LetterStatistics.html)
EtB> # Any line where these obscure letters are equal to or exceed vowels,
EtB> # and there are at least three of each group, is considered
EtB> # strong psuedotext. And line with at least twenty letters is weak
EtB> # psuedotext if fewer than 25% or more than 50% are vowels. Very
EtB> # weak psuedotext applies to any line meeting the above percentages,
EtB> # but has between six and nineteen letters.
I started with something like this for my auto-cancelling of spams
such as the one that triggered this thread, but I ended up simplifying
it considerably for various reasons. The spamware that produces this
particular pattern uses quite a wide range of line lengths, some quite
short, and I ran into a problem with distinguishing them from Polish
names written in lowercase at the end of an article.
(A similar kind of detector for the multi-paragraph gibberish
generated by the program known as 'HipCrime's NewsAgent' likewise had
to be adjusted slightly to avoid triggering on something that looked
like Serbo-Croat poetry or song lyrics.)
--
Andrew.
------------------------------
Date: 23 Jan 2001 09:29:31 +0100
From: Walter Hafner <hafner-usenet@ze.tu-muenchen.de>
Subject: Question about DBM write access and subprocesses
Message-Id: <srjg0iay8lw.fsf@w3projns.ze.tu-muenchen.de>
Hi there,
over the last days I wrote a server script that listens on a TCP
port. The script forks off children to answer connections. I used the
template in "perlipc.html" (look on the various manual sites; it's also
in "Programming Perl", pages 350ff) as a starting point.
The children then write data in DBM hashes that in turn can be retrieved
again by socket connections. Everything worked ok so far.
Then I added an "idle process" that forked off beforehand. That process
was intended to write periodically (every few seconds) into the same DBM
hashes as the other subprocesses, but it simply won't write any values
in the files.
Depending on the DBM package I use either the "idle process" can write
into the files or the dynamically forked processes, but not both of
them.
What am I doing wrong?
Yesterday I tried a different approach: The "idle process" connects to
the server process by TCP sockets, just like "ordinary" connections. Now
it writes every second value it is supposed to write. Don't ask me ...
Is there a simpler approach to get all the subprocesses to write into
the DBM files? Perhabs even a package on CPAN? Apart from FastPL I
didn't find any and FastPL doesn't do what I need (Unix-sockets,
children not dynamically forked).
Thanks
-Walter
------------------------------
Date: Tue, 23 Jan 2001 12:10:33 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Quick Newbie Qeustion please...
Message-Id: <3A6D75A1.EF0A73AA@acm.org>
Garry Williams wrote:
>
> On Sun, 21 Jan 2001 09:00:27 +0200, Ofir <ofirb@jdc.org.il> wrote:
> >I want to be able to determine how many lines are in a file.
> >What is the way (subroutine) to check the total number of lines written in a
> >file?
>
> sub lines {
> my $file = shift;
> return qx/grep -c '\$' $file/;
> }
sub lines {
my $file = shift;
return qx/wc -l $file/;
}
John
------------------------------
Date: Tue, 23 Jan 2001 13:58:58 GMT
From: Gordon.Haverland@agric.gov.ab.ca
Subject: Re: Random Numbers with a Twist
Message-Id: <3a6d8d78.412036016@news.gov.ab.ca>
>On 20 Jan 2001 00:42:40 GMT, abigail@foad.org (Abigail) wrote:
>
>>The hard part is deciding when to stop, that is, when is the set
>>random enough?
You are heading down a slippery path on this one! It is entirely
possible to "draw" random coordinates from a universe of points and
end up with something that is highly ordered/symmetric. It may be
unlikely, but it is possible. If you reject a given outcome for being
"unrandom" according to your personal feelings, you bias your results.
------------------------------
Date: Tue, 23 Jan 2001 10:41:03 +0100
From: "Carsten Nielsen" <cnielsen@sinik.de>
Subject: read win-archive-bit with stat?
Message-Id: <94jjjg$dleu3$1@ID-60175.news.dfncis.de>
Hi ng,
I've got a problem here:
I want to read the Archive-Bit of some files for backking up them in a
zip-Archive.
I know how to format (printf) the stat output[2] for permissons, but how can
I make the archive-bit visible? (maybe you can explain a bit about this
filemode octal system...).
post ya,
Carsten
--------------------------------------------------
first step to become a workoholic:
never say no.
------------------------------
Date: Tue, 23 Jan 2001 20:03:01 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: read win-archive-bit with stat?
Message-Id: <r5db6.4$c%4.1198@vic.nntp.telstra.net>
"Carsten Nielsen" <cnielsen@sinik.de> wrote in message
news:94jjjg$dleu3$1@ID-60175.news.dfncis.de...
> Hi ng,
>
> I've got a problem here:
>
> I want to read the Archive-Bit of some files for backking up them in a
> zip-Archive.
>
"Use the Module Luke"
use Win32::File;
Wyzelli
--
#Modified from the original by Jim Menard
for(reverse(1..100)){$s=($_==1)? '':'s';print"$_ bottle$s of beer on the
wall,\n";
print"$_ bottle$s of beer,\nTake one down, pass it around,\n";
$_--;$s=($_==1)?'':'s';print"$_ bottle$s of beer on the
wall\n\n";}print'*burp*';
------------------------------
Date: Tue, 23 Jan 2001 11:57:22 +0000
From: John Tutchings <ccx138@coventry.ac.uk>
Subject: Re: redirect system command to an array
Message-Id: <3A6D71A1.79A26A61@coventry.ac.uk>
Use back ticks.
@array = `find $ARCHIVE_ROOT -name '*-arc' -print`;
plandis98@my-deja.com wrote:
> How do I redirect a system command to an array? For instance, I want
> to get a list of files in a directory and it's sub directories so what
> I do is do a system find command :
>
> system("find $ARCHIVE_ROOT -name '*-arc' -print");
>
> But how would I redirect the list generated from the system find to an
> array?
>
> One solution that I came up with would output the list to a file and
> then read in the file and parse the list to an array? But this
> wouldn't be the most efficient way.
>
> thanks,
> Peter Landis
>
------------------------------
Date: Tue, 23 Jan 2001 14:56:23 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: redirect system command to an array
Message-Id: <slrn96quj0.22c.tadmc@tadmc26.august.net>
[ Jeopardectomy performed ]
John Tutchings <ccx138@coventry.ac.uk> wrote:
>plandis98@my-deja.com wrote:
>
>> For instance, I want
>> to get a list of files in a directory and it's sub directories so what
>> I do is do a system find command :
^^^^
You should read the documentation for the software that you are using.
If you use the system() function, you should read up on
the system() function.
>> system("find $ARCHIVE_ROOT -name '*-arc' -print");
perldoc -f system
"...This is I<not> what you want to use to capture the
output from a command, for that you should use ..."
^^^
^^^
and right there is the answer to your question!
Elapsed time? About 10-60 *seconds*.
How many seconds did it take to get the answer by posting to Usenet?
Tens of thousands of seconds perhaps.
Counting only _your_ time, you could have had your answer a
*thousand times* faster! That is likely to impress your boss.
Then we add in the time of hundreds or thousands of people who had
to read or filter out (or even answer) your Usenet post.
You sure have wasted a lot of global programmer's time that could
have been spent answering unanswered questions.
Please don't do that anymore.
Use the docs, Luke.
>> But how would I redirect the list generated from the system find to an
>> array?
Like it says in the description of the system() function that
you are using.
>Use back ticks.
>
>@array = `find $ARCHIVE_ROOT -name '*-arc' -print`;
That's what it says alright.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 23 Jan 2001 09:30:19 GMT
From: "Roman Moeller" <roman@topologix.de>
Subject: s/// inconsistency
Message-Id: <94jisk$qmm$1@crusher.de.colt.net>
Hi gurus,
From the following substitutions all but the last succeed.
#!/usr/bin/perl -w
use strict ;
$_='foobar';
my $sub = 'barfoo ';
s/foobar/$sub/;
print ;
$_='foobar';
s/(foo)(bar)/$2$1 /;
print ;
$_='foobar';
$sub = '$2$1 ';
s/(foo)(bar)/$sub/;
print ;
# output : barfoo barfoo $2$1
Obviously, backreferences stored in scalars are not interpreted.
But why ? To me thats inconsistent.
The ony way I found to make backreferences work inside scalars is
eval "s/(foo)(bar)/$sub/;";
but that's _ugly_ .
Any better ?
------------------------------
Date: Tue, 23 Jan 2001 09:52:26 +0000 (UTC)
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: s/// inconsistency
Message-Id: <slrn96ql2o.2q0.bernard.el-hagin@gdndev25.lido-tech>
On Tue, 23 Jan 2001 09:30:19 GMT, Roman Moeller <roman@topologix.de> wrote:
>Hi gurus,
>
>From the following substitutions all but the last succeed.
>
>#!/usr/bin/perl -w
>use strict ;
>
>$_='foobar';
>my $sub = 'barfoo ';
>s/foobar/$sub/;
>print ;
>
>$_='foobar';
>s/(foo)(bar)/$2$1 /;
>print ;
>
>$_='foobar';
>$sub = '$2$1 ';
>s/(foo)(bar)/$sub/;
>print ;
>
>
># output : barfoo barfoo $2$1
>
>Obviously, backreferences stored in scalars are not interpreted.
>But why ? To me thats inconsistent.
$sub is a single quoted string, thus it's treated literally. No
interpolation. On the other hand, if you use double quotes $sub won't be
initialised before the match occurs and you'll get a warning (if -w is
set).
Cheers,
Bernard
--
#requires 5.6.0
perl -le'* = =[[`JAPH`]=>[q[Just another Perl hacker,]]];print @ { @ = [$ ?] }'
------------------------------
Date: Tue, 23 Jan 2001 10:58:37 +0100
From: Mona Wuerz <wuerz@yahoo.com>
Subject: Re: s/// inconsistency
Message-Id: <230120011058373411%wuerz@yahoo.com>
In article <94jisk$qmm$1@crusher.de.colt.net>, <roman@topologix.de>
wrote:
> $_='foobar';
# $sub = '$2$1 ';
$sub = "$2$1 ";
> s/(foo)(bar)/$sub/;
> print ;
>
>
> # output : barfoo barfoo $2$1
# output : barfoo barfoo barfoo
(as far as I understand it, you're preventing interpolation of $1 and
$2 by using single quotes.)
-mona
------------------------------
Date: Tue, 23 Jan 2001 20:54:55 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: s/// inconsistency
Message-Id: <slrn96ql7f.n5q.mgjv@martien.heliotrope.home>
On Tue, 23 Jan 2001 09:30:19 GMT,
Roman Moeller <roman@topologix.de> wrote:
> Hi gurus,
>
> From the following substitutions all but the last succeed.
No, they all succeed. You are just doing something different in the last
one.
> #!/usr/bin/perl -w
> use strict ;
>
> $_='foobar';
> my $sub = 'barfoo ';
> s/foobar/$sub/;
> print ;
>
> $_='foobar';
> s/(foo)(bar)/$2$1 /;
> print ;
>
> $_='foobar';
> $sub = '$2$1 ';
> s/(foo)(bar)/$sub/;
> print ;
You could do something ugly like:
$sub = '"$2$1 "';
s/(foo)(bar)/$sub/ee;
# man perlop
[snip]
s/PATTERN/REPLACEMENT/egimosx
[snip]
`s<foo>/bar/'. A `/e' will cause the replacement
portion to be treated as a full-fledged Perl
expression and evaluated right then and there. It
is, however, syntax checked at compile-time. A
second `e' modifier will cause the replacement
portion to be `eval'ed before being run as a Perl
expression.
[snip]
> Obviously, backreferences stored in scalars are not interpreted.
> But why ? To me thats inconsistent.
It's not inconsistent to me at all. How many levels of indirection deep
should Perl go to find these? What about something like:
$foo = '$2$1 ';
$bar = '$foo';
$baz = '$bar';
$banana = '$baz';
s/(foo)(bar)/$banana/;
Would you expect that to end up as $baz? or $bar? or $foo? or $2$1? or
would you expect that to resolve the backreferences that you eventually
arrive at? I hope you see what I mean here.
$2 and $1 are just variables. They get used by Perl internally, but in
contexts like these they're the same as all the others.
> The ony way I found to make backreferences work inside scalars is
>
> eval "s/(foo)(bar)/$sub/;";
The /e option works better, because it only evaluates the right side of
the expression. Not the left.
> but that's _ugly_ .
Yep. Symbolic references are ugly.
> Any better ?
Yes. Don't do it this way. Maybe you should sort of explain to us what
it is you want to do, and maybe we can cone up with a better solution to
the problem. If you just want to reverse the two matches, a literal $2$1
in the right hand side of the s/// will do. But you're not using a
literal, so there must be some magical need oyu have that we're not
aware of. Once you tell us what that is, maybe we'll be able to tell you
whether you need to use ugly stuff, or whether you can use less ugly
stuff.
Martien
--
Martien Verbruggen |
Interactive Media Division | If it isn't broken, it doesn't have
Commercial Dynamics Pty. Ltd. | enough features yet.
NSW, Australia |
------------------------------
Date: Tue, 23 Jan 2001 11:06:24 +0100
From: Mona Wuerz <wuerz@yahoo.com>
Subject: Re: s/// inconsistency
Message-Id: <230120011106241483%wuerz@yahoo.com>
In article <slrn96ql2o.2q0.bernard.el-hagin@gdndev25.lido-tech>,
bernard.el-hagin@lido-tech.net wrote:
> On Tue, 23 Jan 2001 09:30:19 GMT, Roman Moeller <roman@topologix.de> wrote:
> >#!/usr/bin/perl -w
> >use strict ;
> >
> >$_='foobar';
> >$sub = '$2$1 ';
> >s/(foo)(bar)/$sub/;
> >print ;
> >
> >
> ># output : barfoo barfoo $2$1
>
> On the other hand, if you use double quotes $sub won't be
> initialised before the match occurs and you'll get a warning (if -w is
> set).
I can't confirm this. I cut-and-pasted Roman's code, and it produced no
warnings. I didn't think it would, as $sub isn't actually evaluated
before the s/// statement, so it doesn't matter whether or not it's
initialized. I'm curious, what did you think it would warn about?
-mona
------------------------------
Date: Tue, 23 Jan 2001 11:11:16 +0100
From: Mona Wuerz <wuerz@yahoo.com>
Subject: Re: s/// inconsistency
Message-Id: <230120011111169090%wuerz@yahoo.com>
(sorry for replying to myself, hit the send button too soon)
> In article <slrn96ql2o.2q0.bernard.el-hagin@gdndev25.lido-tech>,
> bernard.el-hagin@lido-tech.net wrote:
>
> > On Tue, 23 Jan 2001 09:30:19 GMT, Roman Moeller <roman@topologix.de> wrote:
>
> > >#!/usr/bin/perl -w
> > >use strict ;
> > >
> > >$_='foobar';
> > >$sub = '$2$1 ';
> > >s/(foo)(bar)/$sub/;
> > >print ;
> > >
> > >
> > ># output : barfoo barfoo $2$1
> >
> > On the other hand, if you use double quotes $sub won't be
> > initialised before the match occurs and you'll get a warning (if -w is
> > set).
>
> I can't confirm this. I cut-and-pasted Roman's code, and it produced no
> warnings.
That is, after I replaced '$2$1 ' with "$2$1 ".
> I didn't think it would, as $sub isn't actually evaluated
> before the s/// statement, so it doesn't matter whether or not it's
> initialized. I'm curious, what did you think it would warn about?
-mona
------------------------------
Date: Tue, 23 Jan 2001 10:13:53 +0000 (UTC)
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: s/// inconsistency
Message-Id: <slrn96qmb0.2q0.bernard.el-hagin@gdndev25.lido-tech>
On Tue, 23 Jan 2001 11:06:24 +0100, Mona Wuerz <wuerz@yahoo.com> wrote:
>In article <slrn96ql2o.2q0.bernard.el-hagin@gdndev25.lido-tech>,
>bernard.el-hagin@lido-tech.net wrote:
>
>> On Tue, 23 Jan 2001 09:30:19 GMT, Roman Moeller <roman@topologix.de> wrote:
>
>> >#!/usr/bin/perl -w
>> >use strict ;
>> >
>> >$_='foobar';
>> >$sub = '$2$1 ';
>> >s/(foo)(bar)/$sub/;
>> >print ;
>> >
>> >
>> ># output : barfoo barfoo $2$1
>>
>> On the other hand, if you use double quotes $sub won't be
>> initialised before the match occurs and you'll get a warning (if -w is
>> set).
>
>I can't confirm this. I cut-and-pasted Roman's code, and it produced no
>warnings. I didn't think it would, as $sub isn't actually evaluated
>before the s/// statement, so it doesn't matter whether or not it's
>initialized. I'm curious, what did you think it would warn about?
If you really cut-and-pasted the above code you'd get:
Global symbol "$sub" requires explicit package name at ./perl.pl line 6.
Global symbol "$sub" requires explicit package name at ./perl.pl line 7.
Execution of ./perl.pl aborted due to compilation errors.
If you fix that by adding 'my' before '$sub you'll get:
Use of uninitialized value in concatenation (.) at ./perl.pl line 6.
because $1 and $2 aren't set at this point in the program.
Cheers,
Bernard
--
#requires 5.6.0
perl -le'* = =[[`JAPH`]=>[q[Just another Perl hacker,]]];print @ { @ = [$ ?] }'
------------------------------
Date: Tue, 23 Jan 2001 23:39:25 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: s/// inconsistency
Message-Id: <slrn96qurt.n5q.mgjv@martien.heliotrope.home>
On Tue, 23 Jan 2001 10:58:37 +0100,
Mona Wuerz <wuerz@yahoo.com> wrote:
> In article <94jisk$qmm$1@crusher.de.colt.net>, <roman@topologix.de>
> wrote:
>
>> $_='foobar';
>
> # $sub = '$2$1 ';
> $sub = "$2$1 ";
>
>> s/(foo)(bar)/$sub/;
>> print ;
>>
>>
>> # output : barfoo barfoo $2$1
>
> # output : barfoo barfoo barfoo
>
> (as far as I understand it, you're preventing interpolation of $1 and
> $2 by using single quotes.)
If you now only run the third bit of code, on its own, without the two
preceding matches, you'll also notice that $2 and $1 are not set when
$sub gets declared. Using double quotes there will result in two
warnings about undefined variables.
in other words, the $2 and $1 you are interpolating in $bar = "$2$1 "
are the result of the _previous_ pattern match.
Also see my other post.
Martien
--
Martien Verbruggen |
Interactive Media Division | This matter is best disposed of from
Commercial Dynamics Pty. Ltd. | a great height, over water.
NSW, Australia |
------------------------------
Date: Tue, 23 Jan 2001 15:17:59 GMT
From: "Roman Moeller" <roman@topologix.de>
Subject: Re: s/// inconsistency
Message-Id: <94k78h$71d$1@crusher.de.colt.net>
On 23-Jan-2001,Bernard El-Hagin wrote:
> $sub is a single quoted string, thus it's treated literally. No
> interpolation.
.. at the point of assignment. Exactly what I wanted, since i wanted to
feed the substitution with backreferences.Scalars surely don't remember,
how they were constructed, whether using single or double quotes,
q/ operators or what else. So this cannot have any influence on the
substitution itself.
What I wanted to point out is :
if
s/pattern/substitution/
is equvalent to
$sub="substitution";
s/pattern/$sub/
and this is the almost always the case, why does this equivalence
doesn't hold if the string happens to contain backreferences ?
> Cheers,
> Bernard
Cheers also, and thanks for taking your time
Roman
------------------------------
Date: Tue, 23 Jan 2001 12:59:23 GMT
From: sgi_ripe@my-deja.com
Subject: Socket error
Message-Id: <94jv7a$m4p$1@nnrp1.deja.com>
Hi all.
Help me pls !!!
After I changed linux kernel from 2.2.12 to
2.2.14, I can't compile perl
correctly.
I've tried to do 'make test' and got following
error
Failed Test Status Wstat Total Fail Failed
List of failed
--------------------------------------------------
--------------------------
---
lib/io_multihom 0 11 8 8 100.00% 1-8
lib/io_sock.t 0 11 14 14 100.00% 1-14
lib/io_udp.t 0 11 7 7 100.00% 1-7
I ran debug and saw that process is interupted
due to Signal SEGV at
../lib/IO/Socket.pm line 42
( getprotobyname() system call ) ...
I've tried to compile different versions of the
perl (5.5.x - 5.6.0) also I
upgraded kernel to 2.2.18 but it doesn't work as
well....
What's wrong? Do u have any ideas?
P.S. I've installed precompiled perl version and
I don't have problem with
it, but I should compile my own distribution in
any case.....
Regards,
SGI
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Tue, 23 Jan 2001 23:16:42 +1000
From: "Jeffrey Grace" <gracenews@optusnet.com.au>
Subject: Re: spawning a process that is a perl program
Message-Id: <3a6d844e$0$16409$7f31c96c@news01.syd.optusnet.com.au>
<tuoihong@my-deja.com> wrote in message news:94iuvr$tog$1@nnrp1.deja.com...
[snip, child code just finished]
> print "Content-type: text/plain\n\n";
> print "Parent exiting ...\n";
>
>
> the problem i have is that it does execute the ftp.pl but after that it
> becomes a defunct process. How can i fix this?
you'll need to either ignore the CHLD signal, or use waitpid. Else the
child processes will remain zombies. If the parent code exits (which it
won't in the production as it runs "forever") the childs will become
orphaned, then adopted by init, which will catch SIGCHLD, and the processes
will end.
--
Jeffrey Grace
~~~~~~~~~~~~~~~~~~~~
Queensland, Australia
------------------------------
Date: Tue, 23 Jan 2001 12:54:46 GMT
From: "Koen Bossaert" <not@defined.com>
Subject: Re: stability of threads + interpreter performance
Message-Id: <qafb6.156$j4.16147@nreader2.kpnqwest.net>
"Dan Sugalski" <dan@tuatha.sidhe.org> wrote in message
news:_K4b6.151545$P82.18385537@news1.rdc1.ct.home.com...
> Koen Bossaert <not@defined.com> wrote:
> > Hi,
>
> > I read that threading is a lot more stable, but still experimental in
Perl
> > 5.6 than in 5.005, but that one has to pay a performance penalty if you
> > recompile the interpreter to support threading (ref:
> >
http://www-106.ibm.com/developerworks/library/l-perl5.html?dwzone=linux).
>
> Yup, it's better, but still has problems. It likely will never be truly
> fixed in any of the releases of perl 5.
>
> > Can anyone tell me if it is stable enough to use in business
applications?
> > How big is the performance penalty?
>
> If you avoid its traps, it's safe, though the performance penalty can be
> reasonably high. How high depends on your system, but you might see up to
> a 20% slowdown.
That's quite a lot.
> Dan
Thanks for the information Dan.
Koen
------------------------------
Date: 23 Jan 2001 10:06:14 GMT
From: vek@pharmnl.ohout.pharmapartners.nl (Villy Kruse)
Subject: Re: Still Can't Get MIME Lite To Send Attachment...
Message-Id: <slrn96qlsg.rpd.vek@pharmnl.ohout.pharmapartners.nl>
On Mon, 22 Jan 2001 22:05:08 GMT,
Rand Simberg <simberg.interglobal@trash.org> wrote:
>On Sun, 21 Jan 2001 15:06:54 GMT, in a place far, far away,
>simberg.interglobal@trash.org (Rand Simberg) made the phosphor on my
>monitor glow in such a way as to indicate that:
>>******************************************************************
>>
>>Content-Disposition: inline
>>Content-Length: 57
>>Content-Transfer-Encoding: binary
>>Content-Type: text/plain
>>
>>The attached file contains your requested archive backup.
>>*******************************************************************
>>
>>But still no attachment. AFAIK, the path is valid. Does anyone have
>>any idea what the problem might be?
>
>Found the problem. Apparently, if it's of type text, it is just
>embedded in the message body. In order to force it to an attached
>file, it has to be some other type.
>
>I set it to Type => 'application/octet-stream' and it worked just
>fine...
>
That also depends on what the receiving mail program defines as
an attachment. As far as MIME is concerned, there is no real difference
between the main text and the attachments, but the mail program may
choose to display plain text attachment on the terminal rather than
offer the possibility to save the attachment to disk.
Maybe the line: "Content-Disposition: inline" has something to do with
it as well.
The 'Content-Transfer-Encoding: binary' is a bit iffy. Should preferely
be Base64 for real binary data and 7bit or 8bit for plain text. Then
again, if Content-Type is plain/text, then the contents should realy be
plain text, that is, displayable and printable text, and then you also
need to specify the character set.
Now sounds like a mime question rather than a perl question, so
it is becoming off topic.
Villy
------------------------------
Date: Tue, 23 Jan 2001 13:30:54 +0100
From: "MaxyM" <marekpow@email.hinet.hr>
Subject: Why
Message-Id: <94jtjn$5lvq$1@as121.tel.hr>
Ok, I know when changing characters I should write:
$newch=~s/+/ /g;
And I'd like to change + with a space. But this line doesn't work, and I
still get + instead of something else..
Why?
------------------------------
Date: 23 Jan 2001 13:44:41 +0100
From: Christian Meisl <meisl@amvt.tu-graz.ac.at>
Subject: Re: Why
Message-Id: <m3zogi7806.fsf@famvtpc59.tu-graz.ac.at>
"MaxyM" <marekpow@email.hinet.hr> writes:
> $newch=~s/+/ /g;
>
> And I'd like to change + with a space. But this line doesn't work, and I
> still get + instead of something else..
> Why?
Hmm, usually + means 1 or more occurences of a certain token, so you
might have to quote the +:
$newch =~ s/\+/ /g;
Does that work?
Best regards,
Christian
--
Christian Meisl <meisl@amvt.tu-graz.ac.at> www.amft.tu-graz.ac.at
Inst. f. Apparatebau, Mech. Verfahrenstechnik und Feuerungstechnik
------- I think there's a world market for about five computers --------
PGP fingerprint: DF48 2503 0411 F0EF 149C 851B 1EF0 72B9 78B6 034A
------------------------------
Date: Tue, 23 Jan 2001 13:52:59 -0800
From: "GOGAR" <angenent@kabelfoon.nl>
Subject: Re: Why
Message-Id: <94junj$2am5$1@news.kabelfoon.nl>
try
$newch=~s/\+/ /g;
"MaxyM" <marekpow@email.hinet.hr> wrote in message
news:94jtjn$5lvq$1@as121.tel.hr...
> Ok, I know when changing characters I should write:
>
> $newch=~s/+/ /g;
>
> And I'd like to change + with a space. But this line doesn't work, and I
> still get + instead of something else..
> Why?
>
>
>
>
>
>
------------------------------
Date: Tue, 23 Jan 2001 12:56:02 +0000
From: James Taylor <james@NOSPAM.demon.co.uk>
Subject: Re: Why
Message-Id: <ant23120272bfNdQ@oakseed.demon.co.uk>
In article <94jtjn$5lvq$1@as121.tel.hr>, MaxyM
<URL:mailto:marekpow@email.hinet.hr> wrote:
>
> Ok, I know when changing characters I should write:
>
> $newch=~s/+/ /g;
>
> And I'd like to change + with a space. But this line doesn't work,
Looks fine to me, although I'd have written it with spaces around
the =~ operator. I think you need to show us more of the surrounding
code, for us to see why it appears not to work.
> and I still get + instead of something else..
What something else? A space character, surely?
PS. You need to improve your choice of subject line as most people here
will ignore the simple "Why". Something like "Problem with s/+/ /g"
would at least given some context to your posting.
--
James Taylor <james (at) oakseed demon co uk>
PGP key available ID: 3FBE1BF9
Fingerprint: F19D803624ED6FE8 370045159F66FD02
------------------------------
Date: Tue, 23 Jan 2001 13:16:25 +0000
From: James Taylor <james@NOSPAM.demon.co.uk>
Subject: Re: Why
Message-Id: <ant231325e61fNdQ@oakseed.demon.co.uk>
In article <ant23120272bfNdQ@oakseed.demon.co.uk>, James Taylor
<URL:mailto:james@NOSPAM.demon.co.uk> wrote:
>
> In article <94jtjn$5lvq$1@as121.tel.hr>, MaxyM
> <URL:mailto:marekpow@email.hinet.hr> wrote:
> >
> > $newch=~s/+/ /g;
>
> Looks fine to me,
Where's my head today!
Yes, backslash escape the + as others have suggested.
--
James Taylor <james (at) oakseed demon co uk>
PGP key available ID: 3FBE1BF9
Fingerprint: F19D803624ED6FE8 370045159F66FD02
------------------------------
Date: Tue, 23 Jan 2001 14:56:22 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Why
Message-Id: <slrn96qtd9.22c.tadmc@tadmc26.august.net>
MaxyM <marekpow@email.hinet.hr> wrote:
>Subject: Why
Subject: substituting characters
Please put the subject of your post in the Subject of your post.
This helps members of this community find articles about subjects
that interest them. Folks wanting to substitute characters aren't
likely to look in a thread will such a silly Subject as this one.
[ and on top of that, some people score down (or kill) based
on the contents of the Subject header. Your article hit one
of my score rules. I don't usually have time to read articles
that have negative scores, I'm on vacation this week though :-)
]
>Ok, I know when changing characters I should write:
>
>$newch=~s/+/ /g;
No, s///g is for changing _strings_ or _patterns_.
tr/// is for changing _characters_, it is many times faster.
You should write
$newch =~ s/+/ /g;
Space characters are not a limited resource. Feel free to use as
many of them as you like to make your code easier to read.
>And I'd like to change + with a space. But this line doesn't work,
That line doesn't even compile. I guess that would qualify as
"doesn't work".
>and I
>still get
You (or I anyway) don't "get" anything but a syntax error message.
Why are you not asking about the syntax error message?
You did not include the message text, or even mention that you
got a message.
>+ instead of something else..
So I don't know what you are talking about here.
>Why?
Because your program never executed!
$newch =~ tr/+/ /;
I sure do hope this isn't part of URL decoding. That wheel has
already been invented, there are modules that do URL decoding
for you.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 23 Jan 2001 15:53:42 +0100
From: "Ellegiers, J. M. (Jens)" <jellegie@ford.com>
Subject: Re: Why
Message-Id: <3A6D9AF6.9D122E7E@ford.com>
James Taylor wrote:
>
> In article <94jtjn$5lvq$1@as121.tel.hr>, MaxyM
> <URL:mailto:marekpow@email.hinet.hr> wrote:
> >
> > Ok, I know when changing characters I should write:
> >
> > $newch=~s/+/ /g;
> >
> > And I'd like to change + with a space. But this line doesn't work,
>
Well, the + sign means: match 1 or more times the character before. So,
if you want to replace the + sign itself, you've got to escape it like
this:
$newch =~ s/\+/ /g;
Look it up with perldoc perlre !
> Looks fine to me, although I'd have written it with spaces around
> the =~ operator. I think you need to show us more of the surrounding
> code, for us to see why it appears not to work.
>
> > and I still get + instead of something else..
>
> What something else? A space character, surely?
>
> PS. You need to improve your choice of subject line as most people here
> will ignore the simple "Why". Something like "Problem with s/+/ /g"
> would at least given some context to your posting.
>
> --
> James Taylor <james (at) oakseed demon co uk>
> PGP key available ID: 3FBE1BF9
> Fingerprint: F19D803624ED6FE8 370045159F66FD02
--
Viele Gruesse, regards, saludos
Jens Ellegiers
---------------------------------------------------------------
FORD-Werke AG, Spessartstrasse, 50725 Koeln
Jens Ellegiers Email: jellegie@ford.com /"\
Engineer (I-Engine CAE) Phone: +49-221-90-31467 \ /
Mail Sym: D-ME/PN-S Fax : +49-221-90-33025 X
ASCII Ribbon campaign against HTML E-mail & Usenet News >------> / \
------------------------------
Date: Tue, 23 Jan 2001 09:16:25 GMT
From: Ian Boreham <iboreham@my-deja.com>
Subject: Re: Words - Pulling Hair
Message-Id: <94ji55$cru$1@nnrp1.deja.com>
In article <3A694785.7825E0F7@omeninc.com>,
Sterling <smullett@omeninc.com> wrote:
> H-
>
> I'm attempting to use the 'words' feature for perl.
I wasn't aware there was one. Can't find it in perlfunc.
> The documentation says do this.
> words [-w word-file] [-m min-length] <letters>
What documentation? This looks like the command-line syntax of a
program, not a perl function's syntax. You seem to have ignored the -w
and -m switches entirely. They should be a dead giveaway.
> Here's the problem. It errors.
> $symbol = "RXSN"; # I've changed this to match the error presented
> below.
> $stuff = words $symbol;
> print "SYMBOL: $symbol - $stuff \n";
> Here's the strange part. It's trying to determine an object from the
> $symbol variable.
Perl's best attempt at resolving the non-perl you have given it is to
interpret "words" as a method being called (with non-OO syntax) on a
package specified: the contents of $symbol.
> Can't locate object method "words" via package "RXSN" at
./perl_code.pl
> line 18.
> SYMBOL: RXSN -
> When I do this
> print words $symbol;
> It returns nothing.
-w would warn you; This is the syntax for printing to a filehandle (in
this case called 'words'). The filehandle has never been opened, so the
output is swallowed. With -w, you would get a warning message. Always
use -w.
> Perhaps someone could enlighten me on what this words is suppose to
do?
Whatever its manpage or instructions say. You could call it from perl
using `` or system, if you really wanted.
Regards,
Ian
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
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 126
**************************************