[9326] in Perl-Users-Digest
Perl-Users Digest, Issue: 2921 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Jun 20 15:22:18 1998
Date: Sat, 20 Jun 98 12:00:25 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Sat, 20 Jun 1998 Volume: 8 Number: 2921
Today's topics:
Re: ?CGI scripts & Explorer (Larry Rosler)
Re: [Q] On WAKING a sleeping process... (Mark-Jason Dominus)
Re: Apache 90 TimeOut (Michael Fuhr)
Re: Apache 90 TimeOut <merlyn@stonehenge.com>
Re: Can't open SDBM file from CGI <bowlin@sirius.com>
IO::Socket::INET and the connection that wont close andrew@ugh.net.au
mkdir in PERL <benread@usa.net>
Re: mkdir in PERL (Larry Rosler)
Re: mkdir in PERL (Bob Trieger)
Re: mkdir in PERL (Earl Hood)
Parsing...... <bandahr@the-neighborhood.com>
Re: Problem with space in front of each line of text. (Bob Trieger)
Question(s) about lexically scoped variables under 'use <steph@hotkey.net.au>
Re: Question(s) about lexically scoped variables under (Larry Rosler)
Re: Random Numbers andrew@ugh.net.au
Re: Random Numbers dgris@rand.dimensional.com
Re: removing multiples from an array (Gabor)
Re: removing multiples from an array <bowlin@sirius.com>
Sending file with Perl Script (Mark Thompson)
Re: Sending file with Perl Script (Larry Rosler)
Re: Sending file with Perl Script (Mark Thompson)
Re: Sending file with Perl Script <bowlin@sirius.com>
Re: Sending file with Perl Script (Larry Rosler)
Re: Sending file with Perl Script (Mark Thompson)
Re: SORTING HASHES (THE NEWBIE WAY!!) <steph@hotkey.net.au>
Working With Hash <luckys@geocities.com>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 20 Jun 1998 08:23:26 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: ?CGI scripts & Explorer
Message-Id: <MPG.ff573cdcb5f35a09896d6@nntp.hpl.hp.com>
In article <358ec232.114427838@nntp.ix.netcom.com>, Michael Rubenstein
<miker3@ix.netcom.com> says...
> On Sat, 20 Jun 1998 00:56:59 GMT, root.noharvest.\@not_even\here.com
> (-) wrote:
>
> >lr@hpl.hp.com (Larry Rosler) Said this:
> >
> >>In article <358952ED.6CD8CB72@inlink.com>, perlguy@inlink.com says...
> >>> Actually there was NOTHING wrong with MY script that I was referring
> >>> to. I DID contact Microsoft and their response was:
> >>>
> >>> "We have no interest in fixing it because it is in an old version of the
> >>> browser." (Version 3.02 & 3.03)
> >
> >This is so sad. A company that is so much more interested in revenues
> >than it is in keeping their current customers happy. I mean,
> >especially coming from a company that is quick to proclaim their
> >benevolant concern for the customer and all that marketing blah blah.
> >They aren't interested in supporting the one browser that they've
> >published that actually has a significant market share, that's utterly
> >ridiculous. Just take a look at how Novell does business. They are
...
>
> It certainly is sad. Imagine, a company not fixing an old version.
> They probably think that since the new version is free, one should
> upgrade.
>
> By the way, where can I get a fix for a bug in Perl 4? Or do you
> expect me to upgrade to a newer version?
> --
> Michael M Rubenstein
I can't find the cited article on my newsreader, and
root.noharvest.\@not_even\here.com seems like a strange address. I did
not write the words apparently attributed to me. This is what I *did*
write:
<quote>
I also papered over a bug in MSIE 3, because I couldn't insist they [the
users of my code] upgrade to MSIE 4. Essentially our CGI code has to be
tested on a variety of clients (as well as, in my case, hosts -- HPUX and
NT), which is a great pain.
</quote>
But your hilarious swipe at those in this newsgroup who rely on Frequent
Answer "upgrade your perl" has relieved some of the pain. ROTFLOL.
--
Larry Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 20 Jun 1998 11:38:28 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: [Q] On WAKING a sleeping process...
Message-Id: <6mgl1k$q17$1@monet.op.net>
Keywords: evocable leaflet logging tip
Andrew Johnson wrote to me with a nice suggestion. He suggested that
you could make a FIFO, and then instead of sleep, you'd do a `select'
on the FIFO. The process would awaken at the end of the `select'
timeout, or else you could wake it up by writing to the FIFO.
Something like this:
system("mknod $THE_FIFO");
open F, $THE_FIFO or die ...;
...
for (;;) {
$wake_up = time + $sleep_time;
while (time < $wake_up) {
my $nap_time = $wake_up - time;
my $rc = select (1<<fileno(F)), undef, undef, $nap_time;
if ($rc) {
my $command;
read F, $command, 1;
exit if $command eq 'q'; # Abort process
last if $command eq 'r'; # Premature refresh
# Other commands if desired
}
}
do_something_interesting();
}
If you design the control flow correctly, you can also force the
program to do_someting_interesting when you send it a signal, since
this will interrupt the `select' call. This version doesn't do that;
to get it to wake up, you do
echo -n r >> THE_FIFO
------------------------------
Date: Sat, 20 Jun 1998 15:15:09 GMT
From: mfuhr@dimensional.com (Michael Fuhr)
Subject: Re: Apache 90 TimeOut
Message-Id: <6mgjlo$c3n@flatland.dimensional.com>
[ Followups set to comp.infosystems.www.servers.unix ]
Edward Harris <EdHarris@eg-web.com> writes:
> Apache will not allow a perl script to process for more than 90 seconds
> without a request. On second 91 it stops the scripts processing and
> sends the browser an "Internal Server Error" message.
This really belongs in comp.infosystems.www.servers.*; I've set
followups accordingly.
> Does anyone know any code or way to trick Apache into allowing a script
> to process for more than 90 seconds?
Apache has a timeout directive but the default is 300 seconds -- what's
yours set to? Did the error log provide any more information? What
version of Apache is this?
--
Michael Fuhr
http://www.dimensional.com/~mfuhr/
------------------------------
Date: Sat, 20 Jun 1998 16:02:39 GMT
From: Randal Schwartz <merlyn@stonehenge.com>
Subject: Re: Apache 90 TimeOut
Message-Id: <8cemwk9i3w.fsf@gadget.cscaper.com>
>>>>> "Edward" == Edward Harris <EdHarris@eg-web.com> writes:
Edward> Apache will not allow a perl script to process for more than
Edward> 90 seconds without a request. On second 91 it stops the
Edward> scripts processing and sends the browser an "Internal Server
Edward> Error" message.
Edward> Does anyone know any code or way to trick Apache into allowing
Edward> a script to process for more than 90 seconds?
This is not a comp.lang.perl.misc question. Much more a
comp.infosystems.www.{authoring.cgi,.server.misc} question.
However, since I'm already posting to razz on you, I'll give you useful
information as well. :-)
One of my recent Perl columns in WebTechniques magazine gave a
technique of having a "search in progress"... where an initial page
would come up that says "I'm working on it", and then you'd reload the
page until the answer showed up. (That's automated with client-pull,
for those browsers that support it.) Perhaps that would help you
figure out what to do.
Through a gracious arrangement with the publisher, my past columns are
on-line at http://www.stonehenge.com/merlyn/WebTechniques/. Look for
the one that says "search in progress" in the index.
print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,990.69 collected, $186,159.85 spent; just 72 more days
## before I go to *prison* for 90 days; email fund@stonehenge.com for details
--
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me
------------------------------
Date: Sat, 20 Jun 1998 09:24:43 -0700
From: Jim Bowlin <bowlin@sirius.com>
To: Mark Witwer <mark@witwerswebworks.com>
Subject: Re: Can't open SDBM file from CGI
Message-Id: <358BE24B.D8D2A28F@sirius.com>
Mark Witwer wrote:
>
> I haven't been able to get my CGI script to open my SDBM file that I
> have on my NT server. It is a SDBM file that already exists because I
> originally populated it by running it from the command line. In fact,
> if I run the Perl script that attempts to open the same SDBM file from
> the command line, it reports no problems. Every time I execute by
> submitting from a form, the browser always reports back my 'die' message
> for opening the file. I tried some code I found from a Perl Win32 FAQ
> that was on the Perl Language Home page, but that didn't help either.
> Anybody got an answer?
>
> Mark Witwer
If your "die" message included $! then you would have had your answer
already. Always always always include $! in message returned by die
after checking a systems call.
My guess is that it is a permission problem.
-- Jim Bowlin
------------------------------
Date: Sun, 21 Jun 1998 02:00:20 +1000
From: andrew@ugh.net.au
Subject: IO::Socket::INET and the connection that wont close
Message-Id: <Pine.BSF.3.96.980621015531.21699J-100000@house.key.net.au>
Hi,
I have a IO::Socket::INET object that used to be a TCP connection. From
the debugger I type:
DB<17> $TCPHandle->close
DB<18> x $TCPHandle
0 IO::Socket::INET=GLOB(0x39e3b4)
-> *Symbol::GEN1
DB<19> if ($TCPHandle->opened) { print "yup" }
DB<20> system('netstat -f inet')
Active Internet connections
Proto Recv-Q Send-Q Local Address Foreign Address (state)
tcp 35 0 203.24.170.211.2239 202.12.219.107.rfe ESTABLISHED
<snip>
Hmm...why isnt my connection closed? This is from the child of a forked
process...could the problem be that the parent still has the handle open?
Thanks,
Andrew
------------------------------
Date: 20 Jun 1998 16:46:56 GMT
From: "Ben Read" <benread@usa.net>
Subject: mkdir in PERL
Message-Id: <01bd9c6a$ff356e00$0200005a@playroom>
Help! I'm writing a script that automatically generates a new directory
when the script is run. The only problem is that I'm not sure how to
create directory. The script runs in the www.mydomain.com/cgi-bin
directory but I need it to create a directory in the
www.mydomain.com/accounts directory. I can't figure it out! I've tried
using these methods, but can't get any of them to work:
system "cd ..", "cd accounts", "mkdir $newdirectory";
system ("cd..";"cd accounts";"mkdir $newdirectory");
`cd..;cdaccounts;mkdir $newdirectory`;
Any suggestions or ideas? All help much appreciated!
Thanks! -Ben Read
------------------------------
Date: Sat, 20 Jun 1998 10:30:21 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: mkdir in PERL
Message-Id: <MPG.ff5918b9314f3a19896d9@nntp.hpl.hp.com>
In article <01bd9c6a$ff356e00$0200005a@playroom>, Ben Read
<benread@usa.net> says...
> Help! I'm writing a script that automatically generates a new directory
> when the script is run. The only problem is that I'm not sure how to
> create directory. The script runs in the www.mydomain.com/cgi-bin
> directory but I need it to create a directory in the
> www.mydomain.com/accounts directory. I can't figure it out! I've tried
> using these methods, but can't get any of them to work:
>
> system "cd ..", "cd accounts", "mkdir $newdirectory";
> system ("cd..";"cd accounts";"mkdir $newdirectory");
> `cd..;cdaccounts;mkdir $newdirectory`;
>
> Any suggestions or ideas? All help much appreciated!
Don't use system() or ``; use the Perl function mkdir.
perldoc -f mkdir
Then you can use chdir() if you want to be in the new directory.
--
Larry Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Sat, 20 Jun 1998 17:37:21 GMT
From: sowmaster@juicepigs.com (Bob Trieger)
Subject: Re: mkdir in PERL
Message-Id: <6mgs40$tqt$2@ligarius.ultra.net>
[ posted and mailed ]
"Ben Read" <benread@usa.net> wrote:
-> Help! I'm writing a script that automatically generates a new directory
-> when the script is run. The only problem is that I'm not sure how to
-> create directory. The script runs in the www.mydomain.com/cgi-bin
-> directory but I need it to create a directory in the
-> www.mydomain.com/accounts directory. I can't figure it out! I've tried
-> using these methods, but can't get any of them to work:
->
-> system "cd ..", "cd accounts", "mkdir $newdirectory";
-> system ("cd..";"cd accounts";"mkdir $newdirectory");
-> `cd..;cdaccounts;mkdir $newdirectory`;
perldoc -f mkdir
HTH
Bob Trieger
sowmaster@juicepigs.com
" Cost a spammer some cash: Call 1-800-239-0341
and hang up when the recording starts. "
------------------------------
Date: 20 Jun 1998 17:39:40 GMT
From: ehood@medusa.acs.uci.edu (Earl Hood)
Subject: Re: mkdir in PERL
Message-Id: <6mgs4s$363@news.service.uci.edu>
[mailed & posted]
In article <01bd9c6a$ff356e00$0200005a@playroom>,
Ben Read <benread@usa.net> wrote:
> system "cd ..", "cd accounts", "mkdir $newdirectory";
> system ("cd..";"cd accounts";"mkdir $newdirectory");
> `cd..;cdaccounts;mkdir $newdirectory`;
Why not use the built-in chdir and mkdir functions that are part
of Perl? Also, URL paths do not necessarily match the actual
file paths on the server's filesystem. Also, make sure file
permissions are set appropriately.
--ewh
--
Earl Hood | University of California: Irvine
ehood@medusa.acs.uci.edu | Electronic Loiterer
http://www.oac.uci.edu/indiv/ehood/ | Dabbler of SGML/WWW/Perl/MIME
------------------------------
Date: Sat, 20 Jun 1998 14:10:07 -0400
From: "Brad Jones" <bandahr@the-neighborhood.com>
Subject: Parsing......
Message-Id: <383F077F9AD3A9D5.3C752EDDC7486F8D.821B16182FD53A77@library-proxy.airnews.net>
I know this is probably not the best place to post this and i apologize in
advance, but I am trying to install some cgi perl scripts. We are using
Linux Redhat and Apache, when I pull up the page in a browser it gives the
text not the program, how do I fix this? I can't for the life of me
remember....
TIA,
Brad
------------------------------
Date: Sat, 20 Jun 1998 17:26:21 GMT
From: sowmaster@juicepigs.com (Bob Trieger)
Subject: Re: Problem with space in front of each line of text.
Message-Id: <6mgrfc$tqt$1@ligarius.ultra.net>
[ posted and mailed ]
Leon Stepanian <info@purco.qc.ca> wrote:
->
-> --------------CAE9B9EDEBFC4746E6AB1911
-> Content-Type: text/plain; charset=us-ascii
-> Content-Transfer-Encoding: 7bit
Please, please, do not do this. UseNet is a text medium, no need for Miming.
-> # start of file
-> This is a first line.
->
-> This is a third line.
->
-> This is a fifth line.
->
-> print "<TEXTAREA COLS=70 ROWS=20
-> name=\"c_text\">@holdfile</TEXTAREA>\n";
->
-> I think the problem has to do with trailing line but I can't get this
-> resolved after two days of tinkering. After 200k of scripting this Perl
-> progam, this one problem has me blocked.
There are probably 40 solutions to your problem. The one I use is to put the
elements of an array into a variable.
map { $holdfile .= $_ } @holdfile;
print qq!<TEXTAREA COLS=70 ROWS=20 name="c_text">$holdfile</TEXTAREA>\n!;
As a side note. Check out the perlfunc documentation on q, qq ,qw & qx.
Backwhack as little as possible, it can get confusing to the author and anyone
that has to deal with the source.
HTH
Bob Trieger
sowmaster@juicepigs.com
" Cost a spammer some cash: Call 1-800-239-0341
and hang up when the recording starts. "
------------------------------
Date: Sun, 21 Jun 1998 03:19:04 +1000
From: Stephan Carydakis <steph@hotkey.net.au>
Subject: Question(s) about lexically scoped variables under 'use strict'
Message-Id: <358BEF08.6CCE@hotkey.net.au>
Hello All,
As I am new to Perl, I've been writting scripts(mostly for CGI) without
the pragma 'use strict'. Many people have recommended to always use
strict and I have decide to never again write scripts without it(and
-w).
So, I have begun writting my first script under use strict. I have only
a few lines of code, infact just 1 sub, which parses input, pretty
standard.
Every variable in this sub(and the whole script!) produces an error,
"global symbol '%s' requires explicit package name" which I have read up
on. It seems that I have to either qualify every variable with an
explicit package name, or declare every variable with 'my'.
Is there something I'm missing here?. Can I gather that under strict
that all variables need to be either predeclared with my, or qualified
with a package name? This seems a bit 'odd'(for want of a better word)
to me?
Could someone elaborate on this?
_______________________________________________________________
Stephan Carydakis steph@hotkey.net.au
P.S. just a tit-bit. 'pragma' is a greek word meaning 'thing'
_______________________________________________________________
------------------------------
Date: Sat, 20 Jun 1998 10:39:13 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Question(s) about lexically scoped variables under 'use strict'
Message-Id: <MPG.ff5939830436cc29896da@nntp.hpl.hp.com>
In article <358BEF08.6CCE@hotkey.net.au>, Stephan Carydakis
<steph@hotkey.net.au> says...
...
> Is there something I'm missing here?. Can I gather that under strict
> that all variables need to be either predeclared with my, or qualified
> with a package name? This seems a bit 'odd'(for want of a better word)
> to me?
>
> Could someone elaborate on this?
Look at:
use vars qw( $scalar @array %hash ... );
--
Larry Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Sun, 21 Jun 1998 03:59:14 +1000
From: andrew@ugh.net.au
To: Martin <minich@globalnet.co.uk>
Subject: Re: Random Numbers
Message-Id: <Pine.BSF.3.96.980621035310.21699L-100000@house.key.net.au>
On Sat, 20 Jun 1998, Martin wrote:
> Can anyone PLEASE help? I want to be able to choose a random number between
> 1 and 10 but don't know how to do it in Perl. I thought about using the $^T
Try rand(9) + 1. You will need to use srand first.
> to get the least significant number of a number. In BASIC, you could use:
>
> a$ = right$(test$,1)
Try something like:
$a = substr($test,length($test) -1,1);
Andrew
------------------------------
Date: Sat, 20 Jun 1998 18:49:05 GMT
From: dgris@rand.dimensional.com
Subject: Re: Random Numbers
Message-Id: <6mgvig$6f8$1@rand.dimensional.com>
[posted and mailed to the cited author]
In article <Pine.BSF.3.96.980621035310.21699L-100000@house.key.net.au>,
<andrew@ugh.net.au> wrote:
>Try rand(9) + 1. You will need to use srand first.
>
To be clear, if you are using a version of perl < 5.004 you need
to call srand first. Quoting from the perlfunc entry for srand-
In fact, it's usually not necessary to call srand() at all,
because if it is not called explicitly, it is called implicitly
at the first use of the rand operator. However, this was not the
case in version of Perl before 5.004, so if your script will run
under older Perl versions, it should call srand().
>Andrew
>
Regards,
Daniel
--
Daniel Grisinger dgris@perrin.dimensional.com
"No kings, no presidents, just a rough consensus and
running code."
Dave Clark
------------------------------
Date: 20 Jun 1998 17:16:42 GMT
From: gabor@vmunix.com (Gabor)
Subject: Re: removing multiples from an array
Message-Id: <slrn6onrlq.3bv.gabor@localhost.vmunix.com>
In comp.lang.perl.misc, Eugene Sotirescu <eugene@vertical.net> wrote :
# How would I go about removing multiples from an array?
# For ex, if the array elements are 123.html 345.html 567.html 123.html
# 678.html 123.html 678.html
# then after removal it should be
# 123.html 345.html 567.html 678.html
#
# Thanks.
assume you have your data in array @foo;
@foo = qw(123.html 345.html 567.html 123.html);
@foo{@foo} = (1) x @foo;
now the hash %foo contains just the unique elements from @foo
------------------------------
Date: Sat, 20 Jun 1998 11:06:48 -0700
From: Jim Bowlin <bowlin@sirius.com>
To: Gabor <gabor@vmunix.com>
Subject: Re: removing multiples from an array
Message-Id: <358BFA38.9F163873@sirius.com>
Gabor wrote:
>
> In comp.lang.perl.misc, Eugene Sotirescu <eugene@vertical.net> wrote :
> # How would I go about removing multiples from an array?
> # For ex, if the array elements are 123.html 345.html 567.html 123.html
> # 678.html 123.html 678.html
> # then after removal it should be
> # 123.html 345.html 567.html 678.html
> #
> # Thanks.
>
> assume you have your data in array @foo;
> @foo = qw(123.html 345.html 567.html 123.html);
> @foo{@foo} = (1) x @foo;
> now the hash %foo contains just the unique elements from @foo
Way way cool! -Jim Bowlin
------------------------------
Date: Sat, 20 Jun 1998 15:18:39 GMT
From: mark-lists@webstylists.com (Mark Thompson)
Subject: Sending file with Perl Script
Message-Id: <358bd2c2.1167344@news.alt.net>
Hi,
I have a file that I want to send users but only if they fill out a form
first. Basically, since there's disclaimers about the program that we need
to make sure that they read, we need it set up so that they can't just follow
a link to get the file directly.
My guess is that the best way would be to have the form processing software
return the file as output if the form is filled out correctly but I don't
really know how to do this.
Any thoughts or resources that someone could point me to?
Thanks,
Mark
------------------------------
Date: Sat, 20 Jun 1998 08:40:30 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Sending file with Perl Script
Message-Id: <MPG.ff577c651e769be9896d7@nntp.hpl.hp.com>
In article <358bd2c2.1167344@news.alt.net>, Mark Thompson <mark-
lists@webstylists.com> says...
> Hi,
>
> I have a file that I want to send users but only if they fill out a form
> first. Basically, since there's disclaimers about the program that we need
> to make sure that they read, we need it set up so that they can't just follow
> a link to get the file directly.
>
> My guess is that the best way would be to have the form processing software
> return the file as output if the form is filled out correctly but I don't
> really know how to do this.
That's pretty basic. All you have to do is print (to STDOUT) the header:
print "Content-Type: text/plain\n\n";
(note the *two* new-lines). Anything you print (to STDOUT) thereafter
will be displayed as plain text by the client browser. You can copy an
existing file, or create and print the data "on the fly."
HTH
--
Larry Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Sat, 20 Jun 1998 16:40:19 GMT
From: mark-lists@webstylists.com (Mark Thompson)
Subject: Re: Sending file with Perl Script
Message-Id: <358ce40e.5596560@news.alt.net>
On Sat, 20 Jun 1998 08:40:30 -0700, lr@hpl.hp.com (Larry Rosler) wrote:
>In article <358bd2c2.1167344@news.alt.net>, Mark Thompson <mark-
>lists@webstylists.com> says...
>> Hi,
>>
>> I have a file that I want to send users but only if they fill out a form
>> first. Basically, since there's disclaimers about the program that we need
>> to make sure that they read, we need it set up so that they can't just follow
>> a link to get the file directly.
>>
>> My guess is that the best way would be to have the form processing software
>> return the file as output if the form is filled out correctly but I don't
>> really know how to do this.
>
>That's pretty basic. All you have to do is print (to STDOUT) the header:
>
>print "Content-Type: text/plain\n\n";
>
>(note the *two* new-lines). Anything you print (to STDOUT) thereafter
>will be displayed as plain text by the client browser. You can copy an
>existing file, or create and print the data "on the fly."
Thanks, that worked for me but it brought up another question :)
How do I control the filename that is used in the Save As dialog?
The file is a BinHex (Macintosh compressed) format file and having a filename
of formprocessor.pl doesn't really help the person know what to do with the
file they've just downloaded. I don't really want to have 100 different cgi
scripts called file1.hqx, file2.hqx . . . file100.hqx though I do know that I
could do it that way if needed.
Thanks again,
Mark
------------------------------
Date: Sat, 20 Jun 1998 09:55:47 -0700
From: Jim Bowlin <bowlin@sirius.com>
To: Mark Thompson <mark-lists@webstylists.com>
Subject: Re: Sending file with Perl Script
Message-Id: <358BE993.97FFBD18@sirius.com>
Mark Thompson wrote:
>
> On Sat, 20 Jun 1998 08:40:30 -0700, lr@hpl.hp.com (Larry Rosler) wrote:
>
> >In article <358bd2c2.1167344@news.alt.net>, Mark Thompson <mark-
> >lists@webstylists.com> says...
> >> Hi,
> >>
> >> I have a file that I want to send users but only if they fill out a form
> >> first. Basically, since there's disclaimers about the program that we need
> >> to make sure that they read, we need it set up so that they can't just follow
> >> a link to get the file directly.
> >>
> >> My guess is that the best way would be to have the form processing software
> >> return the file as output if the form is filled out correctly but I don't
> >> really know how to do this.
> >
> >That's pretty basic. All you have to do is print (to STDOUT) the header:
> >
> >print "Content-Type: text/plain\n\n";
> >
> >(note the *two* new-lines). Anything you print (to STDOUT) thereafter
> >will be displayed as plain text by the client browser. You can copy an
> >existing file, or create and print the data "on the fly."
>
> Thanks, that worked for me but it brought up another question :)
>
> How do I control the filename that is used in the Save As dialog?
> The file is a BinHex (Macintosh compressed) format file and having a filename
> of formprocessor.pl doesn't really help the person know what to do with the
> file they've just downloaded. I don't really want to have 100 different cgi
> scripts called file1.hqx, file2.hqx . . . file100.hqx though I do know that I
> could do it that way if needed.
>
> Thanks again,
>
> Mark
You could try to add what is called "path info" in the URL
that calls your program. Example:
Current URL: http://host/cgi-bin/prog.pl
New URL: http://host/cgi-bin/prog.pl/sneakyfile.name
HTH -- Jim Bowlin
------------------------------
Date: Sat, 20 Jun 1998 10:24:20 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Sending file with Perl Script
Message-Id: <MPG.ff59022ad7514c59896d8@nntp.hpl.hp.com>
In article <358ce40e.5596560@news.alt.net>, Mark Thompson <mark-
lists@webstylists.com> says...
...
> How do I control the filename that is used in the Save As dialog?
> The file is a BinHex (Macintosh compressed) format file and having a filename
> of formprocessor.pl doesn't really help the person know what to do with the
> file they've just downloaded. I don't really want to have 100 different cgi
> scripts called file1.hqx, file2.hqx . . . file100.hqx though I do know that I
> could do it that way if needed.
Getting further off-topic; consult with CGI folks. My thoughts: You
can't 'control the filename' in any case -- all you can do is suggest.
One way of suggesting is by resending your script with a unique PATH_INFO
field:
print "Location: http://.../$ENV{SCRIPT_NAME}/pathname\n\n";
Consult with CGI folks.
--
Larry Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Sat, 20 Jun 1998 17:32:50 GMT
From: mark-lists@webstylists.com (Mark Thompson)
Subject: Re: Sending file with Perl Script
Message-Id: <358df078.8774514@news.alt.net>
Cute, Thanks! I didn't even think of that (I was looking for a directive of
some sort like the mimetype one but a "Filename: myfile.hqx" or something
like that). No need for the program to even care what the information is as
long as it's there.
I just wish I wasn't forced to do something sneaky like this to get what I
want done but I guess I have to if there's no direct provision for doing
this.
Thanks again!
Mark
On Sat, 20 Jun 1998 09:55:47 -0700, Jim Bowlin <bowlin@sirius.com> wrote:
>> Thanks, that worked for me but it brought up another question :)
>>
>> How do I control the filename that is used in the Save As dialog?
>> The file is a BinHex (Macintosh compressed) format file and having a filename
>> of formprocessor.pl doesn't really help the person know what to do with the
>> file they've just downloaded. I don't really want to have 100 different cgi
>> scripts called file1.hqx, file2.hqx . . . file100.hqx though I do know that I
>> could do it that way if needed.
>>
>> Thanks again,
>>
>> Mark
>
>You could try to add what is called "path info" in the URL
>that calls your program. Example:
>
>Current URL: http://host/cgi-bin/prog.pl
>New URL: http://host/cgi-bin/prog.pl/sneakyfile.name
------------------------------
Date: Sun, 21 Jun 1998 02:59:11 +1000
From: Stephan Carydakis <steph@hotkey.net.au>
Subject: Re: SORTING HASHES (THE NEWBIE WAY!!)
Message-Id: <358BEA5F.4283@hotkey.net.au>
Larry Rosler wrote:
>
> In article <358981A5.7206@hotkey.net.au>, Stephan Carydakis
> <steph@hotkey.net.au>says...
> ...
> The keys get plugged into $a and $b; the sort compares the values
> $ta_sort{$a} and $ta_sort($b}, and returns the keys as a list sorted by
> these values. I hope you understand now. (This is only about the second
> level of non-trivial sort. There are many higher degrees of difficulty.)
Thanks Larry. I actually looked at it and worked this out already. :]
It seems perfectly logical to me now.
Thanks for your time anyways. I do appreciate it.
Stephan Carydakis steph@hotkey.net.au
------------------------------
Date: Sat, 20 Jun 1998 13:26:15 -0400
From: Luckys <luckys@geocities.com>
Subject: Working With Hash
Message-Id: <358BF0B6.2A33@geocities.com>
I'm working with hash in reference with a DBM file and have been able to
successfuly read and write associative arrays to it. I can't, however,
edit already existing arrays within it (edit the value portion of it).
Everytime I try to edit the value portion of the pair it adds a new pair
to the DBM file. Is there a way to edit the value of the already
existing pair without having to delete or undef it? If not, what would
be the best method of removing both the key and value for an already
defined pair?
------------------------------
Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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.misc (and this Digest), send your
article to perl-users@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.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
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 V8 Issue 2921
**************************************