[22235] in Perl-Users-Digest
Perl-Users Digest, Issue: 4456 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jan 23 14:11:27 2003
Date: Thu, 23 Jan 2003 11:10:11 -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 Thu, 23 Jan 2003 Volume: 10 Number: 4456
Today's topics:
parse scalar into array <fm_duendeBASURA@yahoo.com>
Re: parse scalar into array <nobull@mail.com>
Re: parse scalar into array <shondell@cis.ohio-state.edu>
Re: parse scalar into array <tassilo.parseval@post.rwth-aachen.de>
Re: Perl on IIS (run in ASP pages?) <will@com.yahoo>
Re: Perl on IIS (run in ASP pages?) <nobull@mail.com>
Re: Perl package giving errors <usenet@dwall.fastmail.fm>
Re: Perl package giving errors (Tad McClellan)
Perl Thread Tk Web Server problem (Michael)
Re: Please Help Me <nobull@mail.com>
Re: Regex: optional word boundary (Tad McClellan)
Re: To extract a specific portion of a text file (Tad McClellan)
Re: unlink() (Tad McClellan)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 23 Jan 2003 18:20:02 GMT
From: monkeys paw <fm_duendeBASURA@yahoo.com>
Subject: parse scalar into array
Message-Id: <mnWX9.10715$rM2.9761@rwcrnsc53>
How can i take a string and put each char into an
array. For instance, i have $i = 134675. I simply
need to add each digit together like so:
1 + 3 + 4 + 6 + 7 + 5 = 26
I could do this with a series of modulus 10
but there must be an easy way to do:
@each_digit = parsing_func($i);
where @each_digit would result in:
qw(1 3 4 6 7 5)
------------------------------
Date: 23 Jan 2003 18:38:42 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: parse scalar into array
Message-Id: <u9fzrj3e4t.fsf@wcl-l.bham.ac.uk>
monkeys paw <fm_duendeBASURA@yahoo.com> writes:
> How can i take a string and put each char into an
> array. For instance, i have $i = 134675. I simply
> need to add each digit together like so:
>
> 1 + 3 + 4 + 6 + 7 + 5 = 26
>
> I could do this with a series of modulus 10
> but there must be an easy way to do:
>
> @each_digit = parsing_func($i);
>
> where @each_digit would result in:
>
> qw(1 3 4 6 7 5)
I could have sworn I'd seen this in the FAQ but I can't see it now.
Can anyone else find it in the FAQ?
Anyhow, no matter, I know it's also in
perldoc -f split
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: 23 Jan 2003 13:49:47 -0500
From: Ryan Shondell <shondell@cis.ohio-state.edu>
Subject: Re: parse scalar into array
Message-Id: <xcw65sfwvjo.fsf@psi.cis.ohio-state.edu>
monkeys paw <fm_duendeBASURA@yahoo.com> writes:
> How can i take a string and put each char into an
> array. For instance, i have $i = 134675. I simply
> need to add each digit together like so:
>
> 1 + 3 + 4 + 6 + 7 + 5 = 26
>
> I could do this with a series of modulus 10
> but there must be an easy way to do:
>
> @each_digit = parsing_func($i);
>
> where @each_digit would result in:
>
> qw(1 3 4 6 7 5)
Perhaps something like...
my $i = 134675;
my $value;
$value += $_ foreach (split //, $i);
print $value;
This will print out 26.
--
Ryan Shondell <shondell@cis.ohio-state.edu>
------------------------------
Date: 23 Jan 2003 19:03:07 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@post.rwth-aachen.de>
Subject: Re: parse scalar into array
Message-Id: <b0pe9b$j1b$1@nets3.rz.RWTH-Aachen.DE>
Also sprach monkeys paw:
> How can i take a string and put each char into an
> array. For instance, i have $i = 134675. I simply
> need to add each digit together like so:
>
> 1 + 3 + 4 + 6 + 7 + 5 = 26
>
> I could do this with a series of modulus 10
> but there must be an easy way to do:
>
> @each_digit = parsing_func($i);
This parsing_func() is an alias for split().
> where @each_digit would result in:
>
> qw(1 3 4 6 7 5)
Split on an empty pattern:
my @digits = split //, 134675;
Tassilo
--
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval
------------------------------
Date: Thu, 23 Jan 2003 16:15:39 GMT
From: w i l l <will@com.yahoo>
Subject: Re: Perl on IIS (run in ASP pages?)
Message-Id: <g8503vsvh6kb13ftuei8qafe4s5kq3ch9p@4ax.com>
you can use perl script on the client side, or perl in the form of CGI
on the server side. If you have active state look at the docs, it
explains all this.
w i l l
On Wed, 22 Jan 2003 23:13:52 GMT, "MG" <me@home.com> wrote:
>I know ActiveState perl installs PERLIS.DLL into the components portion of
>IIS, I also know that with ASP pages you can specify a language at the
>beginning such as <%@ Language="JScript" %>. Is there a perl equivilant so
>that I can script perl inside of my web pages? This sounds like a good idea
>since I never did like having to code HTML from inside a perl program (I
>still use templates whenever I can). Thanks.
>
>- Joe
>
------------------------------
Date: 23 Jan 2003 18:16:58 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: Perl on IIS (run in ASP pages?)
Message-Id: <u9u1fz3f51.fsf@wcl-l.bham.ac.uk>
w i l l <will@com.yahoo> top-posts (usually a good sign of someone who
isn't paying attension):
> On Wed, 22 Jan 2003 23:13:52 GMT, "MG" <me@home.com> wrote:
>
> >I know ActiveState perl installs PERLIS.DLL into the components portion of
> >IIS, I also know that with ASP pages you can specify a language at the
> >beginning such as <%@ Language="JScript" %>. Is there a perl equivilant so
> >that I can script perl inside of my web pages? This sounds like a good idea
> >since I never did like having to code HTML from inside a perl program (I
> >still use templates whenever I can). Thanks.
> you can use perl script on the client side, or perl in the form of CGI
> on the server side. If you have active state look at the docs, it
> explains all this.
It also, I'm fairly sure, explains how to use Perl ASP like the OP
asked. This is something about which I know little because I don't
use ASP.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Thu, 23 Jan 2003 17:48:38 -0000
From: "David K. Wall" <usenet@dwall.fastmail.fm>
Subject: Re: Perl package giving errors
Message-Id: <Xns930C8250789C8dkwwashere@216.168.3.30>
Bernard El-Hagin <bernard.el-hagin@DODGE_THISlido-tech.net> wrote on 23 Jan
2003:
> On Thu, 23 Jan 2003 08:10:59 -0500, Ryan <ryan@rhis.net> wrote:
>
> [...]
>
>
>>I think that did the trick. I guess from the error msg I could have
>>concluded that but I must need more coffee or something.... Thank you much.
>
> Tad, can we add "drink coffee before posting" to the "Must" section of
> the Posting Guidelines?
>
> ;-)
That doesn't necessarily work. A few days ago I asked a question whose
answer I had somehow managed to miss in the docs that I had open *right in
front of me*, and I was full of coffee. :-)
--
David K. Wall - usenet@dwall.fastmail.fm
"Oook."
------------------------------
Date: Thu, 23 Jan 2003 12:50:03 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Perl package giving errors
Message-Id: <slrnb30ear.b52.tadmc@magna.augustmail.com>
David K. Wall <usenet@dwall.fastmail.fm> wrote:
> Bernard El-Hagin <bernard.el-hagin@DODGE_THISlido-tech.net> wrote on 23 Jan
> 2003:
>
>> On Thu, 23 Jan 2003 08:10:59 -0500, Ryan <ryan@rhis.net> wrote:
>>
>> [...]
>>
>>
>>>I think that did the trick. I guess from the error msg I could have
>>>concluded that but I must need more coffee or something.... Thank you much.
>>
>> Tad, can we add "drink coffee before posting" to the "Must" section of
>> the Posting Guidelines?
>>
>> ;-)
>
> That doesn't necessarily work. A few days ago I asked a question whose
> answer I had somehow managed to miss in the docs that I had open *right in
> front of me*, and I was full of coffee. :-)
Maybe you had something else on your mind.
Maybe we should add:
drink coffee and take a tinkle before posting
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 23 Jan 2003 09:04:15 -0800
From: magic@tublet.freeserve.co.uk (Michael)
Subject: Perl Thread Tk Web Server problem
Message-Id: <e4f7604c.0301230904.63efb6fd@posting.google.com>
I'm trying to write a very simple Peer-to-Peer application using Perl
Tk and Threads. I'm using ActiveState Perl v5.8 on Windows XP Home,
and using the Threads and Threads:shared modules.
My application should have both a server and client part, for
receiving and sending information. The information being sent is just
database results, so nothing difficult or complex.
I create a GUI using Tk with start and stop buttons, and when I start
the server part I spawn a new thread so the GUI remains active while
the server sits and listens. The server and client parts I have up and
running so no problems there. It's killing the thread on exit of the
Perl program that's the issue.
As I have found out, the easiest and most recommended way to end a
thread is to complete/end the function you spawned the thread as.
Simple enough and I've done this as a simple exercise. However, the
accept() function in Perl sits and listens (as it's supposed to)
waiting for connections. Therefore the function never exits.
I don't want to detach the thread because I want to communicate
between the main thread and the server thread and I also want to be
able to control the server at certain points.
My only way so far of returing from the server thread has been to use
the client part of my application to communicate with the server
thread by calling localhost and forcing the server to end. Utter
madness!! Apart from being messy, security goes out the window.
What I want is a nuke_thread() function where I just call the id of
the thread and destroy it. Is there any way to do this ??
I toyed with the idea of creating a process, which in turn spawned a
thread. This way I could destroy the process, but I'm slightly wary of
what might happen to the thread. I have tried using the %SIG()
variable but this only works on processes and again, I'm not sure what
would happen to the thread if I killed it's parent process.
Any ideas ??
Thanks
Michael
------------------------------
Date: 23 Jan 2003 18:35:15 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: Please Help Me
Message-Id: <u9k7gv3eak.fsf@wcl-l.bham.ac.uk>
"Khanh Tran" <kttran@nortelnetworks.com> writes TOFU:
> Thank you very much for your quick response.
Please do not thank me then spit TOFU[1] in my face. I feel insulted
by it. Most of the people who answer questions here would feel
insulted by it.
Insult us often and you will find that we will ignore you.
I *strongly* advise that you read the posting guidelines *before* you post
again.
[1] new Text Over, Full qoute Under.
------------------------------
Date: Thu, 23 Jan 2003 11:33:10 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Regex: optional word boundary
Message-Id: <slrnb309qm.aqs.tadmc@magna.augustmail.com>
Sara <genericax@hotmail.com> wrote:
> tadmc@augustmail.com (Tad McClellan) wrote in message news:<slrnb2u59r.8ha.tadmc@magna.augustmail.com>...
>> /\bfan(mail | base)?/x
>>
>> can indeed be prettied up with spaces. :-)
>
> Actually I retract my previous response, Tad. I can't get this
> solution to work.
--------------------
#!/usr/bin/perl
use strict;
use warnings;
$_ = 'foo fanbase bar';
print "matched\n" if /\bfan(mail | base)?/x;
--------------------
Works (matches) for me.
Note the option on the end there...
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 23 Jan 2003 11:37:58 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: To extract a specific portion of a text file
Message-Id: <slrnb30a3m.aqs.tadmc@magna.augustmail.com>
John Smith <clearguy02@yahoo.com> wrote:
> Thanks Tad!
>
> I tried your solution, but it was not exactly giving me the results I
> wanted.
TRY MY OTHER SOLUTION!!!
> Do you know how I can just get the first "Test Key" field and only its
> values?
Yes, and I've told you about it 3 times already.
It worked with the first typo-strewn data. It worked with data
you emailed me. It worked with the corrected data you posted.
It works with this 4th set of your ever-morphing data.
I asked if it worked or not (it works when I try it), you never
answered.
Take this code. Use it. It works with every data set that you've
shown us/me. This thread was finished several generations ago.
Let it die.
------------------------------
my $indent;
while ( <DATA> ) {
$indent = length($1), last if /^(\s*Test Key :\s*)/;
}
print;
while ( <DATA> ) {
last unless /^\s{$indent}\S/;
print;
}
------------------------------
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 23 Jan 2003 11:53:35 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: unlink()
Message-Id: <slrnb30b0v.aqs.tadmc@magna.augustmail.com>
codeWarrior <GPatnude@adelphia.net> wrote:
> "Joel Konkle-Parker" <joeljkp@tabdemo.larc.nasa.gov> wrote in message
> news:3E2FFC7E.1060906@tabdemo.larc.nasa.gov...
>> unlink ("./temp_trail.txt") || die $!;
>> But when my script ends each time, the files are still there. The 'die'
>> doesn't produce any output. This is Perl 5.004. What's wrong here?
> Personally: I think it may be the single dot-slash.... current directory is
> simply: "temp_trail.txt" --
You are incorrect.
"./temp_trail.txt" and "temp_trail.txt" are equivalent, they
refer to the same file.
> On Unix systems -- Peril's unlink will NOT remove files if there is a
> symbolic link to it...
You are incorrect again.
unlink() most certainly will remove files that are targets of
symlinks (thereby "breaking" the symlink).
> Are you positive that the file handles are closed at this point in your
> scripts ? (Perl normally closes any open file handles when the script
> terminates or exits normally...)
Filehandles have nothing to do with it either.
> I also suggest that you check the return value of "unlink".... like this....
>
> $STATUS = unlink ('./temp_trail.txt', 'prt0001__out.log.1') || die $!;
> print "RESULT: $STATUS\n\n
^^^
^^^ syntax error
Why check it like that? What advantage over the OP's way of
checking the return value does it offer?
If the die triggers, the print() will never execute anyway.
ie. You will only see the value of $STATUS when the unlink _succeeds_.
> FWIW...
Not much.
No followup would have been worth more that one the strews
red herrings all about.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
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.
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 4456
***************************************