[17608] in Perl-Users-Digest
Perl-Users Digest, Issue: 5028 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Dec 4 18:07:44 2000
Date: Mon, 4 Dec 2000 15:05:18 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <975971117-v9-i5028@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Mon, 4 Dec 2000 Volume: 9 Number: 5028
Today's topics:
Re: "use strict" vs my & local (Abigail)
Re: "use strict" vs my & local (Abigail)
'require' without 'use lib' jack.dunnigan@ec.gc.ca
Re: 'require' without 'use lib' dtbaker_dejanews@my-deja.com
Re: 'require' without 'use lib' <dyoung@NetToNetTech.com>
[OT] Re: Perl Illiterate <joe+usenet@sunstarsys.com>
A locking question, please (Stan Brown)
Re: array of unique random numbers (Abigail)
Re: array of unique random numbers (Abigail)
Re: array of unique random numbers <joe+usenet@sunstarsys.com>
Re: array of unique random numbers <joe+usenet@sunstarsys.com>
Re: array of unique random numbers (Abigail)
Re: array of unique random numbers (Abigail)
Re: array of unique random numbers <joe+usenet@sunstarsys.com>
Re: basics... <jboes@eoexchange.com>
Re: calling perl script in html? <iowa8_song8.remove_eights@hotmail.com>
Can anybody give me any suggestion <irynam@3web.net>
Re: Can this script be done in a one-liner (Abigail)
Re: CGI newbie - premature end of script headers??? jmg2@my-deja.com
Re: CGI newbie - premature end of script headers??? <hillr@ugsolutions.com>
Re: changing file permissions with a perl command (not (Abigail)
Re: Cookie dates (Abigail)
Re: Does map return a list or an array? (Abigail)
dynamic lvalues possible? ber1@my-deja.com
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 4 Dec 2000 19:26:37 GMT
From: abigail@foad.org (Abigail)
Subject: Re: "use strict" vs my & local
Message-Id: <slrn92nrvd.vnu.abigail@tsathoggua.rlyeh.net>
On 2 Dec 2000 15:43:13 -0500, Stan Brown (stanb@panix.com) wrote in comp.lang.perl.misc <URL: news:<90bmt1$hq6$1@panix3.panix.com>>:
++ I am trying to do the equivelant of a C "static" variable definition.
++
++ That is I want to have a structure (turns out to be a hash oof hashes,
++ if it matters) that is visible in a subsrotuine, and retains it's
++ values acros calls. I would prefer not to have to decalre it in main,
++ and pas it back & forth from the subroutine, since it's state data of
++ interest only to that subroutine, But it needs to retain the value as I
++ basicly using the subroutine to cache database results.
++
++ I am curently uising "use strict", and this seems to interfere with
++ even declaring the structure as "local" in main, and having it visible
++ in the subbroutine, which, if I read the doc's corectly should be one
++ way of doing this.
Use a closure.
{my $static;
sub static_is_visible_here {
....
....
}
}
Just be careful that the program flow doesn't run through the block
unexpectedly, or else your $static will be undefined.
Abigail
------------------------------
Date: 4 Dec 2000 19:28:34 GMT
From: abigail@foad.org (Abigail)
Subject: Re: "use strict" vs my & local
Message-Id: <slrn92ns32.vnu.abigail@tsathoggua.rlyeh.net>
On Sat, 02 Dec 2000 21:30:59 GMT, Andrew Johnson (andrew-johnson@home.com) wrote in comp.lang.perl.misc <URL: news:<nSdW5.30679$Z9.1480015@news1.rdc1.mb.home.com>>:
++ In article <90bmt1$hq6$1@panix3.panix.com>,
++ Stan Brown <stanb@panix.com> wrote:
++ > I am trying to do the equivelant of a C "static" variable definition.
++ >
++ > That is I want to have a structure (turns out to be a hash oof hashes,
++ > if it matters) that is visible in a subsrotuine, and retains it's
++ > values acros calls. I would prefer not to have to decalre it in main,
++ > and pas it back & forth from the subroutine, since it's state data of
++ > interest only to that subroutine, But it needs to retain the value as I
++ > basicly using the subroutine to cache database results.
++
++ Create a lexical block and define your private (lexical) variable
++ and your subroutine within that block, and afterwards only that sub
++ can access that variable:
++
++ #!/usr/bin/perl -w
++ use strict;
++
++ {
++ my $static = 41;
++
++ sub foo {
++ print "$static\n";
++ $static++;
++ }
++
++ }
++
++ foo();
++ foo();
++ __END__
++
++ You need to put the block before any code that refers to the
++ subroutine, or use a BEGIN block to ensure the block is compiled
++ early.
Well, the code will be compiled before it's run, so that's not a problem.
The only danger is when *running* the code, not when compiling it; when
the program flows through the block, the static variable is initialized.
Abigail
------------------------------
Date: Mon, 04 Dec 2000 20:01:03 GMT
From: jack.dunnigan@ec.gc.ca
Subject: 'require' without 'use lib'
Message-Id: <90gt5q$gfq$1@nnrp1.deja.com>
Is there anyway to 'require' a plain perl syntax file (i.e. not a *.pm)
without changing @INC? Or alternatively, "un"use the lib after the file
has been found and ingested?
Currently I have something like:
use lib '/some/wierd/directory';
require "Some.config";
But now @INC contains /some/weird/directory..which is no longer
needed. (i.e. AFTER the config file get required)
Jack
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Mon, 04 Dec 2000 20:14:04 GMT
From: dtbaker_dejanews@my-deja.com
Subject: Re: 'require' without 'use lib'
Message-Id: <90gtu5$ha4$1@nnrp1.deja.com>
In article <90gt5q$gfq$1@nnrp1.deja.com>,
jack.dunnigan@ec.gc.ca wrote:
> Is there anyway to 'require' a plain perl syntax file (i.e. not a
*.pm)
> without changing @INC? Or alternatively, "un"use the lib after the
file
> has been found and ingested?
>
> Currently I have something like:
>
> use lib '/some/wierd/directory';
> require "Some.config";
>
--------------------
yes, just put the entire path in the require statement like:
require "./some/weird/dir/config.pl" ;
there really is no need to worry about releasing the memory... unless it
is some HUGE file it shouldnt be a problem.
D
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Mon, 04 Dec 2000 17:52:27 -0500
From: David Young <dyoung@NetToNetTech.com>
Subject: Re: 'require' without 'use lib'
Message-Id: <B6518A5B.38B6%dyoung@NetToNetTech.com>
Ummm, how about:
require "/some/wierd/directory/Some.config";
> From: jack.dunnigan@ec.gc.ca
> Organization: Deja.com - Before you buy.
> Newsgroups: comp.lang.perl.misc
> Date: Mon, 04 Dec 2000 20:01:03 GMT
> Subject: 'require' without 'use lib'
>
> Is there anyway to 'require' a plain perl syntax file (i.e. not a *.pm)
> without changing @INC? Or alternatively, "un"use the lib after the file
> has been found and ingested?
>
> Currently I have something like:
>
> use lib '/some/wierd/directory';
> require "Some.config";
>
> But now @INC contains /some/weird/directory..which is no longer
> needed. (i.e. AFTER the config file get required)
>
> Jack
>
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
------------------------------
Date: 04 Dec 2000 14:14:49 -0500
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: [OT] Re: Perl Illiterate
Message-Id: <m31yvoov6e.fsf_-_@mumonkan.sunstarsys.com>
David Hiskiyahu <David.Hiskiyahu@alcatel.be> writes:
> There are many interpretations of Perl, the following came to my mind:
>
> - Pascal Experiences Record Low,
> - Pain, Envy, Revenge, Love,
> - Practical Enormously Rich Language,
> - Play & Enjoy this Rubbish Lister,
> - Pinguins Expect Romance & Love
> - Pathologically Eclectic Rubbish Lister,
> - Poorly Educated Romantic Lover,
> - Playing Environment for Rubbish Lovers,
> - ...
>
>
> anyone wants to continue the list?
>
- PERL Encourages Recursive Loathing
--
Joe Schaefer
------------------------------
Date: 4 Dec 2000 14:36:55 -0500
From: stanb@panix.com (Stan Brown)
Subject: A locking question, please
Message-Id: <90gron$6hc$1@panix3.panix.com>
I am writing a small application that will consist of 2 co-operating perl
tasks.
Task A will obtain data, and write it to a file. Task B will then need to
take this data out of the file for further processing. The file will
consists of a series of records, one per line.
My plan is to have task A lock the file, write to it, then unlock it. Task
B will lock the file, copy the data that;s there, and truncate the fiel to
zero lenght, then unlock it.
My problem is with the locking mechanism. I looked at CPAm module
File::lockf, and it appears to offer the exact functioanlity the I need.
But I have been unable to seem to get the syntax of thiw working just
right.
I was able to get locking to work using File::Flock; (which to me appears
to have a mich simpler interface). However I need for task A to be able to
time out on failure to obtain the lock, so that it can continue to aquire
and buffer data.
Could some kind soul please give me an example of using File::lockf?
I am alos open to sugestions as to alternate methods of doing this.
The OS is HP-UX 10.20, if that matters.
Thanks.
------------------------------
Date: 4 Dec 2000 19:50:23 GMT
From: abigail@foad.org (Abigail)
Subject: Re: array of unique random numbers
Message-Id: <slrn92ntbv.vnu.abigail@tsathoggua.rlyeh.net>
On Fri, 01 Dec 2000 23:54:17 +0000, Dela Lovecraft (dela@nospam.ukonline.co.uk) wrote in comp.lang.perl.misc <URL: news:<3UWV5.5092$0z.83030@news2-win.server.ntlworld.com>>:
++ Dear All,
++
++ I need to produce an array of random numbers, but each of them needs
++ to be unique ie. if I have an array of 50 values, none can be replicated.
++
++ As far as I can see, the way to do this would be:
++ * set an array of n members
++ * put a random number in slot 1
++ * create another random number, and check to see that it doesn't appear
++ in any of the preceeding elements - if it does, create a different number
++ until it does
++ * repeat the above set until all n are filled.
++
++
++ Is this the only way to do it? If someone has a better idea, could you give
++ perl pointers to show how it would be done?
If you have a large set of numbers to choose from, for instance, the
reals between 0 and 1:
while (keys %hash < 50) {$hash {+rand} = 1}
@array = keys %hash;
If you have a relatively small set to choose from, just shuffle the set,
and take the first 50.
Abigail
------------------------------
Date: 4 Dec 2000 19:58:09 GMT
From: abigail@foad.org (Abigail)
Subject: Re: array of unique random numbers
Message-Id: <slrn92ntqh.vnu.abigail@tsathoggua.rlyeh.net>
On 4 Dec 2000 11:17:24 GMT, Ilmari Karonen (iltzu@sci.invalid) wrote in comp.lang.perl.misc <URL: news:<975927708.8746@itz.pp.sci.fi>>:
++ In article <3A299BBB.11CF43C6@ipartner.net>, Scott Wiersdorf wrote:
++ >
++ >my %random_numbers = ();
++ >while( scalar keys %random_numbers < 50 ) {
++ > my $rnd = rand();
++ > $random_numbers{$rnd}++;
++ >}
++
++ The only problem with that solution is that its running time is
++ theoretically unbounded. In practice that won't be an issue if you're
++ only picking 50 numbers out of a large set, but it will be if you,
++ say, want the numbers to be positive integers below 100.
++
++ I was going to recommend using either your solution or the Fisher-
++ Yates shuffle presented in another reply depending on the situation,
++ but then I realized that it's possible to combine Fisher-Yates and
++ hashes to obtain a better solution than either of them alone:
++
++ sub unique_random_ints {
++ my ($n, $lim) = @_;
++ my (@res, %buf);
++ while (@res < $n) {
++ my $rn = int rand $lim--;
++ push @res, $buf{$rn} || $rn;
++ $buf{$rn} = $buf{$lim} || $lim;
++ }
++ return @res;
++ }
++
++ There. Both the running time and the memory usage are proportional to
++ $n even in the worst case, and completely independent of $lim.
++
++ Should this be in the FAQ? Can anyone suggest improvements?
This works quite well, but depends heavily on the fact integers are a
countable set. How would you do it with reals, with strings, or with
a selector that isn't uniform?
Abigail
------------------------------
Date: 04 Dec 2000 15:00:25 -0500
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: array of unique random numbers
Message-Id: <m3vgt0nehy.fsf@mumonkan.sunstarsys.com>
abigail@foad.org (Abigail) writes:
> If you have a large set of numbers to choose from, for instance, the
> reals between 0 and 1:
>
> while (keys %hash < 50) {$hash {+rand} = 1}
> @array = keys %hash;
I think you left out
shuffle(@array);
keys %hash is curiously ordered list of random elements, and not a
(random) list of random elements.
--
Joe Schaefer
------------------------------
Date: 04 Dec 2000 15:38:12 -0500
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: array of unique random numbers
Message-Id: <m3elznorbf.fsf@mumonkan.sunstarsys.com>
abigail@foad.org (Abigail) writes:
> This works quite well, but depends heavily on the fact integers are a
> countable set. How would you do it with reals, with strings, or with
> a selector that isn't uniform?
for rand output, << 32 should take work (they ain't reals :).
There are two problems with obtaining an array of unique random
elements:
1) somehow obtaining a list of unique elements from a sample space (S)
that has some notion randomness attached to it.
2) ensuring the returned list is random (technically the sample space
is now S^n where n is the number of elts in the list.)
Depending on the size of the sample space vs the number of
elements needed, one of these is usually easier than the other.
Without these details known in advanced, it's doubtful that
some universal code will cover all cases well.
--
Joe Schaefer
------------------------------
Date: 4 Dec 2000 21:16:00 GMT
From: abigail@foad.org (Abigail)
Subject: Re: array of unique random numbers
Message-Id: <slrn92o2cg.vnu.abigail@tsathoggua.rlyeh.net>
On 04 Dec 2000 15:00:25 -0500, Joe Schaefer (joe+usenet@sunstarsys.com) wrote in comp.lang.perl.misc <URL: news:<m3vgt0nehy.fsf@mumonkan.sunstarsys.com>>:
++ abigail@foad.org (Abigail) writes:
++
++ > If you have a large set of numbers to choose from, for instance, the
++ > reals between 0 and 1:
++ >
++ > while (keys %hash < 50) {$hash {+rand} = 1}
++ > @array = keys %hash;
++
++ I think you left out
++
++ shuffle(@array);
++
++ keys %hash is curiously ordered list of random elements, and not a
++ (random) list of random elements.
And since the OP asked for an array of random numbers without duplicates
what's wrong with keys %hash?
Abigail
------------------------------
Date: 4 Dec 2000 21:26:25 GMT
From: abigail@foad.org (Abigail)
Subject: Re: array of unique random numbers
Message-Id: <slrn92o301.vnu.abigail@tsathoggua.rlyeh.net>
On 04 Dec 2000 15:38:12 -0500, Joe Schaefer (joe+usenet@sunstarsys.com) wrote in comp.lang.perl.misc <URL: news:<m3elznorbf.fsf@mumonkan.sunstarsys.com>>:
++ abigail@foad.org (Abigail) writes:
++
++ > This works quite well, but depends heavily on the fact integers are a
++ > countable set. How would you do it with reals, with strings, or with
++ > a selector that isn't uniform?
++
++ for rand output, << 32 should take work (they ain't reals :).
That ties you down the the underlaying rand() function of the C library,
while assuming it has something to do with 32 bits. You wouldn't be
able to swap in a different random generator; for instance one that
returns 128 bit floating point numbers, or one with an unbounded number
of decimals.
You asked whether your algorithm could be improved. It certainly can:
by making it less dependent of the characteristics of the random function.
(You can't make it totally independent; for instance, it's impossible to
get 50 unique numbers if numbers are sampled from a 40 member set)
Abigail
------------------------------
Date: 04 Dec 2000 16:41:29 -0500
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: array of unique random numbers
Message-Id: <m3aeaboody.fsf@mumonkan.sunstarsys.com>
abigail@foad.org (Abigail) writes:
> ++ I wrote:
> ++ > If you have a large set of numbers to choose from, for instance, the
> ++ > reals between 0 and 1:
> ++ >
> ++ > while (keys %hash < 50) {$hash {+rand} = 1}
> ++ > @array = keys %hash;
> ++
> ++ I think you left out
> ++
> ++ shuffle(@array);
> ++
> ++ keys %hash is curiously ordered list of random elements, and not a
> ++ (random) list of random elements.
>
>
> And since the OP asked for an array of random numbers without duplicates
> what's wrong with keys %hash?
>
It's an ordered list. The order depends on the elements in the list,
which means if you're using the elements of keys %hash sequentially,
more info is available than simply "the next element won't be amongst
the previous ones". Ordering reduces the randomness of the numbers
in the remainder of the list, just as if you had done
@array = sort keys %hash;
Since OP didn't ask for an ordered list of random numbers, I
assumed that s/he needed an unordered list.
I guess it untimately depends on what OP actually needed, but since
s/he liked my original answer, I assumed that ordered lists would
be bad.
--
Joe Schaefer
------------------------------
Date: Mon, 04 Dec 2000 15:42:30 -0500
From: "Jeff Boes" <jboes@eoexchange.com>
Subject: Re: basics...
Message-Id: <3a2c0379$0$35010$44a10c7e@news.net-link.net>
Unless my newsreader has been taken over by the Illuminati, I think "silas
horsley" <sbh@hydsys.com> babbled:
> I'm just beginning on the CGI/Perl road... In the world of perl5, can I
> get away with just using CGI.pm to do basic form manipulation? Thanks,
Absolutely. I'd start by picking up Lincoln Stein's excellent book,
"Official Guide to CGI.pm". It has excellent tutorials. Be warned that
the book is some distance behind the evolution of the module, and you
should check its release notes if you are trying to do anything complex.
--
Jeff Boes <jboes@eoexchange.com> Tel: (616) 381-9889 x.18
Sr. Software Engineer, EoExchange, Inc. http://www.eoexchange.com/
Search, Monitor, Notify. http://www.eomonitor.com/
------------------------------
Date: Mon, 04 Dec 2000 21:32:07 GMT
From: Weston Cann <iowa8_song8.remove_eights@hotmail.com>
Subject: Re: calling perl script in html?
Message-Id: <021220001428063864%iowa8_song8.remove_eights@hotmail.com>
> >: On Thu, 30 Nov 2000 01:53:50 GMT, joshbaxley <joshb@isomedia.com>
> >: wrote:
> >:
> >: >I have a perl script that simply takes a list of files in a directory
> >: >and lists them in html with links to them.
> >: >
> >: >Now if I did this in ASP and not perl and I wanted to call it in an HTML
> >: >page, I would simply type:
> >: >
> >: ><!-- #LOCATION File:page.asp -->
> >: >
> >: >now how do I do this with perl?
You may want to check out embeded perl -- allows you to embed perl
directly in html.
http://perl.apache.org/#embed
I like it.
> >:
> >: If you want the perl script to run automatically without user
> >: clicking, AND your ISP does not allow server side includes <-! Exec
> Well, that was certainly helpful!!! If you know of a better
> way to do it on ISP that do not allow SSI then enlighten us.
Unfortunately, there's no real way to do any kind of embeding in an HTML
page unless your ISP supports it, whether it's SSI, ASP, PHP, or
embedded PERL. All embeded directives are processed by the server, and
so the server has to be configured to do the job. So it's either go
with what your ISP supports, or find a new ISP (or go with a
non-embedded solution, such as CGI or Java applets).
------------------------------
Date: Mon, 04 Dec 2000 15:31:13 -0800
From: iryna martynenko <irynam@3web.net>
Subject: Can anybody give me any suggestion
Message-Id: <3A2C2940.67F5F662@3web.net>
--------------CC0A0182D8F3A343093C2FAF
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit
Hi everybody.
Can anybody give me any suggestion how to change the values in the hash
to a different language
%states=(
'CA'=>'California',
'MT'=>'Montana',
'NM'=>'New Mexico',
);
the associative array works, but if I change the values to Russian or
any language except English
like
%states=(
'CA'=>'Калифорния',
'MT'=>'Монтана',
'NM'=>'Нью Мексика',
);
the same hash gives message that there is a mistake in the hash
assignment.
I will appreciate any suggestions how to solve this problem.
Sincerely,
Iryna
--------------CC0A0182D8F3A343093C2FAF
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<font size=-1>Hi everybody.</font>
<br><font size=-1>Can anybody give me any suggestion how to change the
values in the hash to a different language</font><font size=-1></font>
<p><font size=-1>%states=(</font>
<br><font size=-1> 'CA'=>'California',</font>
<br><font size=-1> 'MT'=>'Montana',</font>
<br><font size=-1> 'NM'=>'New Mexico',</font>
<br><font size=-1>);</font><font size=-1></font>
<p><font size=-1>the associative array works, but if I change the values
to Russian or any language except English</font>
<br><font size=-1>like</font>
<br><font size=-1> %states=(</font>
<br><font size=-1> 'CA'=>'Êàëèôîðíèÿ',</font>
<br><font size=-1> 'MT'=>'Ìîíòàíà',</font>
<br><font size=-1> 'NM'=>'Íüþ
Ìåêñèêà',</font>
<br><font size=-1>);</font>
<br><font size=-1> </font>
<br><font size=-1>the same hash gives message that there is a mistake in
the hash assignment.</font>
<br><font size=-1>I will appreciate any suggestions how to solve this problem.</font>
<br><font size=-1></font> <font size=-1></font>
<p><font size=-1>Sincerely,</font><font size=-1></font>
<p><font size=-1>Iryna</font>
<br><font size=-1></font>
<br><font size=-1></font>
<br><font size=-1></font> </html>
--------------CC0A0182D8F3A343093C2FAF--
------------------------------
Date: 4 Dec 2000 19:17:40 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Can this script be done in a one-liner
Message-Id: <slrn92nrek.vnu.abigail@tsathoggua.rlyeh.net>
On Fri, 01 Dec 2000 22:22:57 GMT, Derek Ross (dross@iders.ca) wrote in comp.lang.perl.misc <URL: news:<3A28242C.6598@iders.ca>>:
++ Hello,
++
++ Is it possible for this script to be compressed down into a one-liner?
Trivially.
++
++ All it does is read in two lists of integers from the files a.txt and
++ b.txt, and prints out the sum of each pair.
++
++ -----------------------
++
++ open(A, "a.txt");
++ open(B, "b.txt");
++
++ while(!eof(A))
++ {
++ $a = <A>;
++ $b = <B>;
++
++ print $a + $b . "\n";
++ }
open(A,"a.txt");open(B,"b.txt");while(!eof(A)){$a=<A>;$b=<B>;print$a+$b."\n"}
Or:
perl -ple 'BEGIN {open B, "b.txt" or die} $_ += <B>' a.txt
Abigail
------------------------------
Date: Mon, 04 Dec 2000 20:35:11 GMT
From: jmg2@my-deja.com
Subject: Re: CGI newbie - premature end of script headers???
Message-Id: <90gv5v$ifi$1@nnrp1.deja.com>
I'm having the same problem. I've checked the error logs and the only
thing I get is "Premature end of script headers". Other Perl scripts
work fine through the browser. 'perl -c <scriptname>' works fine also.
I can even execute 'perl <scriptname> > test.html', which results
in a html file. Open this file in a browser and it works fine.
Any clue as to where my problem might lie?
Thanks in advance,
James
In article <56io0t4icsipv21p59dpqmeucpulgvira7@4ax.com>,
Stephen S. <smart73_NOSPAM!!_@earthlink.net> wrote:
> Did you ever figure this problem out?? I have the same problem and no
> one's been able to help much. I think it's some configuration problem
> but haven't had any luck with that. Everybody says look at the error
> logs. That's where I got this error. People say I uploaded the
> script in binary instead. I wrote the script on the linux server
> there was no uploading involved.
>
> On Fri, 3 Nov 2000 23:08:22 +0100, "Tomas" <it_likes_you@yahoo.com>
> wrote:
>
> >Hi,
> >
> >I'm don't do well in CGI. I'm trying to make a form-to-mail cgi, but
I just
> >grabbed it from several tutorials. The script looks fine, but when I
run it
> >on a webserver, it says "Premature end of script headers"
> >
> >Also, I've read that you can print HTML easier when you use "print
> ><<EndOfHTML" so that you don't have to use the print statement
everytime.
> >But is the "EndOfHTML" part neccesary or can you use other thing
such as
> ><<errorpage? And can you use EndOfHTML more than once in a script?
> >
> >Thanks for reading this,
> >
> >You can reply to this or email directly to nofunatall@tiscalinet.be
> >
>
>
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Mon, 04 Dec 2000 13:06:02 -0800
From: Ron Hill <hillr@ugsolutions.com>
Subject: Re: CGI newbie - premature end of script headers???
Message-Id: <3A2C073A.823E16B4@ugsolutions.com>
jmg2@my-deja.com wrote:
> I'm having the same problem. I've checked the error logs and the only
> thing I get is "Premature end of script headers". Other Perl scripts
> work fine through the browser. 'perl -c <scriptname>' works fine also.
> I can even execute 'perl <scriptname> > test.html', which results
> in a html file. Open this file in a browser and it works fine.
> Any clue as to where my problem might lie?
>
> Thanks in advance,
> James
From the Idiot's Guide to CGI in Perl
Q: Did you remember to flush STDOUT at the top of your script so the MIME
type gets out before any errors?
A: Nope - gosh, no wonder it doesn't get out before it bombs! I guess I
better
add this to the top:
$| = 1
http://www.webdeveloper.com/cgi-perl/cgi_idiots_guide_to_perl.html
------------------------------
Date: 4 Dec 2000 20:38:15 GMT
From: abigail@foad.org (Abigail)
Subject: Re: changing file permissions with a perl command (not from unix promt!)
Message-Id: <slrn92o05n.vnu.abigail@tsathoggua.rlyeh.net>
On Mon, 04 Dec 2000 18:25:45 -0000, Chris Stith (mischief@velma.motion.net) wrote in comp.lang.perl.misc <URL: news:<t2nod9fbemeefe@corp.supernews.com>>:
++
++ I'd be happy to write code for you that automatically changes
++ everything that's uploaded to file mode 777, as long as you
++ give me access to upload it to the server. LOL. Maybe in the
++ /etc directory and the /bin directory?
++
++ Why the hell would you want to make anything uploaded 777?
++ That means that anyone who can upload can run arbitrary code.
That's of course not true. If you can only upload, for instance because
you have an ftponly account, you can only upload. Not execute.
And once they have a shell, well, they can execute what they want anyway.
Abigail
------------------------------
Date: 4 Dec 2000 20:47:26 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Cookie dates
Message-Id: <slrn92o0mu.vnu.abigail@tsathoggua.rlyeh.net>
On Sun, 3 Dec 2000 16:42:29 +0000 (UTC), David Efflandt (efflandt@xnet.com) wrote in comp.lang.perl.misc <URL: news:<slrn92ktv9.nl7.efflandt@efflandt.xnet.com>>:
++ On Sun, 3 Dec 2000 16:13:35 -0000, Tony Bronze <ttiger@lineone.net> wrote:
++ >Some scripts that I am using only allow the year to be input as 2 digits.
++ >If I use 01 when setting a cookie expiry, will that be intepreted as 1901 or
++ >2001 or should I use 101 for 2001?
++
++ I would be suspect of any such scripts that are not y2k compliant. What
++ other mistakes (or security flaws) might they have?
I would be suspect of any person who thinks that use of 2 digits to
denote a year assumes it has a "y2k" problem.
Oddly enough, if you asked the question a year ago, noone would wonder
whether inputting 99 would mean 1899 or 1999.
There was no web in 1901. There were no digital cookies in 1901. Why on
earth should you even assume setting a cookie with a date in 1901 would
make any sense?
Of course, the programmer can have made a mistake, but you can't deduce
that from the fact two digits are used. After all, 4 digit years have
the same problems.
Abigail
------------------------------
Date: 4 Dec 2000 19:09:27 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Does map return a list or an array?
Message-Id: <slrn92nqv7.vnu.abigail@tsathoggua.rlyeh.net>
On Sat, 2 Dec 2000 13:40:12 +0800, John Lin (johnlin@chttl.com.tw) wrote in comp.lang.perl.misc <URL: news:<90a24o$mlh@netnews.hinet.net>>:
++ Dear all,
++
++ Today my collegue asked me "Does map return a list or an array?".
++ Before I answered, I carefully read the manual.
++ Hmm... the answer is "a list". I shouted out loudly "It returns a list."
++ "Are you sure?" Then he gave me a quiz. "Guess what the outputs are."
++
++ sub list { 'A','B','C' }
++ print scalar list;
++
++ sub array { my @a = ('A','B','C') }
++ print scalar array;
++
++ sub quess { map {$_} 'A','B','C' }
++ print scalar quess;
++
++ Hmm... The first function returns a list. So the answer is 'C'.
++ The second function returns an array. So the answer is 3.
++ The third returns a list (according to the document) so the answer is 'C'.
Wrong. All functions are called in scalar context, hence all functions
return a scalar.
Function never ever return arrays. Depending on their context, they return
nothing, a scalar, or a list.
++ "Buzz... You are wrong... "
++ After seeing the answer, I think Perl is a little bit too complicated to
++ learn.
++ Do you get the correct answer?
Well, the first one evaluates a list in scalar context, hence it returns
the last element of the list, being "C". The second one evaluates an array
in scalar context, hence it returns the number of elements in the array,
being 3. The last one evaluates map in scalar context. What the value
of that is, is explained in the second sentence of the description of
map in the documentation. You will see that that will match the outcome
of your code experiment.
Abigail
------------------------------
Date: Mon, 04 Dec 2000 22:41:46 GMT
From: ber1@my-deja.com
Subject: dynamic lvalues possible?
Message-Id: <90h6j9$ovb$1@nnrp1.deja.com>
I am trying to create default variables to use when generating an html
form from a previouse instance of the same form. Using the CGI module
I am able to read in the previous query with no problem. What I think
describes what I want to do is...
my (@names) = $query->param;
for $value (@names)
{
my ($next) = "\$${value}_default = $query->param('$value')";
eval ($next);
print "next is $next\n";
print "software_message_default is
$software_message_default\n\n";
}
# so if I know I have a value 'software_message",
# I can make the variable $software_message_default and put
something
# in it on the fly.
#maybe I should just hardcode it.
Thanks for your time,
Bryan
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
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 5028
**************************************