[17298] in Perl-Users-Digest
Perl-Users Digest, Issue: 4720 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Oct 25 09:10:28 2000
Date: Wed, 25 Oct 2000 06:10:13 -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: <972479412-v9-i4720@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Wed, 25 Oct 2000 Volume: 9 Number: 4720
Today's topics:
Re: Length of a string stored in a scalar <lr@hpl.hp.com>
Re: local binmode? pingu2@my-deja.com
Re: local binmode? <bart.lateur@skynet.be>
Re: loop through all symbol table entries <rfoskett@my-deja.com>
Re: Make me a hot or not script (Gwyn Judd)
Re: memory allocation and my <james@NOSPAM.demon.co.uk>
Re: memory allocation and my nobull@mail.com
Re: memory allocation and my (Gwyn Judd)
Re: memory allocation and my <mauldin@netstorm.net>
Re: OT: Jihad definition <bart.lateur@skynet.be>
Perl - SSI - IE contra Netscape <J.Wenzel-Ketel@t-online.de>
Re: Perl - SSI - IE contra Netscape <elephant@squirrelgroup.com>
Re: Perl - SSI - IE contra Netscape <jeff@vpservices.com>
perl -MO=CC,-O2,-oprog.c prog.pl ?? <ralawrence@my-deja.com>
Perl DBI installation <hxshxs@my-deja.com>
Re: Perl outputs to dos instead of ie5 browser <bart.lateur@skynet.be>
Re: Perl Program Problem (Tad McClellan)
regex changes in 5.6 davidhj@mail.com
Re: socket problem (Charles DeRykus)
Re: trying to open excel or pdf files in browsers using <duocbtNOSPAM@pacific.net.au>
Re: use strict; with eval:: error messages to stderr nobull@mail.com
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 25 Oct 2000 00:05:06 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Length of a string stored in a scalar
Message-Id: <MPG.146025f794fe112798ae6d@nntp.hpl.hp.com>
In article <x7u2a1mxc7.fsf@home.sysarch.com>, uri@sysarch.com says...
> >>>>> "JO" == Jerome O'Neil <jerome@activeindexing.com> writes:
>
> JO> Jeff H <jeffahill@_ANTISPAM_.lucent.com> elucidates:
> >> This may seem like a stupid question, but how do I determine the
> >> length of a string stored in a scalar? I've read the perldoc on
> >> Perl data types, but it didn't seem to tell how to do this. It
> >> would be incredibly handy information to have in some of my
> >> applications.
>
> JO> The 'length' function, oddly enough, might do what you want.
>
> we have to make a page of self answering questions. this is happening
> too often. larry did too good a job naming many of perl's functions.
This Larry made such a list a couple of months ago. Do you want to add
it into the perldocs?
Subject: Re: Self-Answering Questions
http://x54.deja.com/[ST_rn=ps]/getdoc.xp?AN=661765261
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Wed, 25 Oct 2000 10:20:17 GMT
From: pingu2@my-deja.com
Subject: Re: local binmode?
Message-Id: <8t6c4v$vbr$1@nnrp1.deja.com>
Thank you for all the answers.
>$ perldoc -f binmode
>
> binmode FILEHANDLE, DISCIPLINE
my binmode doesn't have this DISCIPPLINE option. What Perl/OS are you on? It
must be a new addition, so I'm afraid I can't rely on this.
>Why the heck would you want to do something like that? Either a file
>is binary or it isn't. WHat's the point of switching half way through?
For debugging code in a module writing to a socket. When debugging is set
high, everything printed to the socket is also printed to STDOUT, and can
thus be redirected to a file.
In text mode on Windows, CR-LF is output as CR-CR-LF, which is confusing,
especially when you are debugging. So I considered "binmoding" STDOUT. But
this is in a module, and I shouldn't binmode the main script's STDOUT.
># perldoc -f binmode
>[snip]
> binmode() should be called after open() but before
> any I/O is done on the filehandle.
Gee, yet another doc. for binmode! (Mine (5.005_03) doesn't say this).
This looks like what I was after:
> local *BSTDOUT;
> open(BSTDOUT ">&STDOUT") or die "Couldn't dup STDOUT [$!]\n"
> binmode(BSTDOUT);
>
> # ...
>
> close(BSTDOUT);
But would it work correctly on systems where "binmode() should be called
after open() but before any I/O is done on the filehandle"? I will try it on
Linux and WinNT/95, but please let me know if you can see a reason why it
might lead to problems in some special cases.
Thank you,
Milivoj
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 25 Oct 2000 11:29:19 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: local binmode?
Message-Id: <btgdvs08rl3fhbjsrek4qkegdb6rftd8kr@4ax.com>
pingu2@my-deja.com wrote:
>In text mode on Windows, CR-LF is output as CR-CR-LF, which is confusing,
>especially when you are debugging. So I considered "binmoding" STDOUT. But
>this is in a module, and I shouldn't binmode the main script's STDOUT.
Ah so. Why aren't you simply making a copy of what you send through the
socket, and kill the CR's in that string?
tr/\r//d;
I guess you could also dup the STDOUT filehandle, and binmode that.
Untested, though.
open BINSTDOUT, '>&STDOUT';
binmode BINSTDOUT;
select BINSTDOUT;
--
Bart.
------------------------------
Date: Wed, 25 Oct 2000 07:41:25 GMT
From: rog <rfoskett@my-deja.com>
Subject: Re: loop through all symbol table entries
Message-Id: <8t62r5$olm$1@nnrp1.deja.com>
> > There has to be some way of looping around all the entries in main::
> > perhaps something like this will work:
> > foreach (keys %main::) {
> > print "key = '$_'\n";
> > }
>
> Did you even try it?
>
hehe - no sorry. I was using Windows when writing this so couldnt test
the stuff I was hypothesising about until I rebooted into linux where
Perl is (no ActiveState)
Well - I guess that solves that one.
Thanks
rog
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 25 Oct 2000 12:33:32 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: Make me a hot or not script
Message-Id: <slrn8vdkoq.pan.tjla@thislove.dyndns.org>
I was shocked! How could Peter Sundstrom <peter.sundstrom@eds.com>
say such a terrible thing:
>At the current rate the NZ peso is sliding, NZ$100,000 will be just enough
>to buy a big mac and coke in the US.
Never fear, come the revolution we will print more money to counter
this effect!
--
Gwyn "Inflation? What's that?" Judd
(print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
We cannot banish dangers, but we can banish fears. We must not demean
life by standing in awe of death.
-David Sarnoff
------------------------------
Date: Wed, 25 Oct 2000 11:14:18 +0100
From: James Taylor <james@NOSPAM.demon.co.uk>
Subject: Re: memory allocation and my
Message-Id: <ant2510180b0fNdQ@oakseed.demon.co.uk>
In article <Pine.GSO.4.21.0010242055150.21952-100000@mtwhitney.nsc.com>,
Steven Kuo x7914 <URL:mailto:skuo@mtwhitney.nsc.com> wrote:
>
> One can check with:
>
> #! /usr/local/bin/perl -w
> # foo
>
> use strict;
>
> my @data;
>
> while (<DATA>)
> {
> if (/^foo/)
> {
> @data = split (/:/);
> print \@data, "\n";
> }
> elsif (/^bar/)
> {
> my @data2 = split (/:/);
> print \@data2, "\n";
> }
>
> }
>
> __END__
> foo: tofo : kungfoo: foo-fighters
> bar: behind-bars: bar-brawl : no-holds-barred
> foo: foo-man-chu : foo-lish : foobar
> bar: bar-maid : bar-nacle : barn
>
> ===
>
> The results are:
>
> ARRAY(0xcaed4)
> ARRAY(0xcaf58)
> ARRAY(0xcaed4)
> ARRAY(0xd42c0)
>
> Notice how the reference for @data stays the same while that
> for @data2 does not?
Okay, so the answer to the OP's question is yes, declaring a my
variable inside a loop allocates a new variable each time, but
what I'd like to know is what the pros and cons are of each approach.
Would seasoned Perl programmers prefer one method over the other?
Secondly, shouldn't perl optimise this internally so that a new
variable does not need to be created each time, or am I missing
something (well obviously I am) about the pros and cons of my
variables inside loops.
Thanks.
--
James Taylor <james (at) oakseed demon co uk>
PGP key available ID: 3FBE1BF9
Fingerprint: F19D803624ED6FE8 370045159F66FD02
------------------------------
Date: 25 Oct 2000 13:18:34 +0100
From: nobull@mail.com
Subject: Re: memory allocation and my
Message-Id: <u9d7gpktb9.fsf@wcl-l.bham.ac.uk>
perl-news@axehind.com (Brian) writes:
> While looking at a co-workers perl script I noticed that he had
> something like this
>
> my @data;
> while(<FILE>) {
> if(/^foo/) {
> @data = split(/:/);
> &sub_func(\@data);
> }
> }
>
> When I asked him why @data was "declared" outside the while loop or if
> statement, he said that the memory would have to be re-allocated for
> the array everytime there was a match if the array @data was declared
> inside the loop. By "declaring" it outside the loop, memory doesnt
> have to be allocated every match.
>
> Is there any truth to this?
Yes, but not much. If you want a quantative answer use Benchmark.
If course a much more significant issue is that if sub_func() creates
any persistant references to @data then horible things will happen
with the my outside the loop.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Wed, 25 Oct 2000 12:57:12 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: memory allocation and my
Message-Id: <slrn8vdm53.pan.tjla@thislove.dyndns.org>
I was shocked! How could James Taylor <james@NOSPAM.demon.co.uk>
say such a terrible thing:
>Okay, so the answer to the OP's question is yes, declaring a my
>variable inside a loop allocates a new variable each time, but
>what I'd like to know is what the pros and cons are of each approach.
>Would seasoned Perl programmers prefer one method over the other?
>
>Secondly, shouldn't perl optimise this internally so that a new
>variable does not need to be created each time, or am I missing
>something (well obviously I am) about the pros and cons of my
>variables inside loops.
Well sure there are very good reasons why my() should create a new
instance. Say if you were taking a reference to that my'ed variable and
storing it somewhere (say in a hash). You would be very surprised to
find that the variable you had stored away had changed it's value
unexpectedly. Or if you were (say) reading in fields from a file into a
hash and then printing that, if you don't my() the hash every time
through fields don't get cleared out and you find yourself printing out
old fields that you may not need. I'm sure there are other examples
(*cue*).
--
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
Somebody ought to cross ball point pens with coat hangers so that the
pens will multiply instead of disappear.
------------------------------
Date: Wed, 25 Oct 2000 13:00:45 GMT
From: Jim Mauldin <mauldin@netstorm.net>
Subject: Re: memory allocation and my
Message-Id: <39F6D905.D4EF05FF@netstorm.net>
Steven Kuo x7914 wrote:
>
> On Wed, 25 Oct 2000, Brian wrote:
>
> > While looking at a co-workers perl script I noticed that he had
> > something like this
> >
> > my @data;
> > while(<FILE>) {
> > if(/^foo/) {
> > @data = split(/:/);
> > &sub_func(\@data);
> > }
> > }
> >
> > When I asked him why @data was "declared" outside the while loop or if
> > statement, he said that the memory would have to be re-allocated for
> > the array everytime there was a match if the array @data was declared
> > inside the loop. By "declaring" it outside the loop, memory doesnt
> > have to be allocated every match.
> >
> > Is there any truth to this?
> >
> > Brian Pontz
>
> One can check with:
>
> #! /usr/local/bin/perl -w
> # foo
>
> use strict;
>
> my @data;
>
> while (<DATA>)
> {
> if (/^foo/)
> {
> @data = split (/:/);
> print \@data, "\n";
> }
> elsif (/^bar/)
> {
> my @data2 = split (/:/);
> print \@data2, "\n";
> }
>
> }
>
> __END__
> foo: tofo : kungfoo: foo-fighters
> bar: behind-bars: bar-brawl : no-holds-barred
> foo: foo-man-chu : foo-lish : foobar
> bar: bar-maid : bar-nacle : barn
>
> ===
>
> The results are:
>
> ARRAY(0xcaed4)
> ARRAY(0xcaf58)
> ARRAY(0xcaed4)
> ARRAY(0xd42c0)
>
> Notice how the reference for @data stays the same while that
> for @data2 does not?
>
This is a little bit misleading, because perl does (sooner or later)
recycle the memory allocated to @data2. Using v5.6.0 and changing your
data lines to:
bar: behind-bars: bar-brawl : no-holds-barred
bar1: bar-maid : bar-nacle : barn
bar2: bars22: bar-cat : noholdsbarred
bar3: bar-zoo : barnacle : bard
bar4: bart: barhop : barring
bar5: barq : barp : barn
bar6: barmaid : bar-nacle : barn
bar7: behind-bars: bar-brawl : no-holds-barred
bar8: barkeep : barblue : barbell
bar9: barf : barq : barz
bar0: ind-bars: barawl : noholds-barred
bar12: barice : barnacle : bark
Gives this output:
@data2: ARRAY(0x8761760)
@data2: ARRAY(0x876f1fc)
@data2: ARRAY(0x876f220)
@data2: ARRAY(0x87650d4)
@data2: ARRAY(0x876f1f0)
@data2: ARRAY(0x8761760) # same as first
@data2: ARRAY(0x876f1fc) # same as second
@data2: ARRAY(0x876f220) # same as third
@data2: ARRAY(0x87650d4) # same as fourth
@data2: ARRAY(0x876f1f0) # same as fifth
@data2: ARRAY(0x8761760) # same as first
@data2: ARRAY(0x876f1fc) # same as second
So, yes - declaring a my variable in the if { } block does cost the
overhead of allocating memory for the variable and then deallocating
it. But perl does not go on endlessly allocating memory that is never
reclaimed.
As a related matter, it should be noted that if my @data is declared in
the outermost part of the while loop:
while(<FILE>) {
my @data;
if(/^foo/) {
@data = split(/:/);
&sub_func(\@data);
}
}
it is only created once (and, of course, goes out of scope at the end of
the while loop).
-- Jim
------------------------------
Date: Wed, 25 Oct 2000 11:24:02 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: OT: Jihad definition
Message-Id: <4mgdvscjdi5gdhko0rnfndurotq8s77g5d@4ax.com>
Uri Guttman wrote:
><context>
>i think moronzilla knows as much perl as hitler.
></context>
>
>that should end this thread. and hopefully end moronzilla as well.
That won't work. See the "Godwin's Law" entry in the Jargon File:
However there is also a widely- recognized codicil that any
intentional triggering of Godwin's Law in order to invoke its
thread-ending effects will be unsuccessful.
--
Bart.
------------------------------
Date: Wed, 25 Oct 2000 10:58:43 +0200
From: "J.Wenzel-Ketel" <J.Wenzel-Ketel@t-online.de>
Subject: Perl - SSI - IE contra Netscape
Message-Id: <8t67ia$s2c$06$1@news.t-online.com>
Hi,
I've written a Perlprogramm that generates a sheet with three buttons.
Wenn clicken these buttons the story goes on.
http://www.kom-netz.de/ Click PC und mehr/Multple Choice
This works whenn your using ie but not with ns.
Can somebody tell me why or tell me what I'am doing wrong!!!!!
Jolanda
------------------------------
Date: Wed, 25 Oct 2000 21:05:22 +1000
From: jason <elephant@squirrelgroup.com>
Subject: Re: Perl - SSI - IE contra Netscape
Message-Id: <MPG.1461697f1fe99cb098984f@localhost>
J.Wenzel-Ketel wrote ..
>I've written a Perlprogramm that generates a sheet with three buttons.
>Wenn clicken these buttons the story goes on.
>http://www.kom-netz.de/ Click PC und mehr/Multple Choice
>
>This works whenn your using ie but not with ns.
>Can somebody tell me why or tell me what I'am doing wrong!!!!!
this is a browser issue - and nothing to do with the Perl language ..
you will find a better and more accurate answer in a forum related to
browsers
--
jason -- elephant@squirrelgroup.com --
------------------------------
Date: Wed, 25 Oct 2000 02:25:12 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Perl - SSI - IE contra Netscape
Message-Id: <39F6A6F8.234D18E5@vpservices.com>
"J.Wenzel-Ketel" wrote:
>
> I've written a Perlprogramm that generates a sheet with three buttons.
> Wenn clicken these buttons the story goes on.
> http://www.kom-netz.de/ Click PC und mehr/Multple Choice
>
> This works whenn your using ie but not with ns.
> Can somebody tell me why or tell me what I'am doing wrong!!!!!
Maybe because of your HTML, or maybe because of your JavaScript, or
maybe because of your style sheets. But definetly not because of your
Perl. If it prints to any browser, your Perl works, so you need to look
at the other things for your problem.
--
Jeff
------------------------------
Date: Wed, 25 Oct 2000 08:55:26 GMT
From: Richard Lawrence <ralawrence@my-deja.com>
Subject: perl -MO=CC,-O2,-oprog.c prog.pl ??
Message-Id: <8t675r$rm5$1@nnrp1.deja.com>
Hi,
I saw something somewhere that mentioned that you could convert perl
code to c using the line:
perl -MO=CC,-O2,-oprog.c prog.pl
So I gave it a go with a simple hello world program and true enough I
got:
Prescan
Saving methods
Loaded B
Loaded IO
Loaded Fcntl
prog.pl syntax OK
and a (fairly scarey looking) c file. But when I look at the code it
references header files such as
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
#include "cc_runtime.h"
which I don't have.
Does anyone know where I can find these header files or can anyone show
me what I'm doing wrong?
Many thanks
Rich
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 25 Oct 2000 07:52:24 GMT
From: Howard <hxshxs@my-deja.com>
Subject: Perl DBI installation
Message-Id: <8t63fo$p3e$1@nnrp1.deja.com>
I failed on DBI "make test" during the installation on a fresh redhat
6.2 machine. It failed on "client" test. I wonder if anyone knows how
to check out what went wrong on my machine. any hints ?
Thanks.
-Howard
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 25 Oct 2000 08:39:03 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Perl outputs to dos instead of ie5 browser
Message-Id: <vt6dvsgc1u2d3tqial2nnd0ur8hcnh8ohh@4ax.com>
joe mc cool wrote:
>Let me get this correct:
>
> perl some.cgi.script > some.cgi.html
>
>then view the html from say, Netscape Navigator. Am I correct ? Will
>this work even with forms ?
Kinda. CGI.pm allows reading in the parameters (the stuff following the
quotation mark, when in GET mode) interactively, or from a file. The
author calls this "offline mode".
Too bad that even when in offline mode, the script still sends the
content-type header. So you'll have to strip this of the head of the
HTML file before viewing it wit ha browser.
--
Bart.
------------------------------
Date: Wed, 25 Oct 2000 07:07:37 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Perl Program Problem
Message-Id: <slrn8vdfnp.aos.tadmc@magna.metronet.com>
On Wed, 25 Oct 2000 04:16:57 GMT, Noghri <noghri@nospam.com> wrote:
>First off I have this perl script that I've been trying to get to run.
>Here's a copy of the script.
>**********************************************************************************
>#!/usr/local/bin/perl
#!/usr/local/bin/perl -w
use strict;
>print "\nWhat would you like the password to be? ";
>$pword=<stdin>;
>print "\nRepeat? ";
>$ppword=<stdin>;
>
>while($ppword ne $pword)
A policy where everyone's password must end with a newline is
rather strange...
>chdir(~);
~ is expanded by the _shell_ ...
... but this is Perl, not the shell. Tilde does not mean home dir in Perl.
You should be checking the return value too. Just because you
_asked_ to change dirs doesn't mean you _did_ change dirs.
chdir or die "could not chdir to home directory $!";
>if (-e public_html) {chdir(public_html);}
^^^^^^^^^^^
Barewords are bad.
Strings should be quoted.
>system "chmod 755
>public_html"
Perl has a builtin chmod() function, no need to shell-out for that.
>sub fixindex()
>{
>$#file=0;
Global variables are Bad!
>open(INDEX,"<index.html");
Check the return value.
Just because you _asked_ to open a file doesn't mean you _did_ open a file.
>foreach $line <INDEX>
Syntax error.
The damn program doesn't even compile!
I'm not reading any more of it.
>I can't seem to figure out exactly what's wrong. Could someone help me
>out here?
There are *dozens* of things wrong!
Delete the program and start over.
--
Tad McClellan SGML consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 25 Oct 2000 11:37:26 GMT
From: davidhj@mail.com
Subject: regex changes in 5.6
Message-Id: <8t6gll$2g2$1@nnrp1.deja.com>
I have a subroutine which seems to be working in perl 5.004 but not 5.6.
It's meant to read a file, removing comments after "#", and break it up
into HTML-ish chunks by splitting before each "<" (I know this is not a
perfect way of doing this!)
sub readform
{
open (FORM, "< form.htm") || &error("Throw an error");
local $/ = undef;
while (<FORM>)
{
s/(#.*\n)?//g; # get rid of comments
# btw, I know the ()? is unnecessary -
# could this be causing problems?
s/#.*$//; # get rid of comment at EOF
@form = split (/.{0}(?=<)/);
}
close FORM;
}
In 5.004 this works well, and I get some nice html-ish chunks in @form.
In 5.6 @form seems to be empty.
I have looked at the perldelta for 5.6, and the perlre for 5.6, but
can't find anything that has changed - can anyone suggest anything?
Cheers
Dave H-J
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 25 Oct 2000 08:33:32 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: socket problem
Message-Id: <G2z93w.280@news.boeing.com>
In article <wrn1OUIDfAUiu3UevbHjRjYA4q0q@4ax.com>,
Neil <neil@thump.org> wrote:
> my $sock = new IO::Socket::INET (
> PeerAddr => $host,
> PeerPort => $socket,
> Proto => "tcp");
> die "client: could not open socket to server: $!\n" unless ($sock);
>
>$host and $socket are correct and not firewalled off etc.
>
>I'm getting !$ as "not owner". CAn't find anyting in dejanews to help. Running
>perl 5.004_04 built for alpha-dec_osf on compaq true65 5.0a.
Does the same error occur if you telnet to the socket... ?
telnet <host> <port>
That might at least indicate if there was a problem with the
underlying socket.
hth,
--
Charles DeRykus
------------------------------
Date: Wed, 25 Oct 2000 21:26:30 +1000
From: "Duoc B T" <duocbtNOSPAM@pacific.net.au>
Subject: Re: trying to open excel or pdf files in browsers using cgi
Message-Id: <39f6c143.bb8a9@nancy.pacific.net.au>
David Efflandt <efflandt@xnet.com> wrote in message
news:slrn8v60o5.8f7.efflandt@efflandt.xnet.com...
> On Sun, 22 Oct 2000, Duoc B T <duocbtNOSPAM@pacific.net.au> wrote:
> >
> >i am pulling my hair trying to get my cgi to open an excel or pdf file in
> >the browser. i've tried many things unsuccessfully. this is one of the
> >versions of my getfile.cgi :
> >
> >#!/usr/cgi-bin/perl
> >
> >print ("Content-Disposition: attachment; filename=testfile.xls\n");
> >print ("Pragma: no-cache\n");
> >print ("Cache-Control: no-cache\n");
> >print( "Content-type: application/octet-stream\n\n");
> >exit;
> >
> >when i called my getfile.cgi, the download window pops up asking if i
want
> >to open or save. this is not my intention. i want it to open
automatically
> >in the browser (like a usual link). but still, when i choose open, excel
> >opens the file with the contents missing. any help is appreciated.
>
> You apparently neglected to open, read and send (print) the file contents
> from your script, so what contents do you expect excel to open?
>
> --
> David Efflandt efflandt@xnet.com http://www.de-srv.com/
> http://www.autox.chicago.il.us/ http://www.berniesfloral.net/
> http://cgi-help.virtualave.net/ http://hammer.prohosting.com/~cgi-wiz/
ok, David. i opened, read and printed but still unsuccessful. i really need
help. it would be very helpful if you could give an example. here my code to
help you help me:
#!/usr/cgi-bin/perl
my $file = "testfile.xls";
print "Content-type: application/xls\n\n";
if (open(FILE,$file)) {
$size = -s $file;
print <<EOM;
Content-type: application/octet-stream
Content-length: $size
Content-Disposition: in-line; filename="$file"
EOM
binmode(FILE);
binmode(STDOUT); # No-op for UNIX, mandatory for Win32
while (sysread(IN,$_,32*1024)) { print $_; }
} else {
print "Content-type: text/plain\n\n Error $!\n";
}
------------------------------
Date: 25 Oct 2000 08:30:02 +0100
From: nobull@mail.com
Subject: Re: use strict; with eval:: error messages to stderr
Message-Id: <u9em15l1st.fsf@wcl-l.bham.ac.uk>
William Lewis Brown <bbrown@addtoit.com> writes:
> Unfortunately, it seems as if any errors associated with "use strict" are spit
> out on stderr and do not appear as part of $@.
Fortunately this bug has been fixed in 5.6.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
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 4720
**************************************