[24500] in Perl-Users-Digest
Perl-Users Digest, Issue: 6680 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jun 11 09:06:05 2004
Date: Fri, 11 Jun 2004 06:05:09 -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 Fri, 11 Jun 2004 Volume: 10 Number: 6680
Today's topics:
Re: $array.fieldname question <nobull@mail.com>
Re: Cute bit of Perl to Assign $1,$2 to named variables <bik.mido@tiscalinet.it>
Re: Expanding scalar hash element in array ref. <dima@program.ru>
Re: Extracting Text <tore@aursand.no>
Re: Extracting Text <postmaster@castleamber.com>
Re: Extracting Text (Anno Siegel)
Re: Extracting Text <peter@semantico.com>
Re: Extracting Text <tore@aursand.no>
How to test a variable to see if it is a valid regexp p (Leif Wessman)
Re: How to test a variable to see if it is a valid rege <usenet@morrow.me.uk>
Re: How to test a variable to see if it is a valid rege <thepoet_nospam@arcor.de>
Re: How to test a variable to see if it is a valid rege <dwall@fastmail.fm>
Negative Look Ahead question? (Simon Fairey)
Re: Negative Look Ahead question? (Anno Siegel)
Re: Negative Look Ahead question? <usenet@morrow.me.uk>
Re: parsing file name assigning extension to a variable <tore@aursand.no>
Re: parsing file name assigning extension to a variable <postmaster@castleamber.com>
perl -e '%h=(a=>1,b=>2); for (keys %h) { s/a/b/ }; prin (A. Farber)
Re: perl -e '%h=(a=>1,b=>2); for (keys %h) { s/a/b/ }; <usenet@morrow.me.uk>
Re: perl -e '%h=(a=>1,b=>2); for (keys %h) { s/a/b/ }; (Anno Siegel)
Re: Perl cgi on Windows 2003 Server fails (Hallvard ?strem)
Re: Perl cgi on Windows 2003 Server fails <usenet@morrow.me.uk>
Re: perl IF DBI::errsrt moller@notvalid.se
Re: Regular expressions <ittyspam@yahoo.com>
Re: SOAP::Lite using HTTPS as a transport? <usenet@morrow.me.uk>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 11 Jun 2004 12:37:48 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: $array.fieldname question
Message-Id: <u9hdti5k1w.fsf@wcl-l.bham.ac.uk>
ZZT <a@b.c> writes:
> $def.var1=value1;
> $def.var2=value2;
> $ref.var1=value3;
> $ref.var2=value4;
That is not Perl5 syntax. Please learn about Perl's data strucutres
and express code fragments in your posts in (strict) Perl5 syntax.
I think you've been told this before....
http://groups.google.com/groups?threadm=aspt16%24qol%241%40news1.wdf.sap-ag.de
http://groups.google.com/groups?threadm=al7nbd%24bu9%241%40news1.wdf.sap-ag.de
If you are asking questions about Perl6 then please say so.
I shall assume you are planning to use Perl5 and mean:
$def{var1}='value1';
$def{var2}='value2';
$ref{var1}='value3';
$ref{var2}='value4';
> @sections=("def","ref");
> foreach (@sections)
> {
> function1 ($$_.var1); # -> function1($def.var1);
> }
>
> How can I do this?
You are asking "How can I use a variable as a variable name?". This
is a FAQ.
Simply correct the syntax as described above and it will work so long
as %def and %ref are package variables.
But this is using symbolic references you should should not do that
unless you have a damn good reason (you don't).
You should use real references and a HoH.
For details see aforementioned FAQ.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Fri, 11 Jun 2004 14:11:53 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Cute bit of Perl to Assign $1,$2 to named variables
Message-Id: <to6jc0tth3pupt1hl1n8aclum7v0m2jbn7@4ax.com>
On Mon, 07 Jun 2004 18:37:31 GMT, Jeff Boes <jboes@qtm.net> wrote:
>> Again, how is it possible that you had overlooked that for so many
>> years?!?
>
>Easy. TMTOWTDI, y'know. Someone can be a Perl programmer without knowing
>each of the dozen WTDI. Are they the best possible Perl programmer they
I agree, to make an example last week I was surprised to spot a
solution to a problem posted here based on the return value of the ..
op: a solution that I may have devised myself, if only I had
remembered that ..'s return value is not a simple boolean. (Yes I know
that boolean values do not exist in Perl5, but I guess you know what I
mean!)
Yet, the .. operator is somewhat exotic, and I think most Perl
programmers would at least partially agree on this.
OTOH I cannot give an explicit example, but I'm quite sure that
assignements of the form
my ($n,$m)=/($something)...($somethingelse)/
do appear dozens of times in perldoc pages and in scripts posted here,
etc.
>I wholeheartedly agree with other posters in this thread: someone goes,
>"Hey, look what I found!", and three people jump down his throat saying,
>"You idjit, that's been there since Larry Wall was in short pants!"
Except that *nobody* here has said "You idjit", either explicitly or
implicitly.
It has only pointed out that the observed behaviour is used so
commonly that it seems strange to find someone finding it surprising.
>Sure, someone's going to post things like:
>
> $a += 1; # Wow, I can do this!
>
>but instead of whacking them on top of the head with a rolled up
>newspaper, you could (a) ignore them or (b) point out that all of these
>are possible, too:
>
> $a *= 3;
> $a .= " cats";
> $a &= 7;
And IMHO it is exactly what has been done: the OP has been told that
what he had found can be explained in a straightforward manner taking
into account that (i) m// has a return values, (ii) it acts by default
on $_ is nothing else is specified with =~.
>P.S.: I find it amusing that the OP's signature included:
>
>> vim -c ":%s.^.CyrnfrTfcbafbeROenzSZbbyranne.|:%s/[R-T]/ /Ig|:normal ggVGg?"
Yes, definitely amazing!!
>Sure enough, [s]he's a Vim expert. Now, I don't know enough about Vim to
> get out of it back to a shell prompt. I hope that if I ever have to
Vim? That editor that has two modes, one that beeps and one that
doesn't?!? ;-)
>learn it, I can learn it from the OP. And that if I post something dull
>and old-hat on the equivalent Vim newsgroup, I suspect the OP will have
>the grace to deal with me in a way quite unlike the way this thread
>started out.
To be sure I read again the posts and I don't really see any
aggressive behaviour. People were only saying that they found it
disconcerting/hard to believe that such a *basic*, *common*, *well
defined*, *standard* behaviour had passed unobserved for so many
years.
It's *evidence* that there's a general consensus on this, since only a
few posters seemed to think otherwise.
I am a Perl beginner too, but I definitely agree on this point of
view, even if I may have similarly missed something quite as obvious
myself...
Last, please note that the OP himself didn't feel offended by the
answers he got, so how can you judge the way "he's been dealt with"?!?
Michele
--
you'll see that it shouldn't be so. AND, the writting as usuall is
fantastic incompetent. To illustrate, i quote:
- Xah Lee trolling on clpmisc,
"perl bug File::Basename and Perl's nature"
------------------------------
Date: Fri, 11 Jun 2004 15:11:48 +0400
From: Dmitry Roslyakov <dima@program.ru>
Subject: Re: Expanding scalar hash element in array ref.
Message-Id: <cac3p0$1p8k$1@news.rtcomm.ru>
perldoc -f ref
...
if (ref($conf->{$var}) eq 'ARRAY') {
# You have an array reference
}
...
> Hello guys,
> Is there any way in Perl to convert scalar hash element value to an
> array reference with the original scalar as a first element of the
> array. I just
> want to convert the following PHP code into Perl:
>
> <?php
>
>
> while ($buf = fgets($fp, 1024) ) {
>
> // ... parsing code here
>
> if (array_key_exists($var, $conf)) {
> if (!is_array($conf[$var])) {
> $tmpval = $conf[$var]; // grab original value
> $conf[$var] = array(); // convert to array
> $conf[$var][] = $tmpval; // store original value as a first
> element
> }
> $conf[$var][] = $val;
> } else {
> $conf[$var] = $val;
> }
> // ...
>
> } // end while
>
> ?>
>
> The idea here is that some variable can have multiple entries in conf
> file, so
> I want to store them in a 'bucket' under the same key. But most of the
> entries
> are simple 'var = value' pair, so I want to have flexibility to
> process both.
>
> In Perl there is a way to check for existence of 'key' with exists()
> function
> (which is equivalent to PHP array_key_exists()). BUT the problem I
> encountered
> in Perl is to convert the scalar value of the key to array reference.
>
> <perl>
>
> while ( <$fh> ) {
>
> # parsing code here
>
> if ( exists($conf->{$var}) ) {
> # ??? There's nothing equivalent to PHP is_array() function in
> Perl
> # How do I know if value is still a scalar or an already an array
> ref
>
> # If I value is already an array ref, I would do
> push @{$conf->{$var}}, $val;
>
>
> } else {
> # var encountered for the first time
> $conf->{$var} = $val;
> }
>
> } # end while
>
> </perl>
>
> Is there anyway to do it? Any suggestion are appreciated
>
> $dmitri--; # ;-)
------------------------------
Date: Fri, 11 Jun 2004 12:24:23 +0200
From: Tore Aursand <tore@aursand.no>
Subject: Re: Extracting Text
Message-Id: <pan.2004.06.11.10.18.40.794760@aursand.no>
On Fri, 11 Jun 2004 00:35:59 -0700, Jake Gottlieb wrote:
> while (<file.txt>) {
That doesn't read from "file.txt". This one does (untested);
open( FH, '<', 'file.txt' ) or die "$!\n";
while ( <FH> ) {
# ...
}
> $line = $_;
> $yes = (index $line, 'GO:000');
> if ($yes > -1) {
> print "YES : $line";
> }
> if ($line =~ /ENSG\d+.\d\s+\S+\s+GO:\d{7}\s+\d+\s+/){
> print "La GO! $line \n";
> }
> }
If you are sure that you can match on 'GO:000', you're on the right track
using 'index'. But you don't need any regular expressions (untested);
open( FH, '<', 'file.txt' ) or die "$!\n";
while ( <FH> ) {
next unless ( index($_, 'GO:000') >= 0 );
print;
}
close( FH );
Also: Be sure to 'use strict' and 'use warnings' in your script(s).
--
Tore Aursand <tore@aursand.no>
"Poor management can increase software costs more rapidly than any
other factor." (Barry Boehm)
------------------------------
Date: Fri, 11 Jun 2004 05:48:54 -0500
From: John Bokma <postmaster@castleamber.com>
Subject: Re: Extracting Text
Message-Id: <40c98e18$0$199$58c7af7e@news.kabelfoon.nl>
Tore Aursand wrote:
> next unless ( index($_, 'GO:000') >= 0 );
index($_, 'GO:000') > -1 or next;
--
John MexIT: http://johnbokma.com/mexit/
personal page: http://johnbokma.com/
Experienced Perl programmer available: http://castleamber.com/
Happy Customers: http://castleamber.com/testimonials.html
------------------------------
Date: 11 Jun 2004 11:08:59 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Extracting Text
Message-Id: <cac3sb$jkp$1@mamenchi.zrz.TU-Berlin.DE>
John Bokma <postmaster@castleamber.com> wrote in comp.lang.perl.misc:
> Tore Aursand wrote:
>
> > next unless ( index($_, 'GO:000') >= 0 );
>
> index($_, 'GO:000') > -1 or next;
1 + index $_, 'GO:000' or next;
Anno
------------------------------
Date: Fri, 11 Jun 2004 12:16:32 +0100
From: Peter Hickman <peter@semantico.com>
Subject: Re: Extracting Text
Message-Id: <40c99490$0$21761$afc38c87@news.easynet.co.uk>
Anno Siegel wrote:
> Peter Hickman <peter@semantico.com> wrote in comp.lang.perl.misc:
>>while ( my $line = <> ) {
>> next unless $line =~ m/\s+GO:0009986\s+/;
> ^ ^
> The "+"es make no difference here.
Good catch.
> That can be simplified to
>
> /\sGO:0009986\s/ and print while <>;
Now you are just showing off ;-)
------------------------------
Date: Fri, 11 Jun 2004 14:34:03 +0200
From: Tore Aursand <tore@aursand.no>
Subject: Re: Extracting Text
Message-Id: <pan.2004.06.11.12.33.34.640009@aursand.no>
On Fri, 11 Jun 2004 11:08:59 +0000, Anno Siegel wrote:
>>> next unless ( index($_, 'GO:000') >= 0 );
>> index($_, 'GO:000') > -1 or next;
> 1 + index $_, 'GO:000' or next;
While we're at it: How about keeping those two lines (the check and the
print) on one line?
while ( <> ) {
index($_, 'GO:000') and print;
}
--
Tore Aursand <tore@aursand.no>
"People that think logically are a nice contrast to the real world."
(Matt Biershbach)
------------------------------
Date: 11 Jun 2004 05:04:30 -0700
From: leifwessman@hotmail.com (Leif Wessman)
Subject: How to test a variable to see if it is a valid regexp pattern?
Message-Id: <64beeaad.0406110404.3b0a4adf@posting.google.com>
How do I test a variable to see if it contains a valid regexp pattern?
Is it possible?
Leif
------------------------------
Date: Fri, 11 Jun 2004 12:16:58 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: How to test a variable to see if it is a valid regexp pattern?
Message-Id: <cac7rq$dgi$3@wisteria.csv.warwick.ac.uk>
Quoth leifwessman@hotmail.com (Leif Wessman):
> How do I test a variable to see if it contains a valid regexp pattern?
> Is it possible?
my $maybe_re = ...;
my $re = eval { qr/$maybe_re/ };
$@ and print "regex wasn't valid: $@";
Ben
--
If I were a butterfly I'd live for a day, / I would be free, just blowing away.
This cruel country has driven me down / Teased me and lied, teased me and lied.
I've only sad stories to tell to this town: / My dreams have withered and died.
ben@morrow.me.uk (Kate Rusby)
------------------------------
Date: Fri, 11 Jun 2004 14:22:34 +0200
From: Christian Winter <thepoet_nospam@arcor.de>
Subject: Re: How to test a variable to see if it is a valid regexp pattern?
Message-Id: <40c9a40a$0$26361$9b4e6d93@newsread4.arcor-online.net>
Leif Wessman schrieb:
> How do I test a variable to see if it contains a valid regexp pattern?
> Is it possible?
You can use
eval { qr/$pattern/ } or warn $@;
to precompile your pattern and catch possible errors.
HTH
-Christian
------------------------------
Date: Fri, 11 Jun 2004 12:37:04 -0000
From: "David K. Wall" <dwall@fastmail.fm>
Subject: Re: How to test a variable to see if it is a valid regexp pattern?
Message-Id: <Xns950557A8FBB8Cdkwwashere@216.168.3.30>
leifwessman@hotmail.com (Leif Wessman) wrote:
> How do I test a variable to see if it contains a valid regexp pattern?
> Is it possible?
my $string = 'tes(ting';
my $regex;
eval { $regex = qr($string); };
print $@ ? 'Invalid regex' : 'Valid regex';
------------------------------
Date: 11 Jun 2004 04:39:16 -0700
From: simon.fairey@ft.com (Simon Fairey)
Subject: Negative Look Ahead question?
Message-Id: <af9e67d1.0406110339.7e4483ee@posting.google.com>
Why does the following not work unless I put foo before the (?!)
portion, I have strings and I want to match all strings (I know
nothing about the content of the strings) that don't contain a certain
phrase but I have to use a negative RE rather than negating a positive
RE
foreach(qw(foobar fooboo)){
print "Checking <$_>....";
if(/(?!bar)/){
print "Match\n";
}else{
print "No Match\n";
}
}
I'm reading the docs but can't find out something core about the way
regexps work
that I'm obviously missing that will explain why this fails?
Cheers
Si
------------------------------
Date: 11 Jun 2004 11:54:35 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Negative Look Ahead question?
Message-Id: <cac6hr$lvj$2@mamenchi.zrz.TU-Berlin.DE>
Simon Fairey <simon.fairey@ft.com> wrote in comp.lang.perl.misc:
> Why does the following not work unless I put foo before the (?!)
> portion, I have strings and I want to match all strings (I know
> nothing about the content of the strings) that don't contain a certain
> phrase but I have to use a negative RE rather than negating a positive
> RE
>
> foreach(qw(foobar fooboo)){
> print "Checking <$_>....";
> if(/(?!bar)/){
> print "Match\n";
> }else{
> print "No Match\n";
> }
> }
The negative lookahead (?!bar) matches (i.e. doesn't find "bar") right
at the beginning of the strings, so the regex engine happily reports
a match. Look-around assertions must be anchored to some place in the
string to be useful.
Anno
------------------------------
Date: Fri, 11 Jun 2004 12:06:33 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Negative Look Ahead question?
Message-Id: <cac789$dgi$1@wisteria.csv.warwick.ac.uk>
Quoth anno4000@lublin.zrz.tu-berlin.de (Anno Siegel):
> Simon Fairey <simon.fairey@ft.com> wrote in comp.lang.perl.misc:
> > Why does the following not work unless I put foo before the (?!)
> > portion, I have strings and I want to match all strings (I know
> > nothing about the content of the strings) that don't contain a certain
> > phrase but I have to use a negative RE rather than negating a positive
> > RE
> >
> > foreach(qw(foobar fooboo)){
> > print "Checking <$_>....";
> > if(/(?!bar)/){
> > print "Match\n";
> > }else{
> > print "No Match\n";
> > }
> > }
>
> The negative lookahead (?!bar) matches (i.e. doesn't find "bar") right
> at the beginning of the strings, so the regex engine happily reports
> a match. Look-around assertions must be anchored to some place in the
> string to be useful.
If you just want the assertion '$_ does not contain bar' then you want
if (!/bar/) {
print "match";
}
else {
print "no match";
}
Ben
--
Although few may originate a policy, we are all able to judge it.
- Pericles of Athens, c.430 B.C.
ben@morrow.me.uk
------------------------------
Date: Fri, 11 Jun 2004 12:24:24 +0200
From: Tore Aursand <tore@aursand.no>
Subject: Re: parsing file name assigning extension to a variable
Message-Id: <pan.2004.06.11.10.22.05.642048@aursand.no>
On Thu, 10 Jun 2004 19:54:58 -0500, John Bokma wrote:
> [...]
> Or File::Find
...or File::Find::Rule, which I find a lot easier to work with. :)
--
Tore Aursand <tore@aursand.no>
------------------------------
Date: Fri, 11 Jun 2004 05:49:21 -0500
From: John Bokma <postmaster@castleamber.com>
Subject: Re: parsing file name assigning extension to a variable
Message-Id: <40c98e33$0$199$58c7af7e@news.kabelfoon.nl>
Tore Aursand wrote:
> On Thu, 10 Jun 2004 19:54:58 -0500, John Bokma wrote:
>
>>[...]
>>Or File::Find
>
> ...or File::Find::Rule, which I find a lot easier to work with. :)
I will have a look into that one, thanks.
--
John MexIT: http://johnbokma.com/mexit/
personal page: http://johnbokma.com/
Experienced Perl programmer available: http://castleamber.com/
Happy Customers: http://castleamber.com/testimonials.html
------------------------------
Date: 11 Jun 2004 04:14:45 -0700
From: Alexander.Farber@t-online.de (A. Farber)
Subject: perl -e '%h=(a=>1,b=>2); for (keys %h) { s/a/b/ }; print keys %h'
Message-Id: <c9ccaf83.0406110314.4dfa34a5@posting.google.com>
Hi,
I have a hash where keys and values are file paths.
I'm going to use that hash to generate a GNU Makefile.
For some parts of the file paths I have shortcuts
(like $(TOPDIR)) which I'd like to substitute into the
paths. I.e. I'd like to go through the hash keys and
perform a substitution on them, like in this test case:
perl -e '%h=(a=>1,b=>2); for (keys %h) { s/a/b/ }; print keys %h'
ab
The code above doesn't work as expected - I'd need it to
print "bb" and not "ab". Looks like the hash keys aren't
the "lvalue" described in the "perldoc perlsyn":
If any element of LIST is an lvalue, you can modify it by
modifying VAR inside the loop. Conversely, if any element
of LIST is NOT an lvalue, any attempt to modify that ele-
ment will fail. In other words, the "foreach" loop index
variable is an implicit alias for each item in the list
that you're looping over.
What could I do to solve this problem, please?
I'd prefer a solution with for() or while() because
I need to perform few more operations on the hash keys.
Regards
Alex
------------------------------
Date: Fri, 11 Jun 2004 11:27:48 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: perl -e '%h=(a=>1,b=>2); for (keys %h) { s/a/b/ }; print keys %h'
Message-Id: <cac4vk$b2c$2@wisteria.csv.warwick.ac.uk>
Quoth Alexander.Farber@t-online.de (A. Farber):
>
> I have a hash where keys and values are file paths.
> I'm going to use that hash to generate a GNU Makefile.
> For some parts of the file paths I have shortcuts
> (like $(TOPDIR)) which I'd like to substitute into the
> paths. I.e. I'd like to go through the hash keys and
> perform a substitution on them, like in this test case:
>
> perl -e '%h=(a=>1,b=>2); for (keys %h) { s/a/b/ }; print keys %h'
> ab
>
> The code above doesn't work as expected - I'd need it to
> print "bb" and not "ab".
>
> What could I do to solve this problem, please?
You could try (untested)
my %h = ( a => 1, b => 2 );
%h = map {
(my $k = $_) =~ s/a/b/;
( $k => $h{$_} );
} keys %h;
> I'd prefer a solution with for() or while() because
> I need to perform few more operations on the hash keys.
You can do what you like to the keys inside the map loop as well.
Ben
--
All persons, living or dead, are entirely coincidental.
ben@morrow.me.uk Kurt Vonnegut
------------------------------
Date: 11 Jun 2004 11:44:02 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: perl -e '%h=(a=>1,b=>2); for (keys %h) { s/a/b/ }; print keys %h'
Message-Id: <cac5u2$lvj$1@mamenchi.zrz.TU-Berlin.DE>
A. Farber <Alexander.Farber@t-online.de> wrote in comp.lang.perl.misc:
> Hi,
>
> I have a hash where keys and values are file paths.
> I'm going to use that hash to generate a GNU Makefile.
> For some parts of the file paths I have shortcuts
> (like $(TOPDIR)) which I'd like to substitute into the
> paths. I.e. I'd like to go through the hash keys and
> perform a substitution on them, like in this test case:
>
> perl -e '%h=(a=>1,b=>2); for (keys %h) { s/a/b/ }; print keys %h'
> ab
I don't see at all how that helps substituting parts of file names
with makefile variables. A templating solution comes to mind.
Lot's of modules for that on CPAN, maybe too many.
> The code above doesn't work as expected - I'd need it to
> print "bb" and not "ab".
Do you expect the hash to have the key "b" twice? It can't,
hash keys are unique.
> Looks like the hash keys aren't
> the "lvalue" described in the "perldoc perlsyn":
[...]
No, the elements returned from "keys" aren't lvalues. "perldoc
-f keys" explicitly says so:
The returned values are copies of the original
keys in the hash, so modifying them will not
affect the original hash. Compare "values".
("values" *does* return lvalues.)
> What could I do to solve this problem, please?
Nothing, as long as your solution requires a hash to contain the
same key twice. What is it you really want to achieve?
Anno
------------------------------
Date: 11 Jun 2004 04:49:36 -0700
From: hallvardost@hotmail.com (Hallvard ?strem)
Subject: Re: Perl cgi on Windows 2003 Server fails
Message-Id: <79b0e251.0406110349.53d9eeb3@posting.google.com>
Thanks for your help, Kevin. The problem persists even if the server
application runs as the current user, that is a user who can execute
perl scripts from the DOS prompt.
FirstClass CGI setup is quite simple and doesn't require any
configuration other than the cgi-bin folder being installed in the
appropriate folder on the file system. The script should execute as
long as it finds the file in the cgi-bin path, and it does if it is
e.g. a precompiled script.
Since my server setup worked just fine on Windows NT, I'm quite sure
my problem must be related to Perl/Windows 2003 Server somehow. Since
Perl works fine from the prompt, I also believe it to be more likely
related to the Windows 2003 Server setup, but how is still a mystery
to me. I'm out of ideas...
Hallvard
spamtotrash@toomuchfiction.com (Kevin Collins) wrote in message news:<slrnccecmb.f8v.spamtotrash@doom.unix-guy.com>...
> In article <79b0e251.0406090128.2536cc08@posting.google.com>, Hallvard ?strem
> wrote:
> > My well tested Perl CGI scripts will not run on my web server after
> > moving it from Windows NT 4.0 to a brand new Windows 2003 Server. The
> > web server software is FirstClass Server 7.1 from Open Text Corp.
> > (http://www.opentext.com/products/firstclass/), and the web server
> > setup is identical with the setup on NT, which should be OK. Perl
> > version on Windows 2003 Server is 5.806. Here are some of my
> > observations:
> >
> > 1. Scripts are running OK from the command prompt on the server, and
> > the Perl installation looks OK. I've been through the more classical
> > Perl for win32 pitfalls checks.
> >
> > 2. Client browser returns this message:
> > ---
> > 1.1 200 OK Server: FirstClass/7.1 Content-type: text/html Don't know
> > how to run /cgi-bin/example.pl
> > ---
> > (Example.pl is a simple "Hello World" demo which runs OK from the
> > prompt -- and normally on any web server with CGI-capabillity.)
> >
> > 3. Compiled CGI scripts, e.g. EXE-files, runs OK on the server.
> >
> > 4. Checked out the system PATH environment variable, and it points at
> > C:\Perl\bin like it should.
> >
> > 5. Web server service is set up with the Local System user account,
> > and should have the proper access rights.
> >
> > 6. I've installed an Apache test server in order to rule out the
> > possibility that the problem somehow could be related to my FirstClass
> > Server setup. The symptoms were almost identical, allthough Apache
> > returned an not specified "Internal Server Error" message. Compiled
> > CGI ran OK on Apache as well.
> >
> > In other words, there must be something in the Windows 2003 Server
> > setup that I've missed? It seems like FirstClass Server can't find the
> > Perl interpreter, even though the system PATH is OK. I've been through
> > loads of FAQs and documentation, but haven't come across a solution so
> > far. So I'll appreciate a helping hand on this.
> >
> > Regards,
> > Hallvard Østrem
>
> I would suspect that the ".pl" file extension is not set system-wide, or you
> possibly need to define a "handler" (Apache term) for .pl files.
>
> Kevin
------------------------------
Date: Fri, 11 Jun 2004 12:14:43 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Perl cgi on Windows 2003 Server fails
Message-Id: <cac7nj$dgi$2@wisteria.csv.warwick.ac.uk>
Quoth hallvardost@hotmail.com (Hallvard ?strem):
>
> spamtotrash@toomuchfiction.com (Kevin Collins) wrote in message news:<slrnccecmb.f8v.spamtotrash@doom.unix-guy.com>...
> > In article <79b0e251.0406090128.2536cc08@posting.google.com>, Hallvard ?strem
> > wrote:
> > > My well tested Perl CGI scripts will not run on my web server after
> > > moving it from Windows NT 4.0 to a brand new Windows 2003 Server.
> >
> > I would suspect that the ".pl" file extension is not set system-wide, or you
> > possibly need to define a "handler" (Apache term) for .pl files.
>
> Thanks for your help, Kevin. The problem persists even if the server
> application runs as the current user, that is a user who can execute
> perl scripts from the DOS prompt.
>
> FirstClass CGI setup is quite simple and doesn't require any
> configuration other than the cgi-bin folder being installed in the
> appropriate folder on the file system. The script should execute as
> long as it finds the file in the cgi-bin path, and it does if it is
> e.g. a precompiled script.
>
> Since my server setup worked just fine on Windows NT, I'm quite sure
> my problem must be related to Perl/Windows 2003 Server somehow. Since
> Perl works fine from the prompt, I also believe it to be more likely
> related to the Windows 2003 Server setup, but how is still a mystery
> to me. I'm out of ideas...
What happens if you create a file script.pl and double-click on it? Does
it run with perl, or not? You haven't yet indicated that it does.
Ben
--
If I were a butterfly I'd live for a day, / I would be free, just blowing away.
This cruel country has driven me down / Teased me and lied, teased me and lied.
I've only sad stories to tell to this town: / My dreams have withered and died.
ben@morrow.me.uk (Kate Rusby)
------------------------------
Date: Fri, 11 Jun 2004 12:04:28 GMT
From: moller@notvalid.se
Subject: Re: perl IF DBI::errsrt
Message-Id: <841xkms3lg.fsf@notvalid.se>
Xaver Biton <javier@t-online.de> writes:
> Hi,
>
> I'writing a program which will be used to migrate a mysql DB to
> another mysql DB.
>
> Because the data quantity is relative big, if an arror occur while
> inserting a record in the new db I would like to deviate this record
> error table.
>
> How ban achive that.
> If someone could make a little example I would be grathefull.
Not an answer to your question but..
In cases like this it's *almost* *always* better to use
the tools provided by the database.
From webpage:
"The mysqldump client can be used to dump a database or a collection of
databases for backup or for transferring the data to another SQL server
(not necessarily a MySQL server). The dump will contain SQL statements
to create the table and/or populate the table. "
Start reading here if interested.
http://dev.mysql.com/doc/mysql/en/mysqldump.html
------------------------------
Date: Fri, 11 Jun 2004 09:03:47 -0400
From: Paul Lalli <ittyspam@yahoo.com>
Subject: Re: Regular expressions
Message-Id: <20040611090124.T8971@dishwasher.cs.rpi.edu>
On Fri, 11 Jun 2004, kapil_kaushik wrote:
> in perl, to search for a ' we use \' but then i cannot
> understand, what the following code searches for.
> /^\s*\'0'\s*$/
> Here the 1st ' is preceded by a \ meaning it is a normal '
> but the 2nd ' puts me in confusion
> I am new to this language
> Kindly help
From what source did you get that information? Whoever told you that is
wrong. The following are the only characters that need to be escaped with
a backslash in a regular expression:
\ | ( ) [ { ^ $ * + ? .
Note that you must add to this list whatever character you use as your
delimiter, and also the @ character if whatever follows it could be an
array name.
Paul Lalli
P.S. I do seriously want to know where that info came from, so we know to
avoid it in the future. Thank you.
------------------------------
Date: Fri, 11 Jun 2004 11:23:29 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: SOAP::Lite using HTTPS as a transport?
Message-Id: <cac4nh$b2c$1@wisteria.csv.warwick.ac.uk>
Quoth josh.kuo@prioritynetworks.net (josh):
> According to http://cookbook.soaplite.com/, it should be as easy as
> this:
>
> my ( $soap ) = SOAP::Lite
> -> uri('Demo')
> # -> proxy('http://localhost/cgi-bin/soap.cgi')
> -> proxy('https://localhost/cgi-bin/soap.cgi')
>
> But this is the error I get:
>
> 500 Can't locate object method "new" via package
> "LWP::Protocol::https::Socket" at ./client.pl line 8
>
> I am running Mandrake 10.0 Community, with all default RPMs (urpmi
> perl-SOAP-Lite).
>
> My goal is to have secure (preferrably SSL) communication between the
> SOAP server and client(s). Is there a better way than HTTPS? I just
> thought HTTPS makes a natural choice since I already got HTTP working.
What version of LWP do you have? I have 5.76, and that has an
LWP::Protocol::https::Socket class with a new method.
Try
perl -MLWP -le'print $LWP::VERSION'
and
perl -MLWP::Protocol::https -le'print
LWP::Protocol::https::Socket->can("new")'
. If the first prints something less than 5.76 and the second prints
nothing then upgrade LWP. If the second prints CODE(0xXXXXXXXX) then
your problem is elsewhere.
Ben
--
If you put all the prophets, | You'd have so much more reason
Mystics and saints | Than ever was born
In one room together, | Out of all of the conflicts of time.
ben@morrow.me.uk The Levellers, 'Believers'
------------------------------
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 6680
***************************************