[25630] in Perl-Users-Digest
Perl-Users Digest, Issue: 7872 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Mar 9 18:15:56 2005
Date: Wed, 9 Mar 2005 15:15:47 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Wed, 9 Mar 2005 Volume: 10 Number: 7872
Today's topics:
Re: Praesideo: Latin for 'to watch over' <invinity@nvinity.net>
Re: Praesideo: Latin for 'to watch over' <invinity@nvinity.net>
string substitution help (search and replace) <izombe@yahoo.com>
Re: string substitution help (search and replace) sfgroups@gmail.com
Re: string substitution help (search and replace) <izombe@yahoo.com>
Re: string substitution help (search and replace) <tadmc@augustmail.com>
Re: string substitution help (search and replace) <izombe@yahoo.com>
Re: Struggling to install HTML::Mason (mod_perl would b <tadmc@augustmail.com>
Re: Struggling to install HTML::Mason (mod_perl would b <glex_nospam@qwest.invalid>
Re: Struggling to install HTML::Mason (mod_perl would b john_ramsden@sagitta-ps.com
Re: Struggling to install HTML::Mason (mod_perl would b <tadmc@augustmail.com>
Re: Struggling to install HTML::Mason (mod_perl would b <glex_nospam@qwest.invalid>
Using dot commands in a script danfperl@yahoo.com
Re: Using dot commands in a script <news@chaos-net.de>
Re: Using dot commands in a script <danfperl@yahoo.com>
Re: Using dot commands in a script <news@chaos-net.de>
Re: Using dot commands in a script <tony_curtis32@yahoo.com>
Re: Win32::TieRegistry Logon User Name <jairagoo@gmail.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 9 Mar 2005 06:47:47 -0800
From: "invinity" <invinity@nvinity.net>
Subject: Re: Praesideo: Latin for 'to watch over'
Message-Id: <1110379667.146205.275540@f14g2000cwb.googlegroups.com>
invinity wrote:
> Hey all,
>
> I am currently writing a module that is designed to automate the
> startup and management of Apache processes. In addition, the module
is
> designed to provide a VirtualHost-like environment, but with a
> dedicated Apache process for each host, all on a single IP address. I
> am hoping to get lots of input about the practicality of this program
> and my current namespace, which is "Praesideo". Actually, I am still
in
> the process of converting the modules over to the "Praesideo"
> namespace. My old namespace is "Server::ApacheIVHost."
I forgot to mention that Praesideo also uses Net::DNS to
add/update/delete DNS entries for hosts, which further automates the
host creation process.
------------------------------
Date: 9 Mar 2005 06:51:41 -0800
From: "invinity" <invinity@nvinity.net>
Subject: Re: Praesideo: Latin for 'to watch over'
Message-Id: <1110379901.851255.89610@o13g2000cwo.googlegroups.com>
invinity wrote:
> Hey all,
>
> I am currently writing a module that is designed to automate the
> startup and management of Apache processes. In addition, the module
is
> designed to provide a VirtualHost-like environment, but with a
> dedicated Apache process for each host, all on a single IP address. I
> am hoping to get lots of input about the practicality of this program
> and my current namespace, which is "Praesideo". Actually, I am still
in
> the process of converting the modules over to the "Praesideo"
> namespace. My old namespace is "Server::ApacheIVHost."
I forgot to mention that Praesideo also uses Net::DNS to
add/update/delete DNS entries for hosts, which further automates the
host creation process.
------------------------------
Date: 9 Mar 2005 12:39:41 -0800
From: "Ray Muforosky" <izombe@yahoo.com>
Subject: string substitution help (search and replace)
Message-Id: <1110400781.618244.230340@f14g2000cwb.googlegroups.com>
Hello everyone I need help.
I need to do string substitution on over 350 files on the following
string. Is there a tricky command in vi or command line that can do
this.
FILE CONTENT:
.....
....
kasj tgn=0507, thr=12, options=sched,
safa tgn=0504, thr=22, options=sched,
asda tgn=0513, thr=122, options=sched,
asca tgn=055, thr=562, options=sched,
asca tgn=0514, thr=42, options=sched,
where there is "thr=###" I need make it "thr=##" deleting the first
digit.
So line 3 and 4 will be changed and the file content will be:
kasj tgn=0507, thr=12, options=sched,
safa tgn=0504, thr=22, options=sched,
asda tgn=0513, thr=22, options=sched,
asca tgn=055, thr=62, options=sched,
asca tgn=0514, thr=42, options=sched,
I know less 15 lines of perl script will do it, but I'm wondering if
there is another way.
Any Help will br appreciated.
Ray
------------------------------
Date: 9 Mar 2005 12:54:24 -0800
From: sfgroups@gmail.com
Subject: Re: string substitution help (search and replace)
Message-Id: <1110401664.031486.239140@o13g2000cwo.googlegroups.com>
I think this one-line will help you.
cat a.txt | perl -npe 's/^(.*thr=)\d*(\d\d,.*)$/\1\2/ '
kasj tgn=0507, thr=12, options=sched,
safa tgn=0504, thr=22, options=sched,
asda tgn=0513, thr=22, options=sched,
asca tgn=055, thr=62, options=sched,
asca tgn=0514, thr=42, options=sched,
or
cat a.txt | perl -npe 's/^(.*thr=)\d*(\d\d,.*)$/\1\2/ if 3..4 ; '
kasj tgn=0507, thr=12, options=sched,
safa tgn=0504, thr=22, options=sched,
asda tgn=0513, thr=22, options=sched,
asca tgn=055, thr=62, options=sched,
asca tgn=0514, thr=42, options=sched,
Here you can get some more perl one-liner example.
http://sfg.homeunix.com/support/viewtopic.php?t=47
-SR
------------------------------
Date: 9 Mar 2005 13:22:31 -0800
From: "Ray Muforosky" <izombe@yahoo.com>
Subject: Re: string substitution help (search and replace)
Message-Id: <1110403351.606231.146620@l41g2000cwc.googlegroups.com>
Thanks for the help.Is there anyway I can execute the command without
dumping the content of the file. Can do in file editing?
------------------------------
Date: Wed, 9 Mar 2005 15:33:52 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: string substitution help (search and replace)
Message-Id: <slrnd2uqu0.d1h.tadmc@magna.augustmail.com>
Ray Muforosky <izombe@yahoo.com> wrote:
> I need to do string substitution
> asda tgn=0513, thr=122, options=sched,
> asca tgn=055, thr=562, options=sched,
> where there is "thr=###" I need make it "thr=##" deleting the first
> digit.
> asda tgn=0513, thr=22, options=sched,
> asca tgn=055, thr=62, options=sched,
> I know less 15 lines of perl script will do it, but I'm wondering if
> there is another way.
perl -pe 's/thr=\d(\d\d)/thr=$1/' filename
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 9 Mar 2005 13:36:32 -0800
From: "Ray Muforosky" <izombe@yahoo.com>
Subject: Re: string substitution help (search and replace)
Message-Id: <1110404192.511106.239200@z14g2000cwz.googlegroups.com>
Thanks for the help.Is there anyway I can execute the command without
dumping the content of the file. Can do in file editing?
------------------------------
Date: Wed, 9 Mar 2005 09:00:20 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Struggling to install HTML::Mason (mod_perl would be a good start!)
Message-Id: <slrnd2u3s4.bag.tadmc@magna.augustmail.com>
john_ramsden@sagitta-ps.com <john_ramsden@sagitta-ps.com> wrote:
> Does
> anyone know where to access the predefined @INC path list
perl -le 'print for @INC'
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 09 Mar 2005 10:30:55 -0600
From: "J. Gleixner" <glex_nospam@qwest.invalid>
Subject: Re: Struggling to install HTML::Mason (mod_perl would be a good start!)
Message-Id: <3xFXd.10$i37.169@news.uswest.net>
john_ramsden@sagitta-ps.com wrote:
> I am trying to install HTML::Mason, for use with Apache 2.0.48
> mod_perl v2. on Windows (using ActiveState perl v5.8.4) and wondered if
> anyone had encountered the same problems with a similar combination.
> However, I can't for the life of me find this blasted
> Apache::Constants.pm module, not via ppm or even a Google
> search.
Really?? Using Google and looking for Apache::Constants.pm shows many
links. (hint modperl....)
> Any ideas?
Give the HTTP::Mason site a try:
http://masonhq.com/
specifically
http://masonhq.com/?ApacheModPerl2
------------------------------
Date: 9 Mar 2005 09:16:05 -0800
From: john_ramsden@sagitta-ps.com
Subject: Re: Struggling to install HTML::Mason (mod_perl would be a good start!)
Message-Id: <1110388565.194959.233600@l41g2000cwc.googlegroups.com>
Tad McClellan wrote:
>
> john_ramsden@sagitta-ps.com <john_ramsden@sagitta-ps.com> wrote:
>
> > Does anyone know where to access the predefined @INC path list
>
> perl -le 'print for @INC'
Thanks for your prompt reply Tad. What I meant though was
are these paths listed in a config file somewhere I can go
and change the Windows file names containing spaces to
DOS-style 8.3 names listed with the DOS command "dir /x",
e.g.:
C:\Program Files\ActiveState Perl Dev Kit 6.0\lib\
C:/Perl/lib
C:/Perl/site/lib
to:
C:\Progra~1\Active~1.0\lib\
:::
------------------------------
Date: Wed, 9 Mar 2005 13:09:28 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Struggling to install HTML::Mason (mod_perl would be a good start!)
Message-Id: <slrnd2uif8.cms.tadmc@magna.augustmail.com>
john_ramsden@sagitta-ps.com <john_ramsden@sagitta-ps.com> wrote:
> Tad McClellan wrote:
>> john_ramsden@sagitta-ps.com <john_ramsden@sagitta-ps.com> wrote:
>>
>> > Does anyone know where to access the predefined @INC path list
>>
>> perl -le 'print for @INC'
>
> Thanks for your prompt reply Tad.
That isn't likely to happen often (re: numbnuts), I went slumming
into the negative-scored articles. :-(
> What I meant though was
> are these paths listed in a config file somewhere I can go
> and change
They are compiled into the perl binary.
perldoc -q library
How do I keep my own module/library directory?
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 09 Mar 2005 13:54:49 -0600
From: "J. Gleixner" <glex_nospam@qwest.invalid>
Subject: Re: Struggling to install HTML::Mason (mod_perl would be a good start!)
Message-Id: <ewIXd.20$R24.1725@news.uswest.net>
J. Gleixner wrote:
> Give the HTTP::Mason site a try:
correction..
s/HTTP/HTML/;
------------------------------
Date: 9 Mar 2005 12:10:55 -0800
From: danfperl@yahoo.com
Subject: Using dot commands in a script
Message-Id: <1110399055.402663.101230@l41g2000cwc.googlegroups.com>
I'm trying to load an environment file in a script and I think it may
be easiest to show it before explaining it. I've got 2 files,
/tmp/test.pl and /tmp/test.env. Here are the contents.
test.env:
#!/usr/bin/ksh
export BLAH=TEST
test.pl:
#!/usr/local/bin/perl
system('. /tmp/test.env');
print "\$BLAH is ${BLAH}" ;
When I run it I get:
sh: BLAH=TEST: is not an identifier
$BLAH is
How can I get Perl to load the file properly? It does so from the
command line but throws the error when I run the script. For reasons I
can't get into I can't change the env file - the perl script needs to
be modified. Any help is greatly appreciated!!
Dan
------------------------------
Date: Wed, 9 Mar 2005 21:39:39 +0100
From: Martin Kissner <news@chaos-net.de>
Subject: Re: Using dot commands in a script
Message-Id: <slrnd2unob.8cv.news@maki.homeunix.net>
danfperl@yahoo.com wrote :
> I'm trying to load an environment file in a script and I think it may
> be easiest to show it before explaining it. I've got 2 files,
> /tmp/test.pl and /tmp/test.env. Here are the contents.
>
> test.env:
> #!/usr/bin/ksh
> export BLAH=TEST
>
> test.pl:
> #!/usr/local/bin/perl
use strict;
use warnings
> system('. /tmp/test.env');
Why not simply say:
$ENV{BLAH}="TEST";
to set the environmet variable
or even
$BLAH="TEST";
to use a perl variable?
> print "\$BLAH is ${BLAH}" ;
Here you probably want:
print "Shell-\$BLAH is $ENV{BLAH}\n";
if you really want the exported shell variable.
${BLAH} is the same as $BLAH, which has not been assigned yet in your
script.
>
> When I run it I get:
> sh: BLAH=TEST: is not an identifier
This comes from the shell; I have not worked with the ksh, but it looks
like a syntax error in the variable assignment.
> $BLAH is
This is, because $BLAH is empty.
If you had used strict and warnings, perl had told you.
HTH
Best regards
Martin
--
perl -e '$|=1;&p(7.74.117.115.116.32);&s();&p(97.110.111);&p(116.104.101
.114);&s;&p(32.112.101.114.108);&s();&p(32.104.97.99.107.101.114.10);sub
s{sleep 1};sub p(){print "@_"}'
------------------------------
Date: 9 Mar 2005 13:04:00 -0800
From: "Dan" <danfperl@yahoo.com>
Subject: Re: Using dot commands in a script
Message-Id: <1110402240.221662.181440@l41g2000cwc.googlegroups.com>
Thanks for the quick reply Martin.
> Why not simply say...to set the environmet variable or even...to use
a perl variable?
It's not just one variable - that was an example. The actual
environment file I'm working with has dozens of lines. We have lots of
scripts running here and decided to have a single file with all
settings that anyone could reference. The more we set environment
variables outside it the tougher it is to manage, so there's basically
a hard line on that one: Source from the environment file or not at
all.
I know the error is shell related and I know why it's throwing it. For
some reason the dot command in the script defaults to sh instead of ksh
or bash and the environment file was designed for ksh/bash. When it
runs via sh it throws the error. (It uses "export BLAH=TEST" syntax
which isn't supported in sh.)
Dan
------------------------------
Date: Wed, 9 Mar 2005 23:03:24 +0100
From: Martin Kissner <news@chaos-net.de>
Subject: Re: Using dot commands in a script
Message-Id: <slrnd2uslc.8cv.news@maki.homeunix.net>
danfperl@yahoo.com wrote :
> I'm trying to load an environment file in a script and I think it may
> be easiest to show it before explaining it. I've got 2 files,
> /tmp/test.pl and /tmp/test.env. Here are the contents.
>
> test.env:
> #!/usr/bin/ksh
> export BLAH=TEST
>
> test.pl:
> #!/usr/local/bin/perl
> system('. /tmp/test.env');
> print "\$BLAH is ${BLAH}" ;
>
> When I run it I get:
> sh: BLAH=TEST: is not an identifier
> $BLAH is
>
> How can I get Perl to load the file properly? It does so from the
> command line but throws the error when I run the script. For reasons I
> can't get into I can't change the env file - the perl script needs to
> be modified. Any help is greatly appreciated!!
Well, in that case I would try
system('/usr/bin/ksh /tmp/test.env')
I suppose even
system('/tmp/test.env')
would work if /tmp/test.env is executable, since it has a proper shebang
line.
But I guess I'd prefere a file wich is formatet like this
----- variables.txt ----
name1:value1
name2:value2
name3:value3
----
and then use a hash like this in the scripts
--- snip ----
my %hash;
open FH,"<","variables" or die "error\n";
while (<FH>) {
/(.*?):(.*)/;
$hash{$1}=$2;
}
print $hash{'name1'},"\n";
--- snap ---
The last line prints "value1".
I do not really see a need to use the 'system' function and shell
variables here.
HTH
Martin
--
perl -e '$|=1;&p(7.74.117.115.116.32);&s();&p(97.110.111);&p(116.104.101
.114);&s;&p(32.112.101.114.108);&s();&p(32.104.97.99.107.101.114.10);sub
s{sleep 1};sub p(){print "@_"}'
------------------------------
Date: Wed, 09 Mar 2005 16:10:17 -0600
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: Using dot commands in a script
Message-Id: <87ekeompx2.fsf@limey.hpcc.uh.edu>
>> On 9 Mar 2005 12:10:55 -0800,
>> danfperl@yahoo.com said:
> I'm trying to load an environment file in a script and I
> think it may be easiest to show it before explaining it.
> I've got 2 files, /tmp/test.pl and /tmp/test.env. Here are
> the contents.
> test.env:
> #!/usr/bin/ksh
> export BLAH=TEST
> test.pl:
> #!/usr/local/bin/perl
warnings & strict?
> system('. /tmp/test.env');
system() doesn't use ksh (hence the error message), and those
settings will only exist within that transient child process.
> print "\$BLAH is ${BLAH}" ;
Now back to the parent, child's environment is gone! Also the
child process would not have been able to set a variable
inside the perl program.
> When I run it I get: sh: BLAH=TEST: is not an identifier
> $BLAH is
You could write some perl to parse the export settings in the
ksh script, and then set $ENV{} within the perl.
Or wrap the perl up inside a script that does the source
first.
Is this a FAQ? I couldn't find anything obvious with -q.
hth
t
------------------------------
Date: 9 Mar 2005 10:30:42 -0800
From: "darth" <jairagoo@gmail.com>
Subject: Re: Win32::TieRegistry Logon User Name
Message-Id: <1110393042.207668.190840@z14g2000cwz.googlegroups.com>
thank you very much for enlightening me!
------------------------------
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 7872
***************************************