[19635] in Perl-Users-Digest
Perl-Users Digest, Issue: 1830 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Sep 27 09:05:31 2001
Date: Thu, 27 Sep 2001 06:05:10 -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: <1001595910-v10-i1830@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Thu, 27 Sep 2001 Volume: 10 Number: 1830
Today's topics:
Re: carriage return <Graham.T.Wood@oracle.com>
Re: Combining Lines From Database <dtweed@acm.org>
Re: eval-statement fools garbage-collection ? <pilsl_@goldfisch.at>
Forcing reevaluation of code in mod_perl scripts? <nospaming@gmx.net>
Re: Forcing reevaluation of code in mod_perl scripts? (Damian James)
IO::Socket::INET <mr.thanquol@gmx.de>
Re: launching acrobat on Win32 <clarke__@__hyperformix.com>
Launching an external win32 app using a perl script... <guardian@chello.be>
Re: maths <Thomas@Baetzler.de>
Re: maths <na>
Re: maths <Thomas@Baetzler.de>
Re: maths <na@na>
Re: maths (Damian James)
Re: maths <Thomas@Baetzler.de>
Re: maths <na@na>
Re: maths (Martien Verbruggen)
Re: maths <na@na>
Re: maths <Thomas@Baetzler.de>
Re: maths (Damian James)
Re: maths <Thomas@Baetzler.de>
Re: no database driver specified and DBI_DSN env var no <Thomas@Baetzler.de>
Re: no database driver specified and DBI_DSN env var no <cpryce@pryce.nospam.net>
Re: oracle <ron@indra.com>
Re: Problem using Modules <Graham.T.Wood@oracle.com>
Push into an array <blnukem@hotmail.com>
Re: Push into an array <Thomas@Baetzler.de>
Search engine <dscarlett@REMOVETHIS.optushome.com.au>
Re: Security of letting user specify regex in CGI scrip <bart.lateur@skynet.be>
Re: Setting max. values (cpu/ram usage) for mod_perl sc <nospaming@gmx.net>
Re: Sourcing Things in Perl ? slightlysprintingdog@ntlworld.com
Re: Sourcing Things in Perl ? slightlysprintingdog@ntlworld.com
Re: Sourcing Things in Perl ? (Tim Hammerquist)
Re: Transforming HTML (Grod)
Re: Win32 Perl - Setting ENV Variables from Command-lin <removespamjeremyalansmith@netscapeonline.co.uk>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 27 Sep 2001 13:12:32 +0100
From: Graham Wood <Graham.T.Wood@oracle.com>
Subject: Re: carriage return
Message-Id: <3BB317B0.21D68E64@oracle.com>
This is a multi-part message in MIME format.
--------------1A9277835DAA405CE856C197
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Michael wrote:
> How do I replace carriage ruturn character with a space?
> s/\n/ /g or s/\r\n/ /g can't work.
>
> Michael
In what context are you trying to do this and why can't they work?
Graham Wood
--------------1A9277835DAA405CE856C197
Content-Type: text/x-vcard; charset=UTF-8;
name="Graham.T.Wood.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Graham Wood
Content-Disposition: attachment;
filename="Graham.T.Wood.vcf"
begin:vcard
n:;Graham
x-mozilla-html:FALSE
adr:;;;;;;
version:2.1
email;internet:Graham.T.Wood@oracle.com
fn:Graham Wood
end:vcard
--------------1A9277835DAA405CE856C197--
------------------------------
Date: Thu, 27 Sep 2001 11:59:10 GMT
From: Dave Tweed <dtweed@acm.org>
Subject: Re: Combining Lines From Database
Message-Id: <3BB31344.2595F1E1@acm.org>
Mark Schaver wrote:
> Can anyone show me the way to enlightenment?
Well, I'm going to have to make some assumptions:
1. Lines to be combined are identical in fields 1 through 3.
2. Field 4 indicates the sequence in which they should be combined.
3. Neither the input order nor the output order of the records
is particularly important.
4. The data fits in memory.
#!perl -w
use strict;
my @data = (
"Joe\tSmith\t1/1/1941\t0001\tabc",
"Joe\tSmith\t1/1/1941\t0002\tdef",
"Joe\tSmith\t1/1/1941\t0003\tghi",
"Jane\tDoe\t2/2/1952\t0001\tjkl",
"Jane\tDoe\t2/2/1952\t0002\tmno",
"Sam\tSpade\t3/3/1963\t0001\tpqr",
"Sam\tSpade\t3/3/1963\t0002\tstu",
);
my %db;
for (@data) {
# split the fields apart at the tabs
my ($k1, $k2, $k3, $i, $d) = split "\t";
# using the first three fields as a hash key, put the fifth
# field into an array in the position given by the fourth field
$db{$k1, $k2, $k3}[$i] = $d;
}
for (keys %db) {
# print the new combined record, skipping any undef values in
# each array
print join ("\t", split ($;),
join ('', grep (defined $_, @{$db{$_}}))
), "\n";
}
-- Dave Tweed
------------------------------
Date: Thu, 27 Sep 2001 13:38:27 +0200
From: peter pilsl <pilsl_@goldfisch.at>
Subject: Re: eval-statement fools garbage-collection ?
Message-Id: <3bb30fb5@e-post.inode.at>
peter pilsl wrote:
> nobull@mail.com wrote:
>
>
>>
>> I've looked on perlbug and I can't find this bug so, Peter, since you
>> discovered the bug you get the honour of submitting it.
>>
>
report sent
peter
--
peter pilsl
pilsl_@goldfisch.at
http://www.goldfisch.at
------------------------------
Date: Thu, 27 Sep 2001 13:19:26 +0200
From: EXP <nospaming@gmx.net>
Subject: Forcing reevaluation of code in mod_perl scripts?
Message-Id: <3BB30B3E.C9130C44@gmx.net>
Hiho
I want to execute an external perl file from a mod_perl script but I
don't want mod_perl to keep that external perl file in memory.
I can't simply run it with system(""); as I need to access some global
variables.
---
require ext.pl #works, but would cache it
---
eval {
require ext.pl #still caches it
}
---
system("ext.pl"); #doesn't cache but doesn't allow me to access
#the vars i need either
---
Any ideas?
Background: I have a perl forum which is huge and has many memory leaks.
It is simply impossible to execute it under mod_perl as this bloats
the apache processes to astronomical dimensions and starts crashing/
action wired. But I have to read the output into a mod_perl script in
order to integrate it into a table based webpage.
BYe!
EXP
------------------------------
Date: 27 Sep 2001 11:37:46 GMT
From: damian@qimr.edu.au (Damian James)
Subject: Re: Forcing reevaluation of code in mod_perl scripts?
Message-Id: <slrn9r63nj.6nm.damian@puma.qimr.edu.au>
On Thu, 27 Sep 2001 13:19:26 +0200, EXP said:
>I want to execute an external perl file from a mod_perl script but I
>don't want mod_perl to keep that external perl file in memory.
>I can't simply run it with system(""); as I need to access some global
>variables.
>...
>Any ideas?
>
A couple:
use system(), pass the data as arguments (optionally serialised
with Data::Dumper or Storable, etc), suitably escaped for your
shell.
system(), share the data via files or an DBMS or another external
mechanism (IPC shareable?).
HTH
Cheers,
Damian
--
@:=grep!(m!$/|#!..$|),split//,<DATA>;@;=0..$#:;while($:=@;){$;=rand
$:--,@;[$;,$:]=@;[$:,$;]while$:;push@|,shift@;if$;[0]==@|;select$,,
$,,$,,1/80;print qq x\bxx((@;+@|)*$|++),@:[@|,@;],!@;&&$/} __END__
Just another Perl Hacker,### http://home.pacific.net.au/~djames.hub
------------------------------
Date: Thu, 27 Sep 2001 14:06:07 +0200
From: "felix" <mr.thanquol@gmx.de>
Subject: IO::Socket::INET
Message-Id: <9ov4nf$1ln$1@crusher.de.colt.net>
hi,
I actually try to write a script to send some controll-sequences to a
java-webserver.
but first I want to figure out some basic stuff of how to communicate to a
webserver
via script. my first try was to post a simple "GET" request to a normal
webserver (apache)
but it's not doing it's job.....have a look
#!/usr/local/bin/perl -w
# $Id$
use IO::Socket;
my $request = IO::Socket::INET->new(PeerAddr => 'server-name',
PeerPort
=> '80',
Proto
=> 'tcp',
Type
=> SOCK_STREAM);
print $request "GET /index.html HTTP/1.0\n"; # request a site
print $request, "\n"; # have
a look at the request
print "Server said:\n\n";
while
request>){
print $_ ; # print content of requestet site
}
print "end of request.\n";
#############################################################
if I launch the script a request is posted to the server (as I can see in the access-log)
but the script is just waiting ... and waiting... then it stops and only the output
"
Server said:
end of request.
"
of the request is shown.. (maybe because the server timed out)
does somebody know whats going up here??
thx
fe
------------------------------
Date: Thu, 27 Sep 2001 07:54:01 -0500
From: "Allan" <clarke__@__hyperformix.com>
Subject: Re: launching acrobat on Win32
Message-Id: <IjFs7.194$x12.40658@news.uswest.net>
Hehe. I wish I could affort for my program to terminate. Its a Perl/Tk GUI
app and I'm just trying to bring up help (which is in acrobat). Think my
users will mind if the app terminates when help comes up? ;-)
Here is where I am now:
my $command = "cmd.exe /c start $helpFilename";
my $result = system ($command);
This works provided $helpFilename does not contain spaces. Anyone
know how to escape/quote stuff so system and cmd are happy?
Allan
"Wyzelli" <wyzelli@yahoo.com> wrote in message
news:KUus7.37$ou4.456@wa.nnrp.telstra.net...
> "Allan" <clarke__@__hyperformix.com> wrote in message
> news:sHrs7.944$bL5.423399@news.uswest.net...
> > I have been trying to find a way to launch the Acrobat reader to view
> > a PDF file. If I use
> >
> > system ("test.pdf")
>
> look into exec which runs the external command and never returns (ie your
> program ends at that point) rather than system which waits for the
external
> process to finish.
>
> Wyzelli
> --
> push@x,$_ for(a..z);push@x,' ';
> @z='092018192600131419070417261504171126070002100417'=~/(..)/g;
> foreach $y(@z){$_.=$x[$y]}y/jp/JP/;print;
>
>
------------------------------
Date: Thu, 27 Sep 2001 12:03:11 GMT
From: "GuaRDiaN" <guardian@chello.be>
Subject: Launching an external win32 app using a perl script...
Message-Id: <3AEs7.1325$Ds3.7330@news.chello.be>
Does anybody knows how I could start an external win32 application using a
perl script?
I'm usign Active State Perl under Win2k Advanced Server ...
Thx in advance.
------------------------------
Date: Thu, 27 Sep 2001 12:27:10 +0200
From: =?ISO-8859-1?Q?Thomas_B=E4tzler?= <Thomas@Baetzler.de>
Subject: Re: maths
Message-Id: <2hv5rtg459gnuno2f0rvboiiffo9ad309r@4ax.com>
On Thu, 27 Sep 2001 10:39:39 +0100, "NEWS" <na> wrote:
>the scalar value im left is correct to aprrox 18 decimal places, how do i
>correct this to just two decimal places ?
"perldoc -q round", "perldoc -f sprintf"
Please check the included documentation before you ask.
HTH,
--
use strict;my($i,$t,@r)=(0,'5 -.@BHJPT4acd6e2hk2lmn2o4r2s3tuz',map{ord}
split//,unpack('u*','L#`T&)QD5#0`#!!`#%1D)#08`#P05!!(3``$$"``#"0L&``('.
'"`P<!`````0$`'));$t=~s/(\d)(.)/$2x$1/eg;map{$t.=substr$t,$i,1,''while
$_--;$i++}@r;print"$t\n";# Thomas@Baetzler.de - http://baetzler.de/perl
------------------------------
Date: Thu, 27 Sep 2001 11:49:00 +0100
From: "NEWS" <na>
Subject: Re: maths
Message-Id: <3bb30423$0$230$ed9e5944@reading.news.pipex.net>
thnaks for your help, your really are a nice man.
that was sarcasm.
------------------------------
Date: Thu, 27 Sep 2001 12:57:18 +0200
From: =?ISO-8859-1?Q?Thomas_B=E4tzler?= <Thomas@Baetzler.de>
Subject: Re: maths
Message-Id: <jb16rtcme1neo99mfo1kh5e1900m0b2138@4ax.com>
On Thu, 27 Sep 2001 11:49:00 +0100, "NEWS" <na> wrote:
>thnaks for your help, your really are a nice man.
>
>that was sarcasm.
Who would've guessed. But then I didn't really expect anything else
from a !clue anon poster.
tsk,
--
use strict;my($i,$t,@r)=(0,'5 -.@BHJPT4acd6e2hk2lmn2o4r2s3tuz',map{ord}
split//,unpack('u*','L#`T&)QD5#0`#!!`#%1D)#08`#P05!!(3``$$"``#"0L&``('.
'"`P<!`````0$`'));$t=~s/(\d)(.)/$2x$1/eg;map{$t.=substr$t,$i,1,''while
$_--;$i++}@r;print"$t\n";# Thomas@Baetzler.de - http://baetzler.de/perl
------------------------------
Date: Thu, 27 Sep 2001 12:12:34 +0100
From: "Chris" <na@na>
Subject: Re: maths
Message-Id: <3bb309a8$0$237$ed9e5944@reading.news.pipex.net>
stop talking nonsense and just tell me how to tell a scalar value to correct
itself to two decimal places.
are these forums for people to help one another.
------------------------------
Date: 27 Sep 2001 11:27:28 GMT
From: damian@qimr.edu.au (Damian James)
Subject: Re: maths
Message-Id: <slrn9r6348.6nm.damian@puma.qimr.edu.au>
On Thu, 27 Sep 2001 12:12:34 +0100, Chris said:
>stop talking nonsense and just tell me how to tell a scalar value to correct
>itself to two decimal places.
Am I missing something? What nonsense?
$value =~ s/^(\d+\.\d\d)\d*$/$1/;
will work if you can guarantee there will be at least one digit
followed by a period followed by at least two digits. For a better
solution, there's no substitute for the documentation:
perldoc -q round
perldoc -f sprintf
If you're not familiar with it, this is the online documentation that
is included with every (working) installation of perl. The idea is
that you type either of the above incatations on the command line.
>are these forums for people to help one another.
Indeed, but there are a few conventions that aid in making sure this
does in fact happen. One is that you don't try to take cuts in line,
by which I mean you are expected to check the documentation before
posting a question here. It's unlikely to help you if you are rude
to the regulars, either ;-).
HTH
Cheers,
Damian
--
@:=grep!(m!$/|#!..$|),split//,<DATA>;@;=0..$#:;while($:=@;){$;=rand
$:--,@;[$;,$:]=@;[$:,$;]while$:;push@|,shift@;if$;[0]==@|;select$,,
$,,$,,1/80;print qq x\bxx((@;+@|)*$|++),@:[@|,@;],!@;&&$/} __END__
Just another Perl Hacker,### http://home.pacific.net.au/~djames.hub
------------------------------
Date: Thu, 27 Sep 2001 13:30:39 +0200
From: =?ISO-8859-1?Q?Thomas_B=E4tzler?= <Thomas@Baetzler.de>
Subject: Re: maths
Message-Id: <1p26rt4i0mjnhi5e1hgj66s6e4gpfo6er0@4ax.com>
On Thu, 27 Sep 2001 12:12:34 +0100, "Chris" <na@na> wrote:
>stop talking nonsense and just tell me how to tell a scalar value to correct
>itself to two decimal places.
You can read, can you?
Open a DOS box, type in "perldoc -q round", hit return. Read.
Understand. Repeat steps 2 and 3 as often as necessary. Do the same
with "perldoc -f sprintf".
So newsgroups are a place where people should help each other out?
Indeed they are. But if you think that newsgroups are just there to
spoon-feed you on demand, you're mistaken. I guess pretty much
everybody's willing to spend their time helping others, provided these
people show at least a minimum of courtesy. Courtesy in c.l.p.m
includes that you check your documentation before you ask. General
Usenet courtesy also includes checking the relevant FAQ documents
before posting to a group. You have obviously done neither - so who's
been a rude jerk, eh?
HTH,
--
use strict;my($i,$t,@r)=(0,'5 -.@BHJPT4acd6e2hk2lmn2o4r2s3tuz',map{ord}
split//,unpack('u*','L#`T&)QD5#0`#!!`#%1D)#08`#P05!!(3``$$"``#"0L&``('.
'"`P<!`````0$`'));$t=~s/(\d)(.)/$2x$1/eg;map{$t.=substr$t,$i,1,''while
$_--;$i++}@r;print"$t\n";# Thomas@Baetzler.de - http://baetzler.de/perl
------------------------------
Date: Thu, 27 Sep 2001 12:49:47 +0100
From: "Chris" <na@na>
Subject: Re: maths
Message-Id: <3bb31261$0$234$ed9e5944@reading.news.pipex.net>
you ?
------------------------------
Date: Thu, 27 Sep 2001 21:49:58 +1000
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: maths
Message-Id: <slrn9r64j6.t75.mgjv@martien.heliotrope.home>
On Thu, 27 Sep 2001 12:12:34 +0100,
Chris <na@na> wrote:
> stop talking nonsense and just tell me how to tell a scalar value to correct
> itself to two decimal places.
The answer was given upthread. You look in the perl FAQ. The perldoc
command can be used to find answers in the FAQ.
And again:
perldoc -q round
perldoc -f sprintf
> are these forums for people to help one another.
No, they are not. These newsgroups exist so people can discuss Perl.
They are not help desks. If you want a help desk, hire someone. if you
want to learn about Perl, and you want to participate in this group,
then you better learn how to read and use the documentation.
And read these:
http://mail.augustmail.com/~tadmc/clpmisc.shtml
http://tuxedo.org/~esr/faqs/smart-questions.html
Martien
--
Martien Verbruggen |
Interactive Media Division | +++ Out of Cheese Error +++ Reinstall
Commercial Dynamics Pty. Ltd. | Universe and Reboot +++
NSW, Australia |
------------------------------
Date: Thu, 27 Sep 2001 13:02:55 +0100
From: "Chris" <na@na>
Subject: Re: maths
Message-Id: <3bb31576$0$225$ed9e5944@reading.news.pipex.net>
wow, what a friendly bunch you lot are.
i have a script when i need a little help with and look at the abuse i get.
this is a news group, you dont own and cant control what gets posted. this
isn't your news group.
i come on and post a simple question which i can resolve because my perl
knowledge is limited.
if you dont think i deserve help then dont help me, dont just post message
trying to sound hard, it doesn't impress anyone.
the internet is great because it promotes the free and easy exchange of
information, dont tell me that i cant ask for help with perl - who are you
?
chris
------------------------------
Date: Thu, 27 Sep 2001 14:06:54 +0200
From: =?ISO-8859-1?Q?Thomas_B=E4tzler?= <Thomas@Baetzler.de>
Subject: Re: maths
Message-Id: <kd56rtojelmv133pdof2699132o1posvb0@4ax.com>
On Thu, 27 Sep 2001 12:49:47 +0100, "Chris" <na@na> wrote:
>you ?
Go see the Argument Clinic, bud. And don't mention the war.
--
use strict;my($i,$t,@r)=(0,'5 -.@BHJPT4acd6e2hk2lmn2o4r2s3tuz',map{ord}
split//,unpack('u*','L#`T&)QD5#0`#!!`#%1D)#08`#P05!!(3``$$"``#"0L&``('.
'"`P<!`````0$`'));$t=~s/(\d)(.)/$2x$1/eg;map{$t.=substr$t,$i,1,''while
$_--;$i++}@r;print"$t\n";# Thomas@Baetzler.de - http://baetzler.de/perl
------------------------------
Date: 27 Sep 2001 12:19:32 GMT
From: damian@qimr.edu.au (Damian James)
Subject: Re: maths
Message-Id: <slrn9r665s.6uv.damian@puma.qimr.edu.au>
On Thu, 27 Sep 2001 13:02:55 +0100, Chris said:
>wow, what a friendly bunch you lot are.
>
>i have a script when i need a little help with and look at the abuse i get.
Actually all the responses I have seen have answered your question,
and I have seen nothing resembling abuse, though you yourself have
been somewhat rude. If you found the answers to be unsatisfactory, you
should at least point out why -- otherwise we have nothing to go on.
>this is a news group, you dont own and cant control what gets posted. this
>isn't your news group.
No, but we can all control what posts we see. Most people are not
interested in answering the same questions over an over again, which
is why there exist lists of Frequently Asked Questions as well as the
rather extensive documentation, which are both included with perl.
If you refuse to read it, there is little we can do for you. The
answer that you would arrive at if you did would be something like:
$value = sprintf("%.2f", $value);
But you do NEED to read the documentation. No exception. Without
fail. Is that clear?
HTH
Cheers,
Damian
--
@:=grep!(m!$/|#!..$|),split//,<DATA>;@;=0..$#:;while($:=@;){$;=rand
$:--,@;[$;,$:]=@;[$:,$;]while$:;push@|,shift@;if$;[0]==@|;select$,,
$,,$,,1/80;print qq x\bxx((@;+@|)*$|++),@:[@|,@;],!@;&&$/} __END__
Just another Perl Hacker,### http://home.pacific.net.au/~djames.hub
------------------------------
Date: Thu, 27 Sep 2001 14:23:44 +0200
From: =?ISO-8859-1?Q?Thomas_B=E4tzler?= <Thomas@Baetzler.de>
Subject: Re: maths
Message-Id: <bm56rtsmdv9npir7o8959l8bv3mhk24206@4ax.com>
On Thu, 27 Sep 2001 13:02:55 +0100, "Chris" <na@na> wrote:
>wow, what a friendly bunch you lot are.
Yes. Easily amused, too.
>i have a script when i need a little help with and look at the abuse i get.
This doesn't parse quite right.
>this is a news group, you dont own and cant control what gets posted. this
>isn't your news group.
Now that's a good start, but you need to work a bit on the delivery.
See http://baetzler.de/humor/powerposting.html for details.
>i come on and post a simple question which i can resolve because my perl
>knowledge is limited.
Actually, what you say makes sense. You can resolve such trivial Perl
problems (note uppercase P when talking about the language) all by
yourself in no time by RTFM. Typing "perldoc -q round" to search the
FAQ and skimming the results would probably have been faster than
opening Outluck Express, search the Newsgroup list for something with
Perl in its name and posting a question.
>if you dont think i deserve help then dont help me, dont just post message
>trying to sound hard, it doesn't impress anyone.
Oh, you deserve help all right. If you skip back, you'll see that my
first reply included all the information you needed to solve the
problem.
>the internet is great because it promotes the free and easy exchange of
>information, dont tell me that i cant ask for help with perl - who are you
The Internet is a transport medium. You probably meant the Usenet, the
WWW and other services that are accessible via Internet connections.
HTH,
--
use strict;my($i,$t,@r)=(0,'5 -.@BHJPT4acd6e2hk2lmn2o4r2s3tuz',map{ord}
split//,unpack('u*','L#`T&)QD5#0`#!!`#%1D)#08`#P05!!(3``$$"``#"0L&``('.
'"`P<!`````0$`'));$t=~s/(\d)(.)/$2x$1/eg;map{$t.=substr$t,$i,1,''while
$_--;$i++}@r;print"$t\n";# Thomas@Baetzler.de - http://baetzler.de/perl
------------------------------
Date: Thu, 27 Sep 2001 13:18:02 +0200
From: =?ISO-8859-1?Q?Thomas_B=E4tzler?= <Thomas@Baetzler.de>
Subject: Re: no database driver specified and DBI_DSN env var not set
Message-Id: <ln16rtsleamnj46gj5r9qfsh3tq0rcebb9@4ax.com>
On Thu, 27 Sep 2001, "olivier" <ochampag@nortelnetworks.com> wrote:
[...]
>In the require script :
[...]
missing "use strict;"
>sub ConnectDb() {
[...]
> # Parameters
>
> local($dbname)=$_[0];
> local($server)=$_[1];
> local($login)=$_[2];
> local($passwd)=$_[3];
I don't think you want local here. See the section on my vs. local in
"perldoc -q local":
my( $dbname, $server, $login, $passwd ) = @_;
>$connectline="'dbi:mysql:".$dbname.":".$server."','".$login."','".$passw
>d."'";
This looks pretty much broken - have you read the DBD::Mysql manpage?
You also don't need to concat strings and variables; since you're
using double quotes, you can put the variables in the string and let
Perl interpolate them for you:
my $dsn = "DBI:mysql:database=$dbname;host=$server";
> my $dbh = DBI->connect($connectline) || ErrorExit("Database
>connection n
>ot made: $DBI::errstr");
Wrong syntax here - you need to deliver three paramaters, not three
parameters mashed into one:
my $dbh = DBI->connect( $dsn, $login, $passwd );
That should clear up some of your problems.
HTH,
--
use strict;my($i,$t,@r)=(0,'5 -.@BHJPT4acd6e2hk2lmn2o4r2s3tuz',map{ord}
split//,unpack('u*','L#`T&)QD5#0`#!!`#%1D)#08`#P05!!(3``$$"``#"0L&``('.
'"`P<!`````0$`'));$t=~s/(\d)(.)/$2x$1/eg;map{$t.=substr$t,$i,1,''while
$_--;$i++}@r;print"$t\n";# Thomas@Baetzler.de - http://baetzler.de/perl
------------------------------
Date: Thu, 27 Sep 2001 12:00:21 GMT
From: cp <cpryce@pryce.nospam.net>
Subject: Re: no database driver specified and DBI_DSN env var not set
Message-Id: <270920010702281085%cpryce@pryce.nospam.net>
In article <9ouqun$opc$1@bcarh8ab.ca.nortel.com>, olivier
<ochampag@nortelnetworks.com> wrote:
>$dbh=ConnectDb($dbname,$server,$login,$passwd); ==>> Call the function
>defined in the require script
>
>In the require script :
>--------------------
>#!/usr/bin/env perl
>use DBI;
>..
>..
>sub ConnectDb() {
>
> # Parameters
>
> local($dbname)=$_[0];
> local($server)=$_[1];
> local($login)=$_[2];
> local($passwd)=$_[3];
>
> Debug("server -> ".$server);
> Debug("dbname -> ".$dbname);
>
>
>$connectline="'dbi:mysql:".$dbname.":".$server."','".$login."','".$passw
>d."'";
> my $dbh = DBI->connect($connectline) || ErrorExit("Database
>connection n
>ot made: $DBI::errstr");
>
> return $dbh;
>}
Per the DBD::mysql man page:
$driver = "mysql";
$dsn = "dbi:$driver:database=$database;host=$hostname;port=$port";
$dbh = DBI->connect($dsn, $user, $password);
Note that there are three parameters in the connection string. The
first, the dsn can have several options. Options in the dsn are
separated by semi-colons.
perldoc DBD::mysql
perldoc DBI.pm
As mentioned previously, your ConnectDB subroutine should scope its
varaibles with my, and could be written more succinctly as:
sub ConnectDB {
my ($dbame, $server, $login, $passwd) = @_;
...
[snip rest of code]
--
cp
remove 'nospam' to reply
------------------------------
Date: Thu, 27 Sep 2001 06:00:35 -0600
From: Ron Reidy <ron@indra.com>
Subject: Re: oracle
Message-Id: <3BB314E3.9B67BC5D@indra.com>
Esteban Cozzi wrote:
>
> How i can use oracle from perl?
>
> thx
1. Install DBI and DBD::Oracle and optionally Oracle::OCI
2. Read POD docs (especially the sections dealing with PL/SQL).
3. Read Oracle docs (Pro*C and OCI).
4. Make the Perl debugger your friend.
--
Ron Reidy
Oracle DBA
Reidy Consulting, L.L.C.
------------------------------
Date: Thu, 27 Sep 2001 13:32:41 +0100
From: Graham Wood <Graham.T.Wood@oracle.com>
Subject: Re: Problem using Modules
Message-Id: <3BB31C69.34F18AF3@oracle.com>
This is a multi-part message in MIME format.
--------------D01C2873229829539093DD51
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
RoJo wrote:
> I'm trying to learn how to use Packages. I have a web page (.htm)
> with a form that invokes a script (.pl), which "uses" a couple of
> modules (.pm).
>
> When I run this from my web site, IE gives me the message "The page
> cannot be displayed". Since I've already tested these methods in a
> standalone Perl script, I'm led to believe I did something wrong with
> the packages. So I tried to run it from my hard drive (where I have
> ActivePerl installed). I get the "Save As" dialog box, which asks me
> if I want to save the .pl file. This makes me think my (Win2000
> Professional) file associations are wrong, so I associated .pl and .pm
> with perl.exe, but to no avail. Still got "Save As".
Have you tried running a script that doesn't use modules from the same
place? It sounds like your web server is not configured to run perl
scripts, either at all, or from where you are attempting to run it.
After you get a script running, you might have problems with packages not
being found if they are in the perl\lib or perl\site\lib directories as
your web client probably won't be using the same environment as you
normally do. Use "use lib" statements to tell perl specifically where to
find them or put the packages into the directory where the script is (eg
cgi-bin). I don't think this is what your current problem is though.
Graham Wood
--------------D01C2873229829539093DD51
Content-Type: text/x-vcard; charset=UTF-8;
name="Graham.T.Wood.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Graham Wood
Content-Disposition: attachment;
filename="Graham.T.Wood.vcf"
begin:vcard
n:;Graham
x-mozilla-html:FALSE
adr:;;;;;;
version:2.1
email;internet:Graham.T.Wood@oracle.com
fn:Graham Wood
end:vcard
--------------D01C2873229829539093DD51--
------------------------------
Date: Thu, 27 Sep 2001 12:44:15 GMT
From: "Blnukem" <blnukem@hotmail.com>
Subject: Push into an array
Message-Id: <zaFs7.20383$w7.3725020@news02.optonline.net>
Hi group
How do I get this code to "push" $I into the @items array. Everything I
tried I get an error. This code only gives me the last count of $i "9".
print "Content-type: text/html\n\n";
for ($i = 0; $i < 10; $i +=1 ){
@items = "$i"
}
print "@items " ;
------------------------------
Date: Thu, 27 Sep 2001 14:56:52 +0200
From: =?ISO-8859-1?Q?Thomas_B=E4tzler?= <Thomas@Baetzler.de>
Subject: Re: Push into an array
Message-Id: <5286rtscp25cql461vr98h10j68cvdskga@4ax.com>
On Thu, 27 Sep 2001, "Blnukem" <blnukem@hotmail.com> wrote:
>How do I get this code to "push" $I into the @items array. Everything I
>tried I get an error. This code only gives me the last count of $i "9".
Yes. Did you expect something else?
>print "Content-type: text/html\n\n";
>for ($i = 0; $i < 10; $i +=1 ){
>
>
>@items = "$i"
This assign a string containing a number to the array. If you want to
add data to an existing array, use unshift, push, splice or array
operations.
>}
>print "@items " ;
Well, there is only one element to print in there.
Try this:
#!/usr/bin/perl -w
# important: turn on warnings and strict!
use strict;
print "Content-type: text/html\n\n";
# declare the variables you use!
my @items;
for( my $i = 0; $i < 10; $i++ ){
push @items, $i;
}
print "Number of items in array: ", scalar(@items), "\n";
print "Index of last element in array: $#items\n";
print "Elements in array: ", join(', ', @items ), "\n";
__END__
HTH,
--
use strict;my($i,$t,@r)=(0,'5 -.@BHJPT4acd6e2hk2lmn2o4r2s3tuz',map{ord}
split//,unpack('u*','L#`T&)QD5#0`#!!`#%1D)#08`#P05!!(3``$$"``#"0L&``('.
'"`P<!`````0$`'));$t=~s/(\d)(.)/$2x$1/eg;map{$t.=substr$t,$i,1,''while
$_--;$i++}@r;print"$t\n";# Thomas@Baetzler.de - http://baetzler.de/perl
------------------------------
Date: Thu, 27 Sep 2001 12:05:16 GMT
From: "David Scarlett" <dscarlett@REMOVETHIS.optushome.com.au>
Subject: Search engine
Message-Id: <0CEs7.15238$Tv6.79120@news1.rdc1.nsw.optushome.com.au>
Firsly, please don't tell me to post this in
comp.infosystems.www.authoring.cgi, it doesn't belong there, this is a
perl-specific question. ;-)
I'm thinking about write a perl script that will search through a FAQ for
keywords, but I'm not sure what would be the best way to implement it. I
want each answer (ie section of the FAQ) to be in seperate html files, with
each having certain keywords that will be matched against those searched
for.
Here are a few ways I've thought of implementing it, I'd appreciate any
criticisms/suggestions.
1 - Have a file with each line containing the name of an HTML file (eg 1-2-3
translates to question 1.2.3 in the FAQ, which could be in a certain place,
eg ...faq/1-2-3.html) and a list of keywords. This could just be read in,
split and checked for matches one line at a time easily enough, but it would
be annoying to have to edit this file every time a new question is put in
the FAQ.
2 - Have a DBM hash with keywords as keys and faq entries as values (or
vice-versa) (eg. $answers{keyword} = "1-2-3:3-4-5:4-5-6"). Although, this
too would also be an annoyance to update.
3 - Have all the answers in seperate HTML in a certain directory (just like
in the others) and glob them, open each one and look for a META tag with the
keywords. This would be easy to update, but I'd imagine it'd be quite
slow.....
Of course I could always write another program to glob the FAQ questions,
extract the keywords from the META tags and save them for use in either
methods 1 or 2.....
TiA,
--
David Scarlett
dscarlett@REMOVETHIS.optushome.com.au
http://members.optushome.com.au/dscarlett/
"Damn it, Kif, where's the little umbrella? That's what makes it a scotch on
the rocks!"
-Capt. Zapp Brannigann, Futurama
------------------------------
Date: Thu, 27 Sep 2001 10:12:19 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Security of letting user specify regex in CGI script?
Message-Id: <gpu5rtsc21bopgqh21ub59vvec7l1qtptl@4ax.com>
Bart Lateur wrote:
> $query = eval "sub { /\ba\b/ and (/\bb\b/ or /\bc\b/ }";
Whoops, backslash quoting problem. But, since you likely know this is
not how to generate this sub, a fix is not relevant. Well alright then:
$query = eval 'sub { /\ba\b/ and (/\bb\b/ or /\bc\b/ }';
--
Bart.
------------------------------
Date: Thu, 27 Sep 2001 13:10:00 +0200
From: EXP <nospaming@gmx.net>
Subject: Re: Setting max. values (cpu/ram usage) for mod_perl scripts?
Message-Id: <3BB30908.EB1C993F@gmx.net>
EXP wrote:
> I have not tested the cpu limit yet
>
I tested it now, it doesn't work for me. That is to say it works fine
but killing every apache child that reaches a certain cputime limit is
simple not practical since they might well have reached ist by serving
10k requests of simple html pages over say the last 3weeks.
Has anybody some other ideas how this (killing apache once a mod_perl
script reaches a certain cputime or better but I think not at all
possible terminating only the mod_perl script) could be done?
BYe!
EXP
------------------------------
Date: Thu, 27 Sep 2001 10:57:32 +0100
From: slightlysprintingdog@ntlworld.com
Subject: Re: Sourcing Things in Perl ?
Message-Id: <3BB2F80C.B65EFD0E@ntlworld.com>
Okay, forgive my ignorance.
I have a program called ModelSim that I execute from a Perl Tk script.
It needs certain environment variables set up before it is run.
There are two files that need sourcing. One a one point in time and the other later.
I have limited knowledge of the source files, they have lots of 'setenv' commands in
them and various 'echos' to let you know whats going on but thats all.
Using a Solaris Unix system, I usually type :
source <filename> in a terminal when needed and away we go.
This process needs to be automated into the Perl script.
As explained I have just tried to use perls 'system' command to perform the operation
that I type at the prompt and this did not have the desired affect - whether it did
source the file or not.
I'd assume any changes need to be visible when ModelSim is run.
Does this help ?
> I trying to source some stuff in a Perl Tk script.
What does that mean? Are you trying to use the source command of csh?
Read Perl FAQ section 8, question
I {changed directory, modified my environment} in a perl
script. How come the change disappeared when I exited the
script? How do I get my changes to be visible?
> Basically I have a string setup somewhere else in the program ;
> $sourceme which contains the full path of the source file.
You will really need to be much, much more specific about what exactly
you're trying to achieve. Is that 'source file' perl code? Then look
into require and do (see perlfunc)
> And then I'm using the system command to source it like so :
>
> system ( "source $sourceme" );
Some shells have that as a builtin command, but I haven't seen it as an
external command on any system I've worked on. In either case, it won't
'source' anything into the current process.
> I don't get anything written to the console and the file is definately
> not sourced.
It probably was sourced, or maybe not. Depends on the shell that got
fired up. However, you won't really know, since you don't check the
return value of system, which you should do.
> Any ideas ?
Lots. But the first thing _you_ need to do is explain what you want. Not
what you think you need to do.
------------------------------
Date: Thu, 27 Sep 2001 11:05:52 +0100
From: slightlysprintingdog@ntlworld.com
Subject: Re: Sourcing Things in Perl ?
Message-Id: <3BB2F9FF.D1538F3A@ntlworld.com>
Is the file you're sourcing a shell script?
>I'm not sure, from what I can see it looks like a shell script.
>It contains a load of 'setenv' and 'echo' commands and thats about it.
Is it for the same shell that the perl script is running under?
>Yes.
Is it the for the same shell that an individual user of your script uses?
>Yes.
Can you guarantee that this is always the case?
>Yes.
Are you checking the return value of system? Was it successful?
>I don't know how. Would a 'die' command surfice ?
Of course, even if all the above is acceptable, it still won't work.
Assuming the file is sourced:
system() creates a child process
the child process sources the file
the child process terminates
all results of sourcing are lost
period
>Aahh.
If I understand your situation, this is one of the oldest questions
asked, and the answer is:
No, a child process cannot alter it's parents environment except by
very complicated, increasingly dangerous (not to mention just
plain "bad") hacks. This was intended as a feature.
Try rethinking your problem. I've actually recently sought a Perl module
for parsing shell scripts. It could return a hash of variables set
within the script (since you probably don't want an arbitrary shell
script to mess with your %ENV directly) and possibly taint it. I
searched on cpan but didn't turn up anything (but then, I could've been
blind). Anyone know of anything? Even Python has an shutil script.
Of course, if you're trying to "source" a perl script, you probably want
to 'require' or 'use' it...not system().
Okay, here's what I'm trying to do.....
I have a program called ModelSim that I execute from a Perl Tk script.
It needs certain environment variables set up before it is run.
There are two files that need sourcing. One a one point in time and the
other later.
Using a Solaris Unix system, I usually type :
source <filename> in a terminal when needed and away we go.
This process needs to be automated into the Perl script.
Does this help ?
------------------------------
Date: Thu, 27 Sep 2001 11:19:55 GMT
From: tim@vegeta.ath.cx (Tim Hammerquist)
Subject: Re: Sourcing Things in Perl ?
Message-Id: <slrn9r63js.uim.tim@vegeta.ath.cx>
Me parece que slightlysprintingdog@ntlworld.com dijo:
[ snip ]
> Are you checking the return value of system? Was it successful?
>
> >I don't know how. Would a 'die' command surfice ?
Well, system()'s backwards on return value, but the following should do
the trick (if you need system()):
system("shell command") and die "shell command failed: $!\n";
> Okay, here's what I'm trying to do.....
>
> I have a program called ModelSim that I execute from a Perl Tk script.
> It needs certain environment variables set up before it is run.
> There are two files that need sourcing. One a one point in time and the
> other later.
> Using a Solaris Unix system, I usually type :
> source <filename> in a terminal when needed and away we go.
> This process needs to be automated into the Perl script.
>
> Does this help ?
Yes, though I'm not sure what you mean about the files having to be
sourced separately/at different times.
You can Write a csh script like this:
#!/bin/csh
# source_and_run.csh
source your_csh_script
Your_Perl-TK_script
Please forgive me if my csh code is bad. I've never used csh, and tcsh
only briefly.
This may be a good time to call ModelSim's tech support. Without
your posting relavant code, we may not be able to help you much more.
If this is the ModelSim you're talking about (I'm guessing it is), the
following URL and their site sounds like a good starting point and names
a few newsgroups that are probably more familiar with ModelSim than I am
personally.
http://www.model.com/resources/default.asp
BTW: `perldoc -f system` would've told you that "source $sourceme" was
running in a bourne shell (/bin/sh), not csh.
--
Civilization is the limitless multiplication of unnecessary necessities.
-- Mark Twain
------------------------------
Date: 27 Sep 2001 05:27:56 -0700
From: ggrothendieck@volcanomail.com (Grod)
Subject: Re: Transforming HTML
Message-Id: <ffd662ea.0109270427.d548381@posting.google.com>
nobull@mail.com wrote in message news:<u97kulvm9u.fsf@wcl-l.bham.ac.uk>...
> "Raj" <oneconcept@yahoo.co.uk> writes:
> > Basically, I would like to turn:
> > <INPUT TYPE="text" NAME="xFname">
> > into:
> > <INPUT TYPE=text" NAME="xFname" VALUE="Raj">
>
> s/(<INPUT TYPE="text") (NAME="x(\w+)")>/$1 VALUE="$address{$3}" $2/;
>
> This will not work if the <INPUT> tag does not appear exactly as you
> describe all on one line.
This problem about possibly spanning multiple lines could be handled
without using Perl modules by piping the input through the free tidy
program first. See http://web3.w3.org/People/Raggett/tidy/.
------------------------------
Date: Thu, 27 Sep 2001 13:51:28 +0100
From: "Jeremy Smith" <removespamjeremyalansmith@netscapeonline.co.uk>
Subject: Re: Win32 Perl - Setting ENV Variables from Command-line
Message-Id: <YdFs7.1831$zu1.288621@news6-win.server.ntlworld.com>
> >So the question is: How do I set ENV variables when running a local Perl
> >script on a local interpreter.
>
> Set them before running the script, for example in a BAT file that also
> runs the script. Set them in perl by assigning to $ENV{BLAH}, before
> calling system() on the script.
>
> Or, entirely different approach: set them in a module that you load when
> starting up the script:
Thanks, that's just what I was looking for. Outputting the Perl module
script would seem to be the easiest.
BTW, the server isn't Apache, it's a custom one I'm writing partly as an
exercise. This means I have to work out the ENV variables from the HTTP
header, which isn't a problem.
Basically, I want my small server program to have CGI scripting via Perl, so
it just runs Perl after setting all the ENV variables (as if it were a
'proper' web server).
Thanks!
Jeremy.
------------------------------
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 1830
***************************************