[18493] in Perl-Users-Digest
Perl-Users Digest, Issue: 661 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Apr 9 14:10:48 2001
Date: Mon, 9 Apr 2001 11:10:18 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <986839817-v10-i661@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Mon, 9 Apr 2001 Volume: 10 Number: 661
Today's topics:
To run perl in the backround <T_boss75@curanet.com>
Re: Unicode named property in regexes (\p & \P) (Mark Jason Dominus)
unicode, perl and webbrowsers <pilsl_@goldfisch.at>
using dup() <hannak@nospam.kodak.com>
Re: using dup() <info@fruiture.de>
Re: using dup() (Mark Jason Dominus)
Re: using dup() <tony_curtis32@yahoo.com>
Re: using dup() (Mark Jason Dominus)
Re: Want Lisp-like state machine impl. (Mark Jason Dominus)
what's wrong with the code? <slok00@yahoo.com>
Re: what's wrong with the code? <jeffp@crusoe.net>
Re: what's wrong with the code? <camerond@mail.uca.edu>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 9 Apr 2001 12:50:51 -0400
From: "T_Boss" <T_boss75@curanet.com>
Subject: To run perl in the backround
Message-Id: <VNlA6.138474$lj4.4243833@news6.giganews.com>
I have developed a perl program wich has to monitor some PsrtMasters.
to run it, I have to open the comment promt box. and run the program.
To keep it running I have to keep this box open.
Is there anyway to let perl run in the backround, so that i can close this
box??
I have Active perl 5.6 on Win NT 4.0 Sp 5.0
------------------------------
Date: Mon, 09 Apr 2001 17:36:09 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: Unicode named property in regexes (\p & \P)
Message-Id: <3ad1f308.216e$1ef@news.op.net>
In article <986697005.564941@elaine.furryape.com>,
Alan Barclay <gorilla@elaine.furryape.com> wrote:
>What I don't see is an entire list of all the valid properties. I'm
>sure there must be more than are listed.
There should be documentation at unicode.org. But since Unicode is
still evolving, so too will the list of properties.
However, I believe the file lib/unicode/PropList.txt in the Perl
source code distribution may be helpful. I also suggest a perusal of
lib/unicode/UCDFF301.html, which I believe comes straight from
unicode.org.
--
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print
------------------------------
Date: Mon, 9 Apr 2001 19:12:23 +0200
From: peter pilsl <pilsl_@goldfisch.at>
Subject: unicode, perl and webbrowsers
Message-Id: <MPG.153c0be3c688427f9897fb@news.inode.at>
I am not sure if I got it already into my head, so please read the
following and complain about wrong things...
My test-script (using the CGI-module) produces a form, saves the submitted
values to a postgreSQL-database and allows to view saved entries. Encoding
of the HTML-output is UTF-8 everywhere, cause I want to combine german,
english, russian and several baltic languages even in one sentence and
want this script being usable by people in russia and people in serbia and
germany and usa.
I did no more than writing UTF-8 in the html-header and it works perfect
with Internetexplorer 5.5 and less perfect with Netscape 4.x. Netscape
shows the entries saved with IE55 fine, but I cant enter any language with
different charsets (switching to russian keyboard in w2k just produces
ugly-signs).
Opera 5 doesnt view and doesnt allow to enter ...
Is this a problem of this browsers (netscape is listed as unicode-
compliant under www.unicode.org) or should I include some extra unicode-
steps in my scripts ?
I took a look at 'man perlunicode' and 'man utf8', but I think the first
is only some description of the internal techniques and the second is only
about the way perl handles the sourcecode.
Somehow I am really confused about all this stuff and dont figure out,
what part of the unicode-stuff belongs to the browser, to perl, to the
cgi-module, to my script, to my Operatingsystem ...
So please anyone give a short intruction or a good link.
www.unicode.org even confused me more. I would need some dummy-report
before going there again ..
thnx,
peter
--
pilsl@
goldfisch.at
------------------------------
Date: Mon, 09 Apr 2001 11:52:39 -0400
From: Victor Hannak <hannak@nospam.kodak.com>
Subject: using dup()
Message-Id: <3AD1DAC7.2965DB1B@nospam.kodak.com>
I have the following code:
open(LOG, ">>/tmp/logfile");
open(STDOUT, ">&LOG");
print "test";
close(LOG);
I was expecting the word test to go both to stdout and the logfile, but
it goes to neither. How can I get it to go to both at the same time?
Can I tie in STDIN and STDERR also, so that all program interactions are
recorded?
------------------------------
Date: Mon, 9 Apr 2001 18:03:43 +0200
From: "fruiture" <info@fruiture.de>
Subject: Re: using dup()
Message-Id: <9asmth$j78$1@Merlin.et.bocholt.fh-gelsenkirchen.de>
"Victor Hannak" <hannak@nospam.kodak.com> schrieb im Newsbeitrag
news:3AD1DAC7.2965DB1B@nospam.kodak.com...
> ....
> Can I tie in STDIN and STDERR also, so that all program interactions are
> recorded?
> .....
open STDERR,">error.log" or die $!;
warn "foo";
#this will print all STDERR to error.log
there are some interesting modules like IO::Scalar, that allows you to print
into a scalar
use IO::Scalar;
tie *STDERR,'IO::Scalar', \$err;
warn "critical error!;
print $err;
same with arrays (IO::ScalarArray)
but if and how you can print to the User and to a file at once..i don't
know. but you could create a subroutine like myprint ...
--
do something for your health
______fruiture.de___yeah!_
------------------------------
Date: Mon, 09 Apr 2001 17:52:47 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: using dup()
Message-Id: <3ad1f6f7.21d2$294@news.op.net>
In article <3AD1DAC7.2965DB1B@nospam.kodak.com>,
Victor Hannak <hannak@nospam.kodak.com> wrote:
>I have the following code:
>
> open(LOG, ">>/tmp/logfile");
> open(STDOUT, ">&LOG");
> print "test";
> close(LOG);
>
>I was expecting the word test to go both to stdout and the logfile,
You are confused about what 'STDOUT' means. STDOUT does not mean 'the
screen'. It means 'the place where the default output goes'.
Imagine your program is like a room with some holes in the wall. Each
hole has a sign over it. One hole has a sign that says STDOUT.
Another hole has a sign that says LOG. Each hole is attached to a
chute, and when you throw some data through the hole, it goes down the
chute to its destination.
What does open() do? It detaches the old chute and throws it away.
Then it attaches a new chute.
open(LOG, ">>/tmp/logfile")
this attaches the LOG hole to a chute that goes into /tmp/logfile.
open(STDOUT, ">&LOG");
Originally, the STDOUT hole was attached to a chute that went to the
screen of your computer. This open() call throws away that old chute
so that STDOUT is no longer attached to the screen. Instead, it makes
the STDOUT chute go to the same place the the LOG chute is going.
Before open(STDOUT, ">&LOG");
STDOUT ------------------------> screen
LOG ------------------------> /tmp/logfile
After open(STDOUT, ">&LOG");
STDOUT --------,
\
LOG ----------+-------------> /tmp/logfile
Now data printed to LOG will go into the file, and data printed to
STDOUT will *also* go into the file. The connection with the screen
has been thrown away, so data will not appear on the screen.
>it goes to neither.
OK, that is clearly not the case. I just ran your program, and
afterwards, /tmp/logfile contained "test".
> How can I get it to go to both at the same time?
Two strategies are possible:
1.
sub lprint {
print LOG @_;
print STDOUT @_;
}
lprint "test"; # prints "test" to log file and to STDOUT
2.
Get the IO::Tee module.
http://search.cpan.org/search?dist=IO-Tee
Obviously, solution #1 is much easier.
>Can I tie in STDIN and STDERR also, so that all program interactions are
>recorded?
Again you are confused. Input and output are not the same thing.
If what you want is to record all program interactions, I usggest
using a program that is designed for the purpose. On unix systems,
the 'enscript' program may be what you want.
Hope this helps.
--
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print
------------------------------
Date: 09 Apr 2001 12:56:41 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: using dup()
Message-Id: <87d7amrm7a.fsf@limey.hpcc.uh.edu>
>> On Mon, 09 Apr 2001 17:52:47 GMT,
>> mjd@plover.com (Mark Jason Dominus) said:
> If what you want is to record all program interactions,
> I usggest using a program that is designed for the
> purpose. On unix systems, the 'enscript' program may be
> what you want.
[minor correction to excellent article]
Mark means "script" here, not "enscript". Mind you, you
could use enscript to format the results of script nicely.
hth
t
--
Just reach into these holes. I use a carrot.
------------------------------
Date: Mon, 09 Apr 2001 17:59:29 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: using dup()
Message-Id: <3ad1f88a.21f4$bb@news.op.net>
In article <87d7amrm7a.fsf@limey.hpcc.uh.edu>,
Tony Curtis <tony_curtis32@yahoo.com> wrote:
>Mark means "script" here, not "enscript".
Indeed I do. Thanks for the correction.
--
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print
------------------------------
Date: Mon, 09 Apr 2001 17:32:48 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: Want Lisp-like state machine impl.
Message-Id: <3ad1f23f.2141$288@news.op.net>
Keywords: navel, practice, pulp, renaissance
In article <9armjh$ed4$1@charity.cs.utexas.edu>,
Logan Shaw <logan@cs.utexas.edu> wrote:
>I'd just like to point out that, while Lisp may be the lingua franca at
>MIT, it isn't in comp.lang.perl.misc.
Yes, I agree. Although it seemed to me that there might very well be
a solution to his problem, I wasn't familiar enough with the CL
feature that he described to know what the problem was.
David, perhaps a more degtailed functional description would be helpful here.
--
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print
------------------------------
Date: Tue, 10 Apr 2001 00:50:44 +0800
From: slok <slok00@yahoo.com>
Subject: what's wrong with the code?
Message-Id: <3AD1E864.80702@yahoo.com>
I invoke the following simple script from command line ...
eg. myscript.pl -5 relative-or-absolute-path
but it complains at 2 points (see inline comments for complains)
why is it so?
thanks
===
#!/usr/bin/perl -w
#
use strict;
my $path = "."; # default path
my $num = 10; # -n default number of users
my $gotn = 0;
my $gotp = 0;
foreach $a (@ARGV) {
if ( $a <> 0 ) { # COMPLAIN
if( $gotn ) {
print("error handling. More than one -n");
}
$num = - $a;
$gotn = 1;
} else { # COMPLAIN
if( $gotp <> 0 ) {
print("error handling.. more than one path");
}
$gotp = 1;
$path = $a;
}
}
------------------------------
Date: Mon, 9 Apr 2001 12:57:56 -0400
From: Jeff Pinyan <jeffp@crusoe.net>
Subject: Re: what's wrong with the code?
Message-Id: <Pine.GSO.4.21.0104091257070.4502-100000@crusoe.crusoe.net>
[posted & mailed]
On Apr 10, slok said:
>but it complains at 2 points (see inline comments for complains)
>why is it so?
>
> if ( $a <> 0 ) { # COMPLAIN
If you check the perlop documentation (perldoc perlop, or look at
http://www.perldoc.org/), you'll see that Perl uses != as its numerical
not-equal-to operator, not <>.
--
Jeff "japhy" Pinyan japhy@pobox.com http://www.pobox.com/~japhy/
Are you a Monk? http://www.perlmonks.com/ http://forums.perlguru.com/
Perl Programmer at RiskMetrics Group, Inc. http://www.riskmetrics.com/
Acacia Fraternity, Rensselaer Chapter. Brother #734
------------------------------
Date: Mon, 09 Apr 2001 12:05:13 -0500
From: Cameron Dorey <camerond@mail.uca.edu>
Subject: Re: what's wrong with the code?
Message-Id: <3AD1EBC9.1E7DB43C@mail.uca.edu>
slok wrote:
>
> I invoke the following simple script from command line ...
> eg. myscript.pl -5 relative-or-absolute-path
>
> but it complains at 2 points (see inline comments for complains)
> why is it so?
> if ( $a <> 0 ) { # COMPLAIN
> } else { # COMPLAIN
> if( $gotp <> 0 ) {
What's wrong, is that there ain't no "<>" operator for comparisons in
Perl (the <> - "diamond" - operator is for input functions). See perlop.
In the meantime, use the != (not equal to) operator here.
Cameron
--
Cameron Dorey
Associate Professor of Chemistry
University of Central Arkansas
Phone: 501-450-5938
camerond@mail.uca.edu
------------------------------
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 661
**************************************