[15677] in Perl-Users-Digest
Perl-Users Digest, Issue: 3090 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu May 18 14:27:17 2000
Date: Thu, 18 May 2000 11:15:24 -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: <958673724-v9-i3090@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Thu, 18 May 2000 Volume: 9 Number: 3090
Today's topics:
simple newbie question <admin@alphacomp.ch>
split a list of number equally <donby@synopsys.com>
Re: split a list of number equally <aqumsieh@hyperchip.com>
Re: split a list of number equally <blah@nospam.com>
Re: Split with a space (-*-)
Re: suid problem under Solaris 2.7 <rootbeer@redcat.com>
test <john.xu@fingerhut.com>
Re: Threads and Perl for Win32 <dan@tuatha.sidhe.org>
Re: tricky scalar? Assigning to.. AKUT nobull@mail.com
Re: tricky scalar? Assigning to.. AKUT <webmaster@ostas.lu.se>
Re: Use/Require Difference <scott@salmon.ltd.uk>
Re: Use/Require Difference <aqumsieh@hyperchip.com>
Re: Use/Require Difference <jhelman@wsb.com>
Re: Use/Require Difference <scott@salmon.ltd.uk>
Re: What book on perl-cgi for a perl-programmer? (Elliot Finley)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 18 May 2000 18:32:53 +0200
From: Andre =?iso-8859-1?Q?B=E4ttig?= <admin@alphacomp.ch>
Subject: simple newbie question
Message-Id: <39241B35.60B6C1DD@alphacomp.ch>
Hi
I just started to learn Perl with a book. As far all code examples were
ok when running in a DOS box.
But now to print out to the browser nothing is happening with this 2
files.
test.pl:
#!d:/prog/perl/bin/perl.exe
read(STDIN, $Daten, $ENV{'CONTENT_TYPE'});
print "Content-type: text/html\n\n";
print "<html><head><title>CGI-Reaktion</title></head>\n";
print "<body><h1>Reaktion des CGI-Programmes</h1>\n";
print $ENV{'CONTENT_TYPE'};
print "</body></html>\n";
test.html:
<html>
<head>
<title>Testsite</title>
</head>
<body>
<h1>Testformular</h1>
<form action="/cgi-bin/test.pl" method=post>
Name: <input size=40 maxlength=40 name="UserName"> <br>
Text: <textarea rows=5 cols=70 name="Comment"
wrap=virtual></textarea><p>
<input type=submit value="Send">
</form>
</body>
</html>
Who likes to help?
Thanks Andre
------------------------------
Date: Thu, 18 May 2000 09:36:29 -0700
From: Don Byington <donby@synopsys.com>
Subject: split a list of number equally
Message-Id: <39241C0D.C25A2EF5@synopsys.com>
Does anyone have any Perl 5 code for spliltting a list of numbers into
two or more lists, where the new lists have a sum that is as close as
possible?
Thanks,
Don
donby@synopsys.com
------------------------------
Date: Thu, 18 May 2000 16:45:22 GMT
From: Ala Qumsieh <aqumsieh@hyperchip.com>
Subject: Re: split a list of number equally
Message-Id: <7ag0rflsd8.fsf@Merlin.i-did-not-set--mail-host-address--so-shoot-me>
Don Byington <donby@synopsys.com> writes:
> Does anyone have any Perl 5 code for spliltting a list of numbers into
> two or more lists, where the new lists have a sum that is as close as
> possible?
I don't understand what you exactly mean.
Care to illustrate with an example?
--Ala
------------------------------
Date: Thu, 18 May 2000 18:50:37 +0200
From: Marco Natoni <blah@nospam.com>
Subject: Re: split a list of number equally
Message-Id: <39241F5D.7C424506@nospam.com>
Hi Don,
Don Byington wrote:
> Does anyone have any Perl 5 code for spliltting a list of numbers
> into two or more lists, where the new lists have a sum that is
> as close as possible?
Show us the algorithm, if you know it, and we will produce the code
for you. ;)
If you need the algorithm too, please wait until tomorrow: I am going
home, now... :)
Best regards,
Marco
------------------------------
Date: Thu, 18 May 2000 16:07:51 +0100
From: "Damian (-*-)" <damian@amorphous.co.uk>
Subject: Re: Split with a space
Message-Id: <CKTU4.21212$UC.270371@news2-hme0>
Yes you're right. I've just tested that myself here, and it does as you say.
Is the problem the call from Java applet, in that it contains spaces ? I'm
using a socket
to send the command :
GET
/cgi-bin/jeghitable.pl?../htdocs/testing/asteroids/asteroids.hi,15234,desc,f
red bloggs
I know this reaches the webserver (Apache / Active Perl) as I've checked the
Access
Log, and it lists the request, including the full name (space and all) e.g.
192.168.0.81 - - [18/May/2000:16:11:06 +0100] "GET
/cgi-bin/jeghitable.pl?../htdocs/testing/asteroids/asteroids.hi,15234,desc,f
red bloggs"
I tried sticking the part after the '?' in quotes but no luck (I thought the
problem may
be related to HTML pages when there is a space in the address line - I even
put a
'%20' in place of the space).
Does $ENV{QUERY_STRING} not return the full value ? i.e. does it drop the "
bloggs"
part ?
Damian (-*-)
Ala Qumsieh <aqumsieh@hyperchip.com> wrote in message
news:7a4s7vncvd.fsf@Merlin.i-did-not-set--mail-host-address--so-shoot-me...
|
| "Damian (-*-)" <damian@amorphous.co.uk> writes:
|
| > Hi There,
| >
| > I'm trying to split the environment variable but am having trouble when
the
| > data contains
| > spaces (This is a generic game score table script I am writing that is
| > called from a Java
| > applet)
| >
| > I'm using :
| >
| > ($hiScoresFile, $score, $sortMethod, $data) = split(',',
| > $ENV{QUERY_STRING});
| >
| > to crack the initially passed string of the form :
| >
| > "myscores.txt,1000,desc,fred"
| >
| > The problem is when $data contains a space. It is passed through to the
Perl
| > script
| > OK (I've check the access log file) but the split command seems to
reject
| > after the
| > first space. Not having had much experience (and not finding anything in
the
| > FAQ)
| > I was wondering if anyone new of a quick fix ? I just want to be able to
| > fire a string
| > like :
| >
| > "myscores.txt,1000,desc,fred bloggs"
| >
| > to the script and it save our "fred bloggs" as the name.
|
| What makes you say that it doesn't work?
|
| % perl -wl
| my $string = 'myscores.txt,1000,desc,fred bloggs';
| my ($w, $x, $y, $z) = split /,/, $string;
| print $z;
| __END__
| fred bloggs
|
| It works as you want it to. Perhaps your problem is elsewhere?
|
| --Ala
------------------------------
Date: Thu, 18 May 2000 10:01:12 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: suid problem under Solaris 2.7
Message-Id: <Pine.GSO.4.10.10005180958180.25459-100000@user2.teleport.com>
On Thu, 18 May 2000, Elaine Ashton wrote:
> Well..since he is running this on Solaris, technically he shouldn't
> need suid Perl since it is one of the systems that are theoretically
> 'secure'. I'm not sure what there is to gain by having both Perl and
> suidperl on such a system.
Well, you could do that to disable set-id scripting in Perl. :-) At
least, if I'm figuring everything right, that's what would happen. perl
starts up, sees that it's already set-id. But it shouldn't be set-id
unless sperl (suidperl) is handling things, on systems built that way. So,
it makes a big noise and dies.
> I don't remember if there is a FAQ for this but it might be useful for
> people in this sort of situation.
Good idea. I'll have to (finish) writing one. :-)
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Thu, 18 May 2000 17:41:52 GMT
From: "John Xu" <john.xu@fingerhut.com>
Subject: test
Message-Id: <AXVU4.200$731.14853@news7.onvoy.net>
------------------------------
Date: Thu, 18 May 2000 17:24:17 GMT
From: Dan Sugalski <dan@tuatha.sidhe.org>
Subject: Re: Threads and Perl for Win32
Message-Id: <5HVU4.87360$hT2.368585@news1.rdc1.ct.home.com>
Leonard Thornton <LeonardT@intelis-inc.com> wrote:
> Unfortunately, non-threaded is not an option. I am attempting to replace an
> existing script language (proprietary) with a Perl implementation in an
> existing application base. The replacement would be very straightforward if
> I can get around this threading snafu.
Perl in general is threadsafe if:
1) You build with MULTIPLICITY
2) You only have one thread in an interpreter or messing with an
interpreter's data structures (including SVs and such) at one time.
> I am in the process of rebuilding ActivePerl 522 from source and bypassing
> the CPerlObj implementation, as this appears to be where the threading
> problems are at, though I may be mistaken.
You may be, I'm not sure. You also might want to try building perl 5.6.0
from source instead, as I think you might see some speedup when building
with MULTIPLICITY. (I'm not 100% sure of that, but I think so) For what
you're doing, I'd say 5.6.0 is probably the better way to go.
Dan
------------------------------
Date: 18 May 2000 17:43:27 +0100
From: nobull@mail.com
Subject: Re: tricky scalar? Assigning to.. AKUT
Message-Id: <u9ln17lsgg.fsf@wcl-l.bham.ac.uk>
This Q is asked every week or - so anyone think it warrants a FAQ entry?
Jimmy Lantz <webmaster@ostas.lu.se> writes:
> Now I have scalars which has the same name in the incoming form values
> (%in) there for I need to assign the following scenario.:
> ${now2}name = $in{"${now2}name"}
Correct syntax is:
no strict 'vars';
${"${now2}name"} = $in{"${now2}name"}
However you do _not_ want to do this. It is bad, bad, bad.
You have the data in a hash - that is the best place for it.
For reasons see threads from the last few times this question was
asked.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Thu, 18 May 2000 19:23:55 +0200
From: Jimmy Lantz <webmaster@ostas.lu.se>
Subject: Re: tricky scalar? Assigning to.. AKUT
Message-Id: <3924272C.C36D583E@ostas.lu.se>
Problem solved,
Thank you guys.
//
Jimmy
nobull@mail.com wrote:
>
> This Q is asked every week or - so anyone think it warrants a FAQ entry?
>
> Jimmy Lantz <webmaster@ostas.lu.se> writes:
>
> > Now I have scalars which has the same name in the incoming form values
> > (%in) there for I need to assign the following scenario.:
> > ${now2}name = $in{"${now2}name"}
>
> Correct syntax is:
>
> no strict 'vars';
> ${"${now2}name"} = $in{"${now2}name"}
>
> However you do _not_ want to do this. It is bad, bad, bad.
>
> You have the data in a hash - that is the best place for it.
>
> For reasons see threads from the last few times this question was
> asked.
>
> --
> \\ ( )
> . _\\__[oo
> .__/ \\ /\@
> . l___\\
> # ll l\\
> ###LL LL\\
------------------------------
Date: Thu, 18 May 2000 16:18:08 +0100
From: "Scott Pritchett" <scott@salmon.ltd.uk>
Subject: Re: Use/Require Difference
Message-Id: <8g11jf$mft$1@lure.pipex.net>
I know this, but what difference does that make here?
Scott
"M.J.T. Guy" <mjtg@cus.cam.ac.uk> wrote in message
news:8g10mr$o5i$1@pegasus.csx.cam.ac.uk...
> In article <8g0dj7$9mo$1@lure.pipex.net>,
> Scott Pritchett <scott@salmon.ltd.uk> wrote:
> >I know this may be wrong but... I needed to have a way of inserting perl
> >code from a common file which was not a subroutine, so I have :-
> >
> > #!perl -w
> > use strict;
> > $::x=5;
> > use isb;
> > print "x is $::x\n";
> > exit;
> >
> >In isb :-
> >
> > $::x=4;
> > print "in isb x is $::x\n";
> >
> >This returns :-
> >
> > in isb x is 4
> > x is 5
> >
> >When I replace the 'use' with 'require' I get what I expected, namely :-
> > in isb x is 4
> > x is 4
> >
> >Why?!
>
> Because require happens at run time, use at compile time.
>
> perldoc -q require
> perldoc -f use
> perldoc -f require
>
>
> Mike Guy
------------------------------
Date: Thu, 18 May 2000 15:20:53 GMT
From: Ala Qumsieh <aqumsieh@hyperchip.com>
Subject: Re: Use/Require Difference
Message-Id: <7ar9azlwa1.fsf@Merlin.i-did-not-set--mail-host-address--so-shoot-me>
"Scott Pritchett" <scott@salmon.ltd.uk> writes:
> I know this may be wrong but... I needed to have a way of inserting perl
> code from a common file which was not a subroutine, so I have :-
>
> #!perl -w
> use strict;
> $::x=5;
> use isb;
> print "x is $::x\n";
> exit;
>
> In isb :-
>
> $::x=4;
> print "in isb x is $::x\n";
>
> This returns :-
>
> in isb x is 4
> x is 5
>
> When I replace the 'use' with 'require' I get what I expected, namely :-
> in isb x is 4
> x is 4
>
> Why?!
Because use() is a compile-time directive. So the code in a use()d
module will get executed at compile-time (before your script starts
actually running).
require(), on the other hand, is a run-time directive.
For more complete info, checkout perlfa8:
What's the difference between require and use?
--Ala
------------------------------
Date: Thu, 18 May 2000 15:22:22 GMT
From: Jeff Helman <jhelman@wsb.com>
Subject: Re: Use/Require Difference
Message-Id: <39240AD0.99C72B2C@wsb.com>
The reason that the first code block returns "x is 5" is that using
"use" imports a library at compile-time (before the rest of your code is
executed), whereas require pulls it in during runtime (if it hasn't been
pulled in already). Thus your code goes through the following steps:
## USING USE
1. Import strict.pm
2. Run any code in strict.pm
3. Import isb.pm
4. Run any code in isb
4a. Assign value of 4 to $::x
4b. Print ...
5. Assign value of 5 to $::x
6. Print ...
When you use require, the importing of isb and execution of any code in
it is done during runtime when the require statement is found. Thus,
your code goes through the following steps:
## USING REQUIRE
1. Import strict.pm
2. Run any code in strict.pm
3. Assign value of 5 to $::x
4. Import isb.pm
5. Run any code in isb
5a. Assign value of 4 to $::x
5b. Print ...
6. Print ...
I hope this helps. A better explanation is probably in the docs
somewhere... :)
JH
----------------------------------------------------------------
Jeff Helman Product Manager -- Internet Services
jhelman@wsb.com CCH Washington Service Bureau
----------------------------------------------------------------
Scott Pritchett wrote:
>
> I know this may be wrong but... I needed to have a way of inserting perl
> code from a common file which was not a subroutine, so I have :-
>
> #!perl -w
> use strict;
> $::x=5;
> use isb;
> print "x is $::x\n";
> exit;
>
> In isb :-
>
> $::x=4;
> print "in isb x is $::x\n";
>
> This returns :-
>
> in isb x is 4
> x is 5
>
> When I replace the 'use' with 'require' I get what I expected, namely :-
> in isb x is 4
> x is 4
>
> Why?!
------------------------------
Date: Thu, 18 May 2000 16:34:22 +0100
From: "Scott Pritchett" <scott@salmon.ltd.uk>
Subject: Re: Use/Require Difference
Message-Id: <8g1376$nhl$1@lure.pipex.net>
Oh my!
Just tried :-
#!perl -w
use strict;
$::x=5;
print "starting\n";
use isb;
print "x is $::x\n";
exit;
In isb :-
$::x=4;
print "in isb x is $::x\n";
This as you say must "execute" isb at compile time, I thought it was only
resolved at compile time. The print from isb happens before the "starting"
message! So "require" is the answer. BUT, can you explain what actually
happens with code like this at compile time? Can you use it to intialise
variables to set values, are there cleverer things that can be done?
Scott
------------------------------
Date: Thu, 18 May 2000 15:58:14 GMT
From: efinley@efinley.com (Elliot Finley)
Subject: Re: What book on perl-cgi for a perl-programmer?
Message-Id: <392512f5.146459181@news.firstworld.net>
On 18 May 2000 07:23:48 -0700, merlyn@stonehenge.com (Randal L.
Schwartz) wrote:
>>>>>> "Koos" == Koos Schut <schut@rugth1.phys.rug.nl> writes:
>
>Koos> So can anyone suggest some book/reference/www-site
>Koos> which might be very useful for me?
>
>I can give you my rules for selecting a Perl CGI book, and then you
>can be your own judge at the store. Off the top of my head:
>
>REJECT any book that processes the parameters without any library
>support (like mentions $ENV{QUERY_STRING}), except as an example of
>what not to do, or as an interim on the way to using CGI.pm.
>
>REJECT any book that mentions cgi-lib.pl with anything other than disdain.
>
>REJECT any book that doesn't use CGI.pm by at least the second
>chapter.
>
>REJECT any book that doesn't mention the function-call interface for
>CGI.pm (allowing you to use param("foo") instead of $q->param("foo")).
>
>REJECT any book that says "these examples will work under Perl4 or
>Perl5".
>
>(In fact, REJECT any book that calls it "Perl5" rather than "Perl". :)
>
>REJECT any book that does client-side HTTP without using LWP,
>especially if it starts with "use Socket;" (or worse, "require
>'sys/socket.ph';").
>
>REJECT any book that claims to strip HTML with s/<!--.*--!>//g.
>
>REJECT any book that doesn't talk about taint mode.
>
>REJECT any book that uses Berkeley mail (open MAIL, "|mail $user") to
>send mail. (Security holes abound there.)
>
>REJECT any book that attempts to match an email address with a
>simple-minded regular expression like /^\w+\@(\w+\.)+\w+$/. (See the
>FAQ about what a legal email address looks like.)
>
>Most books won't pass this test. That leaves darn few books. If it
>makes it past those, you probably have a reasonably modern book with a
>reasonably clued-in author.
Are there any books that actually make it past all those restrictions?
--
Elliot (efinley@efinley.com) Weird Science!
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
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 V9 Issue 3090
**************************************