[29413] in Perl-Users-Digest
Perl-Users Digest, Issue: 657 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jul 17 16:10:09 2007
Date: Tue, 17 Jul 2007 13:09:11 -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 Tue, 17 Jul 2007 Volume: 11 Number: 657
Today's topics:
Apache Configuration using PERL nicklas.bornstein@gmail.com
Re: Apache Configuration using PERL <glex_no-spam@qwest-spam-no.invalid>
connect a database in remote server (can connect to the zhangxiaoyu912@gmail.com
Re: connect a database in remote server (can connect to (Jens Thoms Toerring)
Re: how do i print/report my class hierarchy <mark.clementsREMOVETHIS@wanadoo.fr>
How do you retrieve a char from a string? <lamthierry@gmail.com>
Re: How do you retrieve a char from a string? <spamtrap@dot-app.org>
how to put "if" within a loop <jiehuang001@gmail.com>
how to put "if" within a loop <jiehuang001@gmail.com>
Re: how to put "if" within a loop <wahab@chemie.uni-halle.de>
Re: Trying to make sense of perl for web development. (Jamie)
Re: Using the split function <jgibson@mail.arc.nasa.gov>
Re: Using the split function <dummy@example.com>
Re: Using the split function <bik.mido@tiscalinet.it>
XML-RPC on Windows gcgaim@gmail.com
Re: XML-RPC on Windows <sisyphus1@nomail.afraid.org>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 17 Jul 2007 08:27:12 -0700
From: nicklas.bornstein@gmail.com
Subject: Apache Configuration using PERL
Message-Id: <1184686032.915829.182220@g12g2000prg.googlegroups.com>
Hi,
Im trying to use PERL, generating some of the Apache Configuration.
I have loaded the module mod_perl, and then do something like;
<Perl>
print 'ErrorDocument 404 http://www.google.dk';
</Perl>
in my httpd.conf - but the Apache Configuration don't evaluate on the
print, it just print out the line in the comand promt.
I have seach Google and found some example using somthing like;
use Apache::PerlSections();
but I can't figure it out. If I use the PerlSections(), I get the
error;
"Can't locate Apache/PerlSections.pm in @INC ...".
How do I simply write some configuration line in my httpd.conf, using
Perl? Thanks!
------------------------------
Date: Tue, 17 Jul 2007 11:31:54 -0500
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: Apache Configuration using PERL
Message-Id: <469ceefa$0$490$815e3792@news.qwest.net>
nicklas.bornstein@gmail.com wrote:
> Hi,
>
> Im trying to use PERL, generating some of the Apache Configuration.
> I have loaded the module mod_perl, and then do something like;
>
> <Perl>
> print 'ErrorDocument 404 http://www.google.dk';
> </Perl>
>
> in my httpd.conf - but the Apache Configuration don't evaluate on the
> print, it just print out the line in the comand promt.
What do you expect it to do? Seems like it's working just fine.
> How do I simply write some configuration line in my httpd.conf, using
> Perl? Thanks!
http://perl.apache.org/docs/1.0/guide/config.html#Apache_Configuration_in_Perl
------------------------------
Date: Tue, 17 Jul 2007 16:35:31 -0000
From: zhangxiaoyu912@gmail.com
Subject: connect a database in remote server (can connect to the server via SSH)
Message-Id: <1184690131.216457.327220@m37g2000prh.googlegroups.com>
Hi, All:
My perl code need to connect to a database (MySQL) in remote server,
and I can login that server via SSH. I am a new to perl, can anyone
give me a hint how can I do that. Many thanks.
Xiaoyu
------------------------------
Date: 17 Jul 2007 17:48:55 GMT
From: jt@toerring.de (Jens Thoms Toerring)
Subject: Re: connect a database in remote server (can connect to the server via SSH)
Message-Id: <5g4do7F3ed92iU1@mid.uni-berlin.de>
zhangxiaoyu912@gmail.com wrote:
> My perl code need to connect to a database (MySQL) in remote server,
> and I can login that server via SSH.
You don't need to have ssh access to the remote database server
in order to be able to connect to the database (at least if the
database server is configured to wait for remote connections).
> I am a new to perl, can anyone give me a hint how can I do that.
There's huge amount of packages for accessing databases in Perl,
mostly via the DBI module. For introductory articles see e.g.
http://www.perl.com/pub/a/2003/10/23/databases.html
or
http://dc.pm.org/talks/perl_db.html
(a Google search for "database perl" will give you a lot more
resources). The homepage for DBI is
http://dbi.perl.org/
Beside a download of the package (and lots of further modules
based on DBI) you will find there a number of articles and
tutorials. If you're into OO programing (and want to avoid
writing SQL;-) have a look at the DBIx::Class package
http://search.cpan.org/~mstrout/DBIx-Class-0.08003/lib/DBIx/Class.pm
Regards, Jens
--
\ Jens Thoms Toerring ___ jt@toerring.de
\__________________________ http://toerring.de
------------------------------
Date: Tue, 17 Jul 2007 21:49:02 +0200
From: Mark Clements <mark.clementsREMOVETHIS@wanadoo.fr>
Subject: Re: how do i print/report my class hierarchy
Message-Id: <469d1d1e$0$27398$ba4acef3@news.orange.fr>
anon24u@gmail.com wrote:
> Hi,
>
> I would like to generate a report of the class hierarchy of my
> application. What is the easiest way? Are there any utilities for
> this in CPAN? I don't need anything fancy.
>
> Since I am using the Class::Std infrastructure, I have thought of
> leveraging the CUMULATIVE functionality somehow. But ideally, I could
> just tell a utility to slurp up my code and report the hierarchy for
> me.
>
> A simple, text/tabular format suffices, but graphical is good too!
Autodia (this is graphical).
Mark
------------------------------
Date: Tue, 17 Jul 2007 12:50:37 -0700
From: Thierry <lamthierry@gmail.com>
Subject: How do you retrieve a char from a string?
Message-Id: <1184701837.540723.160770@i13g2000prf.googlegroups.com>
I have the following string:
my $greet = "hello";
print $greet[0]."\n";
The above clearly doesn't work since $greet is not an array. Is there
an easy way to access characters at specific index in a string without
losing $greet as a String?
Thierry
------------------------------
Date: Tue, 17 Jul 2007 16:00:07 -0400
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: How do you retrieve a char from a string?
Message-Id: <m2sl7mhkc8.fsf@dot-app.org>
Thierry <lamthierry@gmail.com> writes:
> I have the following string:
>
> my $greet = "hello";
> print $greet[0]."\n";
>
> The above clearly doesn't work since $greet is not an array. Is there
> an easy way to access characters at specific index in a string without
> losing $greet as a String?
print substr($greet, 0);
See "perldoc -f substr" for details.
sherm--
--
Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net
------------------------------
Date: Tue, 17 Jul 2007 19:01:19 -0000
From: Jie <jiehuang001@gmail.com>
Subject: how to put "if" within a loop
Message-Id: <1184698879.122390.97370@i38g2000prf.googlegroups.com>
as you see below, I am trying to compare if a list of files have
common elements. The following code works. The problem is that for the
last two lines I need to manually write each array element. when the
array is long, it is much awkward.
is there a way to put the "if" inside a loop?
thank you very much!
Jie
==========my code============
@lists = ("A", "B", "C");
foreach $list (@lists) {
%{$list} = ();
open IN, " < $list.txt";
while (<IN>) {
$_ =~ /(rs\d+)\t([^\t]+)/;
${$list}{$1} = $2;
}
close IN;
}
foreach $SNP (%{$lists[0]}) {
if ( exists ${$lists[1]}{$SNP} && exists ${$lists[2]}{$SNP}) {
print OUT "$SNP\t${$lists[0]}{$SNP}\t${$lists[1]}{$SNP}\t${$lists[2]}
{$SNP}\n";
}
}
------------------------------
Date: Tue, 17 Jul 2007 19:55:07 -0000
From: Jie <jiehuang001@gmail.com>
Subject: how to put "if" within a loop
Message-Id: <1184702107.454386.75880@e16g2000pri.googlegroups.com>
below I am trying to compare if a list of files have common elements
in certain columns. This code works fine. The problem is that the last
two line I manually writes the array element. Is there a way to put
the "if" into a loop, so that I can just use "$lists[$i]" to loop the
whole thing??
thanks!
Jie
========my current code=========
@lists = ("A", "B", "C");
foreach $list (@lists) {
%{$list} = (); ## create an empty hash of each element
open IN, " < pValue_DATA/$list.txt";
while (<IN>) {
chomp;
$_ =~ /(rs\d+)\t([^\t]+)/;
${$list}{$1} = $2;
}
close IN;
}
foreach $SNP (%{$lists[0]}) {
if ( exists ${$lists[1]}{$SNP} && exists ${$lists[2]}{$SNP}) {
print OUT "$SNP\t$WGAS_HASH{$SNP}\t${$lists[0]}{$SNP}\t${$lists[1]}
{$SNP}\t${$lists[2]}{$SNP}\n";
}
}
------------------------------
Date: Tue, 17 Jul 2007 21:29:28 +0200
From: Mirco Wahab <wahab@chemie.uni-halle.de>
Subject: Re: how to put "if" within a loop
Message-Id: <f7j5an$13kl$1@nserver.hrz.tu-freiberg.de>
Jie wrote:
> is there a way to put the "if" inside a loop?
> ==========my code============
> @lists = ("A", "B", "C");
> foreach $list (@lists) {
> %{$list} = ();
> open IN, " < $list.txt";
> while (<IN>) {
> $_ =~ /(rs\d+)\t([^\t]+)/;
> ${$list}{$1} = $2;
> }
> close IN;
> }
>
> foreach $SNP (%{$lists[0]}) {
> if ( exists ${$lists[1]}{$SNP} && exists ${$lists[2]}{$SNP}) {
> print OUT "$SNP\t${$lists[0]}{$SNP}\t${$lists[1]}{$SNP}\t${$lists[2]}
> {$SNP}\n";
> }
> }
Try (untested):
...
foreach my $SNP (%{$lists[0]}) {
print
$SNP,
join "\t",
map ${$lists[$_]}{$SNP},
grep exists ${$lists[$_]}{$SNP},
0 .. $#lists;
print "\n"
}
...
BTW: you should drop this code completely
and rewrite a small idiomatic solution
(only a few lines).
The symbolic refs render this code unmaintainable
and dangerous.
Regards
M.
------------------------------
Date: Tue, 17 Jul 2007 18:59:28 GMT
From: nospam@geniegate.com (Jamie)
Subject: Re: Trying to make sense of perl for web development.
Message-Id: <Lc1184696942263900x8cf1bd4@pong.podro.com>
In <1182430464.041485.285330@a26g2000pre.googlegroups.com>,
cendrizzi <cendrizzi@gmail.com> mentions:
>Wow, thanks guys!
>
>I will do this for sure. For someone newer to perl it is somewhat
>bewildering (and exciting) how many modules exist. Just looking for
>postgres drivers made me feel overwhelmed.
That is (IMO) one of the advantages over PHP, while PHP sort of thrusts
all these functions into the program, Perl uses modules and name spaces
so that you don't have collisions.
>BTW, is mod_perl the best way to go? It seems from most things I've
>read to have some nice advantages.
mod_perl is excellent if you need low level access to the web server. I use
it sometimes.
I'm not terribly crazy about it for most things as it can really ruin your day,
it sits in your web server whether you're using the application or not. (this
can be a significant issue if you have several applications, some of them being
run once or twice a day or even once a month)
FastCGI is really nice, it's also a fair bit easier to design a FastCGI
application to be compatible with regular CGI. This way, you can start
out with CGI and if the application is hit a lot, move over to FastCGI
for only those things that need it.
I find regular old CGI to be pretty darn good on modern computers, (you may
wish to have a perl binary running some place, perhaps just sitting there
doing nothing) most UNIX's can take advantage of an existing perl binary
in memory and it seems to run pretty quick. (shared forking I'd imagine)
I wouldn't use CGI for programs that are requested 100 times a second though...
Perl's AUTOLOAD can be turned into an excellent tool for optimizing vanilla
CGI. Loading only subs that are needed for any particular request. (though, this
can come back to make a mess for you if you switch to FastCGI/mod_perl) PHP
has an AUTOLOAD, but, the way PHP does it is via the CLASS name, perl can do
it as granular as a SUB name.
One thing you'll discover when using mod_perl (or FastCGI) is that it is
possible to hang on to complex data structures for multiple requests. This is
excellent for parsing configuration files, as it only needs to be done ONCE
during the entire duration of the program. (so each page load doesn't need to
"reload" configuration) Downside, of course, is that all this memory will be
used up, not so good for once in awhile scripts and can be a serious problem if
it contains information you DON'T want shared between page requests so you
have to be extra careful about that.
With PHP, this memory sharing wasn't usually an option.
Hmm.. didn't mean to write a speech. Sorry!
Jamie
--
http://www.geniegate.com Custom web programming
Perl * Java * UNIX User Management Solutions
------------------------------
Date: Tue, 17 Jul 2007 09:50:29 -0700
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: Using the split function
Message-Id: <170720070950297652%jgibson@mail.arc.nasa.gov>
In article <Ih1ni.8443$4A1.1652@news-server.bigpond.net.au>, Simon
<shmh@bigpond.net.au> wrote:
> ================================================================= go.pl
>
> sub RunRegQuery {
> open (REGQUERY, "reg query \"\\\\$System\\HKLM\\Software\\test\" /v
> BuildVersion|");
> while (<REGQUERY>) {
> @lines = <REGQUERY>;
> foreach $line (@lines) {
> chomp $line;
> print "$line\n";
> }
> }
> }
You are reading the first line, testing if it is true, and discarding
it. You then read the remaining lines into the @list array and print
them. You then attempt to read another line, which returns undef,
causing the while loop to exit. Is that what you mean to do?
> #================================================= Read a Computer List.
> open (Store, "< systems.txt") or die "can't open systems.txt: $!";
> foreach $line (<Store>) {
Here you read all of the lines from systems.txt into an anonymous
array, and then iterate over the elements of that array. If you only
need one line at a time, it is better to use a while loop:
while( my $line = <Store> ) {
...
}
--
Jim Gibson
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
------------------------------
Date: Tue, 17 Jul 2007 18:23:27 GMT
From: "John W. Krahn" <dummy@example.com>
Subject: Re: Using the split function
Message-Id: <zO7ni.45648$tB5.39706@edtnps90>
Jim Gibson wrote:
> In article <Ih1ni.8443$4A1.1652@news-server.bigpond.net.au>, Simon
> <shmh@bigpond.net.au> wrote:
>>
>> #================================================= Read a Computer List.
>> open (Store, "< systems.txt") or die "can't open systems.txt: $!";
>> foreach $line (<Store>) {
>
> Here you read all of the lines from systems.txt into an anonymous
> array, and then iterate over the elements of that array.
s/(?s:anonymous.)?array/list/g
John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order. -- Larry Wall
------------------------------
Date: Tue, 17 Jul 2007 21:07:49 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Using the split function
Message-Id: <tq4q93hrm6asl2a0uie8npsq4dlm9mpsnf@4ax.com>
On Tue, 17 Jul 2007 09:50:29 -0700, Jim Gibson
<jgibson@mail.arc.nasa.gov> wrote:
>> open (Store, "< systems.txt") or die "can't open systems.txt: $!";
>> foreach $line (<Store>) {
>
>Here you read all of the lines from systems.txt into an anonymous
^^^^^^^^^
>array, and then iterate over the elements of that array. If you only
^^^^^
Well, not really...
>need one line at a time, it is better to use a while loop:
>
> while( my $line = <Store> ) {
> ...
> }
Always true!
Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
.'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
------------------------------
Date: Tue, 17 Jul 2007 15:24:17 -0000
From: gcgaim@gmail.com
Subject: XML-RPC on Windows
Message-Id: <1184685857.901255.149360@m37g2000prh.googlegroups.com>
Hi,
I'm looking for advice on the best XML-RPC package (for a server) to
run on Windows using ActivePerl. Thanks for any help!
------------------------------
Date: Wed, 18 Jul 2007 01:49:27 +1000
From: "Sisyphus" <sisyphus1@nomail.afraid.org>
Subject: Re: XML-RPC on Windows
Message-Id: <469ce509$0$26579$afc38c87@news.optusnet.com.au>
<gcgaim@gmail.com> wrote in message
news:1184685857.901255.149360@m37g2000prh.googlegroups.com...
> Hi,
> I'm looking for advice on the best XML-RPC package (for a server) to
> run on Windows using ActivePerl. Thanks for any help!
>
I don't know the answer to your question, but (if it helps) RPC-Simple and
RPC-XML are available via ppm from http://theoryx5.uwinnipeg.ca/ppms/ and
http://trouchelle.com/ppm/ . Also, at http://trouchelle.com/ppm/ you can get
ppm's of RPC-JSON, RPC-Lite, RPC-Object and XML-RPC.
Cheers,
Rob
------------------------------
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 V11 Issue 657
**************************************