[7632] in Perl-Users-Digest
Perl-Users Digest, Issue: 1258 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Nov 1 11:07:18 1997
Date: Sat, 1 Nov 97 08:00:26 -0800
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, 1 Nov 1997 Volume: 8 Number: 1258
Today's topics:
Re: "die" function won't print in CGI!?!! (William R. Ward)
Re: again -- multi-line text replacement (Bill Moseley)
Re: again -- multi-line text replacement (Tad McClellan)
Re: AUTOLOAD and sort (William R. Ward)
Bug in Perl 5 'chr' <100675.2064@CompuServe.COM>
Re: CGI script results to email? <jgrubb@gte.net>
Cookies <lauri.laakso@samoilu.net>
Re: Cookies (Toutatis)
Displaying Atomic Clock time?? <moggy@lisp.com.au>
Re: Displaying Atomic Clock time?? (Toutatis)
Re: eval 'use Socket' vs. 'use socket' (M.J.T. Guy)
Re: File globbing 5.004.01/2 on Win32 (Eric Bohlman)
File handles and XSUBs (Lloyd Zusman)
Re: help for perl NT4.0 <nospam@voicenet.com>
Re: if (0<= $hun < 250) doesn't compile (Damian Conway)
Invoking a PERL script with parameters paul@pkamf.demon.co.uk
Re: Memory problems - how can I fix? (M.J.T. Guy)
Re: Novell and CGI (Ken C.)
OPEN WON'T WORK IN PERL-WIN32? <jgrubb@gte.net>
Re: Perl 5.004_04 is available (Maintenance Release 4 f <nospam@voicenet.com>
Re: Perl Format Command (Tad McClellan)
Re: Perl2Exe with Tk? (Thomas Rock)
Personal Web Server - Perl ? <yooo@geocities.com>
Re: Personal Web Server - Perl ? (Tad McClellan)
Re: please help--reding client file from a server <lkj@lesbois.com>
Re: Reference to class method (\&{$foo->you}) (M.J.T. Guy)
Re: using -s to get file size (Eric Bohlman)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 31 Oct 1997 20:48:49 -0800
From: hermit@cats.ucsc.edu (William R. Ward)
Subject: Re: "die" function won't print in CGI!?!!
Message-Id: <waapvolqkwe.fsf@ese.UCSC.EDU>
When you call "die" (or "warn") in a CGI environment, the error
message will not be sent to your browser. Where it goes depends on
what server you are using, but generally it's a log file.
If you are using Apache or NCSA (or I think Cern), the error goes into
the error log file verbatim. Apache has an option to send it to a
separate log file for CGI error output.
If you are using the Netscape Commerce or Enterprise server (not sure
about other Netscape servers, but I'd be surprised if it was
different), then Netscape tries to parse the error message for HTTP
header info (e.g. Content-Type: text/html) and fails, putting a really
cryptic message in its error log like:
[31/Oct/1997:19:57:03] failure: for host <hostname> trying to GET
<URL>, cgi-parse-output reports: the CGI program <path-to-cgi> did not
produce a valid header (name without value: got line "<errormsg>")
The error message is downcased and may be truncated, and you'll only
get the first line of it. "did not produce a valid header" means that
it wasn't of the form "header-name: value" which HTTP uses.
I have no idea what the Microsoft IIS does, but it probably isn't pretty.
Anyway, the solution is to "use CGI::Carp qw(fatalsToBrowser);". This
redefines die and warn (and carp and croak, as a bonus) to behave in a
more CGI-friendly way. The error messages are logged with a timestamp
and filename in front, so that Apache or NCSA log file entries will
match the ones the server produces. Also with the fatalsToBrowser
option, the error message will be displayed on your user's screen.
This doesn't work perfectly with all situations, for example if you've
already made some of your output and then call die, you'll get an
extra Content-Type header, which you probably don't want. The only
fix I've found to that is to make your own module that does what
CGI::Carp does, only in a more pleasing manner.
Hope this helps!
--Bill.
[posted and mailed]
Mani Prasad Kancherla <mani@geoplex.com> writes:
> Hi All!
>
> Please take a look at the following code:
> --------------------------------------------------------------------------------------
>
> #!/usr/bin/perl -w
> use CGI(":standard");
>
> $err_str = start_html("Error").h1("Error:")."Can't find form:
> $!".end_html;
>
> print header;
> die $err_str unless (param("form") eq "trouble_report");
> start_html("blah blah"); print "Some stuff"; end_html;
> --------------------------------------------------------------------------------------
>
> When the value of "form" is "trouble_report" everything is fine.
> Otherwise,
> Netscape complains "Document has no data". But when I try this program
> from
> the command line I get what is expected in both cases (i.e. when "form"
> =
> "trouble_report" or even otherwise).
>
> Is there something wrong with what I'm doing?
>
> Thanks in advance,
> mani
>
--
William R Ward Bay View Consulting http://www.bayview.com/~hermit/
hermit@bayview.com 1803 Mission St. #339 voicemail +1 408/479-4072
hermit@cats.ucsc.edu Santa Cruz CA 95060 USA pager +1 408/458-8862
------------------------------
Date: 1 Nov 1997 02:07:01 GMT
From: moseley@netcom.com (Bill Moseley)
Subject: Re: again -- multi-line text replacement
Message-Id: <63e2s5$q40$1@nnrp3.snfc21.pbi.net>
In article <Pine.GSO.3.96.971031170112.9456G-100000@usertest.teleport.com>,
rootbeer@teleport.com says...
>Do you find anything useful when you search for the word "greedy" in the
>perlre(1) manpage? Hope this helps!
I know this can't be that hard...
I thought that perlre(1) manpage helped, but it still doesn't work.
Any suggestions? It is still substituting to the last </TD>.
D:\e>cat script
#!/usr/bin/perl -pi.old
$/=undef; # Read all
$NEWSTR = "<replacement string>\n</td-new>";
s/<img src.*(<\/TD>){1}?/$NEWSTR/si; # make non-greedy with {1}?
D:\e>cat text
<!-- this is a comment -->
<TD>
this is first column
<IMG Src="../images/transparent.gif" Height="1" Width="120">
Line above to first end of column tag should be deleted
</TD>
<TD>
this is the second one, and should remain
</TD>
end of file
D:\e>cat text | perl script
<!-- this is a comment -->
<TD>
this is first column
<replacement string>
</td-new>
end of file
--
Bill Moseley
mailto:moseley@netcom.com
------------------------------
Date: Sat, 1 Nov 1997 09:07:27 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: again -- multi-line text replacement
Message-Id: <fjgf36.gi4.ln@localhost>
Bill Moseley (moseley@netcom.com) wrote:
: In article <Pine.GSO.3.96.971031170112.9456G-100000@usertest.teleport.com>,
: rootbeer@teleport.com says...
: >Do you find anything useful when you search for the word "greedy" in the
: >perlre(1) manpage? Hope this helps!
: I know this can't be that hard...
: I thought that perlre(1) manpage helped, but it still doesn't work.
: Any suggestions? It is still substituting to the last </TD>.
: s/<img src.*(<\/TD>){1}?/$NEWSTR/si; # make non-greedy with {1}?
No.
The .* part is what is matching greedily, you need to modify that part:
s!<img src.*?</TD>!$NEWSTR!si; # make the "dot matching" non-greedy
^^^ # with *? instead of greedy with *
^^^
I also used an alternative regex delimiter so I wouldn't have to
escape the slash.
--
Tad McClellan SGML Consulting
tadmc@flash.net Perl programming
Fort Worth, Texas
------------------------------
Date: 31 Oct 1997 21:26:29 -0800
From: hermit@cats.ucsc.edu (William R. Ward)
Subject: Re: AUTOLOAD and sort
Message-Id: <waan2jpqj5m.fsf@ese.UCSC.EDU>
aml@world.std.com (Andrew M. Langmead) writes:
> lmegliol@inertia.acs.uci.edu (Leonard Megliola) writes:
> >I have a program which makes a call to sort such as the
> >following:
>
> > sort _sort_subroutine ... ;
>
> >_sort_subroutine is an AutoLoaded routine, and because "the normal
> >calling code for subroutines [used in sort] is bypassed", the
> >_sort_subroutine is not loaded. An error is printed that
> >explains that the routine cannot be found.
>
> One way around it that I can think of is to give sort a bare code
> block that calls your autoloaded sub.
>
> @sorted = sort { _sort_subroutine() } @list;
>
> You will pay a small performance penalty for the extra subroutine
> call.
Better to pay that penalty once, at the beginning, than every time it
is called, no?
--Bill.
--
William R Ward Bay View Consulting http://www.bayview.com/~hermit/
hermit@bayview.com 1803 Mission St. #339 voicemail +1 408/479-4072
hermit@cats.ucsc.edu Santa Cruz CA 95060 USA pager +1 408/458-8862
------------------------------
Date: Fri, 31 Oct 1997 07:16:31 -0500
From: Ulrich Ludwig <100675.2064@CompuServe.COM>
Subject: Bug in Perl 5 'chr'
Message-Id: <u$wWTbf58GA.302@nih2naab.prod2.compuserve.com>
Hi,
there seems to be abug in GNU Perl 5.0004 for WIN@*# 32.
The 'chr'-function is not implemented, so you get a
compilation error when trying to use it.
Is this right and does a bugfix exist (It all works well
under UNIX !)
kind regards
Uli
--
uli
( Ulrich Ludwig: 100675.2064@CompuServe.com )
------------------------------
Date: 30 Oct 1997 15:07:16 GMT
From: John Grubb <jgrubb@gte.net>
Subject: Re: CGI script results to email?
Message-Id: <63a7r4$75q$1@gte1.gte.net>
Neil Anuskiewicz wrote:
> I am new to perl right now, so this may seem like a very simple issue.
>
> I need to write a cgi script that creates a form on our web site that
> someone can fill out, submit, and then the results sent in an email.
> The
> email goes to several people so it must retain an easily readable
> format:
>
> question?
>
> answer...
>
> Easy to read question/answer format. At any rate, does anyone have
> some
> guidance on how to accomplish this task or point me in the right
> direction?
>
> Thank you very much.
This is a classic task for PERL. I have probably done hundreds of these.
Although this task uses the most basic of PERL functions, it is not a
simple matter to set up the form and manipulate the inputs. You can
gleen a great deal of information and a very useful library of code for
this specific purpose from Selena Sol's homepage at
http://www.extropia.com/. This is a great place to begin a PERL career.
If I can be of specific help with your code or, if you would like to
retain my services to produce the whole project, I am employed as an
HTML, PERL and JAVA programmer and I do consulting. I don't like to
charge by the hour. I usually quote a price for the completed job. A
simple project of an HTML page with a few questions or entry boxes (less
than 5), with error checking and email of the results to an address
usually runs about $100.00.
I will help on specific code problems without charge, but I can't afford
to spend a great deal of time for free.
John Grubb
jgrubb@gte.net
------------------------------
Date: Sat, 01 Nov 1997 11:36:38 +0200
From: Lauri Laakso <lauri.laakso@samoilu.net>
Subject: Cookies
Message-Id: <345AF826.2BA1@samoilu.net>
My cookies doesn't always work. This is quite important in our system,
so please help. about 10-20% of users using cookies, following code
doesn't work.
I set cookies and then print pictures:
print "Set-Cookie: mycookie=something; ";
print "path=/; ";
print "domain=.samoilu.net;\n";
print "Content-Type: image/jpeg\n\n";
open(FOO,$pic) || &log("adhsow: can't open $pic");
while( <FOO> ) {print;}
close(FOO);
domain is actually www.mmklik.samoilu.net, and i have tried
samoilu.net .samoilu.net mmklik.samoilu.net .mmklik.samoilu.net
and many different paths like "\" or "/" or none.
If cookie not found (when it should found) system tests sendin five
different cookies and then move to the next page and get them
print "Set-Cookie: mmklikcookie0=on; ";
print "path=/; ";
print "domain=.samoilu.net;\n";
This works on every case!!! And it's same than picture-cookie.
Please email (lauri@samoilu.net), if you have any ideas !
(I'm not able to read this group every day)
Thanx very much!!
................................................................
Lauri Laakso - Nettipaja Oy - GSM: 040-588 8889 [EMAIL2GSM]
Internet 35mk/kk + 1mk/h: http://www.samoilu.net/iy.htm
MailCaster: http://www.mailcaster.samoilu.net/
------------------------------
Date: 1 Nov 1997 13:52:12 GMT
From: toutatis@_SPAMTRAP_toutatis.net (Toutatis)
Subject: Re: Cookies
Message-Id: <toutatis-ya023180000111971452110001@news.euro.net>
Lauri Laakso <lauri.laakso@samoilu.net> wrote:
> My cookies doesn't always work.
check
http://www.cookiecentral.com/unofficial_cookie_faq.htm
then ask somewhere else
--
Toutatis
------------------------------
Date: 31 Oct 1997 12:31:25 GMT
From: "Brett" <moggy@lisp.com.au>
Subject: Displaying Atomic Clock time??
Message-Id: <01bce5f9$2c6ba200$271a1acb@speedy>
I was curious to know if there was a way to display the time as from the
Atomic Clock, or anther reliable source?
The reason I ask this is because of a page I am creating which needs the
viewers to see the same time (ie, not what you're computer is set to).
This is primarily for online auctions, so that when an auction is about to
close in say 10 mins, the client knows that it IS 10 mins and not 20 mins
away from closing.
Any suggestions?
Thanks!
Brett
brett@moggy.com
------------------------------
Date: 1 Nov 1997 14:11:27 GMT
From: toutatis@_SPAMTRAP_toutatis.net (Toutatis)
Subject: Re: Displaying Atomic Clock time??
Message-Id: <toutatis-ya023180000111971511270001@news.euro.net>
Brett <moggy@lisp.com.au> wrote:
> I was curious to know if there was a way to display the time as from the
> Atomic Clock, or anther reliable source?
Check
http://www.eecis.udel.edu/~ntp/
then ask somewhere else
--
Toutatis
------------------------------
Date: 1 Nov 1997 15:35:16 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: eval 'use Socket' vs. 'use socket'
Message-Id: <63fi7k$icg$1@lyra.csx.cam.ac.uk>
Rahul Dhesi <c.c.eiftj@33.usenet.us.com> wrote:
>2. When I have a perl script that loads many slow modules, and I want
>it to quickly exit with a usage message if incorrectly invoked.
>
> ... parse argument ..
> if (bad argument) {
> ... print nice usage message ...
> exit(1);
> }
> eval 'use Big_and_slow_module1';
> $@ && die $@;
> eval 'use Big_and_slow_module2';
> $@ && die $@;
> eval 'use Big_and_slow_module3';
> $@ && die $@;
I find it much tidier to simply put the argument test inside a BEGIN block.
Mike Guy
------------------------------
Date: Sat, 1 Nov 1997 07:50:44 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: File globbing 5.004.01/2 on Win32
Message-Id: <ebohlmanEIyJ4L.DDv@netcom.com>
Chris Searle (chris_ns@searle1.demon.co.uk) wrote:
: However, if I use anything that requires globbing by the shell, then I
: get e.g.
: perl test.pl *.bat
: Can't open *.bat: No such file or directory
>From an article posted by Gurusamy Sarathy a while back:
Set PERL5OPT in your environment to "-MWild" (or append, if you already
have something in PERL5OPT), and make sure you put Wild.pm below in your
perl's "lib" directory:
# Wild.pm - emulate shell @ARGV expansion on shells that don't
use File::DosGlob;
@ARGV = map { my @g = File::DosGlob::glob($_) if /[*?]/; @g?@g:$_ } @ARGV;
------------------------------
Date: 1 Nov 1997 05:34:26 GMT
From: ljz@asfast.com (Lloyd Zusman)
Subject: File handles and XSUBs
Message-Id: <slrn65lfi1.f4.ljz@ljz.asfast.net>
I'm looking for some documentation or examples which explain how to
pass a file handle as an argument to an XSUB, and then to have the
XSUB read from or write to this file handle.
I have read the 'perlxs', 'perlxstut', and 'perlguts' man pages, and I
still am finding file-handle processing within an XSUB to be a
mystery.
Any ideas?
Thanks in advance.
--
Lloyd Zusman
ljz@asfast.com
------------------------------
Date: Sat, 01 Nov 1997 15:15:34 GMT
From: John Nolan <nospam@voicenet.com>
Subject: Re: help for perl NT4.0
Message-Id: <345B47A5.67D9@voicenet.com>
theresa@nytimes.com wrote:
>
> Hi:
> Where can I download the perl that can run on NY4.0 from
> command line. Thanks in advance.
Try the Activeware port, at http://www.activeware.com.
It runs on both NY and Chicago. ;-)
--John Nolan
------------------------------
Date: 1 Nov 1997 04:54:12 GMT
From: damian@cs.monash.edu.au (Damian Conway)
Subject: Re: if (0<= $hun < 250) doesn't compile
Message-Id: <63eclk$nbc$1@towncrier.cc.monash.edu.au>
bsa@void.apk.net (Brandon S. Allbery KF8NH; to reply, change "void" to "kf8nh") writes:
>In <t0yvhyeas4u.fsf@cs.man.ac.uk>, on 10/31/97 at 03:06 PM,
>| > there's no compelling reason for a modern
>| > programming language _not_ to support them.
>| And since Perl currently gives an error message for such syntax, and so the
>| extension shouldn't cause old code to break, is it possibly worth
>| considering adding multiple comparisons to Perl?
>Suggest a mechanism --- preferably one that doesn't require massive parser or
>recognizer calisthenics.
The only "calisthenics" that the parser would require would be:
1. Make RELOPs left associative in the grammar
2. Massage the parse tree (top down) so that any occurance of:
RELOP
/ \
RELOP OP3
/ \
OP1 OP2
is transformed to:
ANDOP
/ \
RELOP RELOP
/ \ / \
OP1 OP2 OP2 OP3
Damian
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
who: Damian Conway email: damian@cs.monash.edu.au
where: Computer Science Dept. web: http://www.cs.monash.edu.au/~damian
Monash University quote: "The best form of self-defence is
Clayton 3168, Australia not being there in the first place"
------------------------------
Date: Sat, 01 Nov 1997 18:40:16 GMT
From: paul@pkamf.demon.co.uk
Subject: Invoking a PERL script with parameters
Message-Id: <878380819.8059.3.nnrp-05.9e98ada2@news.demon.co.uk>
Hi Guru's
I want to run a PERL script under UNIX from a Makefile. I want to put
parameters in the Makefile that get picked up by the PERL file upon
execution:
i.e. in the Makefile I write:
PARAM1 = NOV
PARAM2 = MON
# Invoke PERL scipt
./myPERLprog using PARAM1 and PARAM2
ie in the PERL script I want:
$INTERNALVAR1 = $PARAM1;
$INTERNALVAR2 = $PARAM2;
How can I invoke PERL to pick up variables defined in the Makefile?
I looked at ./my perlscript -e etc but had no joy.
Could you please email any replies to paul@pkamf.demon.co.uk
as I don't get in the newsgroups very often.
Thanks
Paul
------------------------------
Date: 1 Nov 1997 13:24:25 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Memory problems - how can I fix?
Message-Id: <63fai9$em0$1@lyra.csx.cam.ac.uk>
Tom Phoenix <rootbeer@teleport.com> wrote:
>On Tue, 28 Oct 1997, Ryan wrote:
>
>> foreach (1..100000) {
>
>As Ilya has pointed out, in current versions of Perl, this becomes a list
>of 100000 scalars at compile time - and they stick around for your entire
>script! My rule of thumb is that, if a list from .. may have more
>than about 1000 elements, you should code it explicitly with something
>like the three-part for loop.
>
> for ($_ = 1; $_ <= 100000; $_++) {
>
>Does that fix (most of) your memory problem?
When I tried the original, it took 9.8M. With the for loop it took
only 400k. So that does indeed explain the memory use.
But that raises a couple of other points:
i) each element of the 1..100000 array is taking nearly 100 bytes.
I know Perl is prodigal with memory, but this seems excessive.
ii) With the foreach, the test took 28 secs on my aging system. The
for version took 38 secs. Conventional wisdom seems to have it
that the C-style for is the fastest form of loop, but it appears
not to be true here.
Mike Guy
------------------------------
Date: Sat, 01 Nov 1997 04:50:01 GMT
From: n8ptt@ibm.net (Ken C.)
Subject: Re: Novell and CGI
Message-Id: <345ab4f9.0@news2.ibm.net>
I'm running Webserver 3.1 (or whatever the latest is) on my Novell 4.11
with Perl5. I'm still learning Perl so my scripts aren't very pretty
(but they work). What questions do you have and I'll try to answer
them.
Ken C. CNE
n8ptt@ibm.net
In article <345A7554.B581DB9E@platinum.com>, Jim Fuhring
<jfuhring@platinum.com> wrote:
>Has anyone had any experience with using a Novell Web server. I am
>trying to run a Perl5 script. It seems from the documentation that I
>have read so far, that the server has to be set up to run a Perl script.
>I am new to Perl and CGI programming, but am learning fast....too fast.
>Does anyone know how to set up a Novell Web Server?
>
>Jim Fuhring
>jfuhring@platinum.com
>
------------------------------
Date: 30 Oct 1997 14:45:02 GMT
From: John Grubb <jgrubb@gte.net>
Subject: OPEN WON'T WORK IN PERL-WIN32?
Message-Id: <63a6he$2nt$1@gte2.gte.net>
Just started trying to run a perl script on an NT server, running
Netscape Enterprise Server. The script works fine except for openning
the output file for appending. The script works fine on a Solaris server
running Enterprise Server.
The code follows:
open (FILEHANDLE, ">>$file");
print FILEHANDLE join("\|", @array_name) . "\n";
close (USERFILE);
$file already exists in the local directory. This should append the
contents of @array_name to $file, with the entities seperated by "|"
symbols, but it actually does absolutely nothing; no errors, no data
written.
What is different about perl-nt32 that causes this? Is open not a valid
function in perl-nt32?
Please help!!
John Grubb
jgrubb@gte.net
------------------------------
Date: Sat, 01 Nov 1997 15:47:43 GMT
From: John Nolan <nospam@voicenet.com>
Subject: Re: Perl 5.004_04 is available (Maintenance Release 4 for Perl5.004)
Message-Id: <345B4F2F.68D0@voicenet.com>
Tim Bunce wrote:
> The development track is focused on major enhancements to Perl and will
> typically have a fairly long major release cycle. Work on 5.005 (which
> will include threading and improved compiler support) is underway now.
> Alpha releases for 5.005 have subversion numbers starting from 5.004_50.
^^^^^^^^^^
So, Perl 5.005 will be subversive?
I guess on Windows platforms it will perform illegal operations. :P
--John Nolan
------------------------------
Date: Sat, 1 Nov 1997 08:55:07 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Perl Format Command
Message-Id: <bsff36.bf4.ln@localhost>
Gary C. New (gnew@southernvirginia.edu) wrote:
: Tad McClellan wrote:
: > : (I have a perl manuel).
: >
: > Is that the porter of the Spanish version of perl? ;-)
: >
: > Some "manuals" are good.
: >
: > Some are less than good.
: >
: > Which one do you have (besides the man pages that you already have,
: > since I assume you have a proper perl installation)?
: I have "Using PERL 5 by David Harlan, Shelley Powers, Paul Doyle, and
: Micheal O Foghlu".
I have not looked at that one. Probably because in gets only a two Camel
rating at Tom Christiansen's "Camel Critiques" Perl book review page:
http://language.perl.com/critiques/index.html
: > If you can phrase a question, someone will likely take a stab at
: > answering it.
: From the perlform I understand the major pic and variable setup, but
: what it doesn't explain very well is where it goes after after writing
: it.
It goes where you tell it to go. Now, all you need to do is figure out
the correct place to tell it to go ;-)
Without seeing any code, we can't say much for sure, but:
You declared your format to have the same name as the filehandle, or
you are using select()?
I generally try to get a small example working from the command line
before incorporating the code into a CGI script. Or, use CGI.pm for
easy off-line debugging.
Get it working from the command line, and write()ing to STDOUT. Then
get it working when write()ing to MAIL. _Then_ put it into the CGI script.
: > What are you trying to get that you cannot figure out from the info
: > in perlform?
: How can I extract it to print on the screen or another file handle?
Change the format declaration, and write() to STDOUT instead of MAIL.
Or, you may want to get to the formline() routine for lower level
access to what is going on.
: > Is there some part of that man page that is unclear?
: After format HANDLE
: @<<<<<<<<<<<<
: $var{'varible'}
: .
: the period.
I don't think I understand this question.
That is only a _declaration_, it doesn't *do* anything (like generate
any output).
Only when you do:
write HANDLE;
does output get generated.
: Thank you for the tackful information and willingness to address my off
: and on inqueary for over a year now.
Glad to help.
If you can find time to answer a few questions here yourself, you will
have paid me back ;-)
--
Tad McClellan SGML Consulting
tadmc@flash.net Perl programming
Fort Worth, Texas
------------------------------
Date: Sat, 1 Nov 1997 08:09:12 -0600
From: thomas@x-tekcorp.com (Thomas Rock)
Subject: Re: Perl2Exe with Tk?
Message-Id: <MPG.ec4f40733ab32fc989680@news.anet-chi.com>
In article <63cpot$5ca@tmp.boc.com>, murray-paul@usa.net says...
> I am looking to build a few small support programs to distribute
> alongside an existing package. A graphical user-interface is required,
> and I would like to be able to pre-compile the script into a single file
> I can ship out to the computers, rather than have a complete perl
> installation on each.
> Now I can use the standard perl distribution and get Tk, or I
> can use the ActiveWare build together with Perl2Exe to get a single
> executable, my question is whether I can do both at once?
> I tried mangling the standard perl directory structure to
> enable perl2exe to find the modules I am including, but although it
> compiles ok, it fails at runtimes in autoloads.
> Is there either a perl2exe for standard perl (preferred), or a
> version of Tk for Activeware perl?
>
> -Paul Murray
Hi,
I have used perl2exe with the Gurusamy Sarathy compiled perl binary for
win-blows. No hacking of the distribution was necessary. E-mail me if you
need further details.
Tom
thomas@x-tekcorp.com
------------------------------
Date: Thu, 30 Oct 1997 17:47:35 +0100
From: "Jo Janssens" <yooo@geocities.com>
Subject: Personal Web Server - Perl ?
Message-Id: <3458ba3f.0@news.bru.tfi.be>
Is it possible to configure Personal Web Server (Microsoft), so I can run
Perl CGI-scripts on it ?
Thx in advance
------------------------------
Date: Sat, 1 Nov 1997 07:29:42 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Personal Web Server - Perl ?
Message-Id: <6saf36.e54.ln@localhost>
Jo Janssens (yooo@geocities.com) wrote:
: Is it possible to configure Personal Web Server (Microsoft), so I can run
: Perl CGI-scripts on it ?
I don't know.
This is the Perl newsgroup.
There are other newsgroups for questions about server setup:
comp.infosystems.www.servers.ms-windows
You are much more likely to get an answer to a server question there,
since perl does not even _have_ a "server".
There is yet another newsgroup for questions about CGI programming:
comp.infosystems.www.authoring.cgi
: Thx in advance
Perl != CGI
--
Tad McClellan SGML Consulting
tadmc@flash.net Perl programming
Fort Worth, Texas
------------------------------
Date: Fri, 31 Oct 1997 21:08:23 -0700
From: Razzbar <lkj@lesbois.com>
To: Tad McClellan <tadmc@flash.net>
Subject: Re: please help--reding client file from a server
Message-Id: <345AAB37.ECF0037A@lesbois.com>
Tad McClellan wrote:
>
> Lena Mindlina (mindlina@allegro.cs.tufts.edu) wrote:
> : I am writing a cgi script in perl. Among other things, it needs
> ^^^^^^^^^^
>
> CGI scripts run on the server.
>
> : to read into a string information from a file that is on the client's pc.
> : Now, this is relatively easy to do if I upload the file to the server, then
> : read from it and then clean up. However, I really don't want to upload
> : the file. Is it at all possible to have a form asking user for the
> : file to look in, but then instead of uploading the file, read the
> : information from it into a variable?
> Think about that for a minute.
I know I'd think twice before letting somebody read a string from one of
my files.
> "I really don't want to upload the file"
> "read the information from it into a variable"
>
... of course, of course!
> Where will the variable live?
>
> On the server, since that is where the CGI script runs...
>
> You end up transferring the whole thing either way.
>
How you figure?
> Why do you not want to upload the file?
>
> To save disk space? You wouldn't save any bandwidth...
How you figure? If he only is interested in a few bytes of
data, from a file of perhaps megabytes, it seems perfectly
reasonable not to want to upload the whole file.
The only way I see it being done is to use some application
on the client to extract the variable, and possibly have it
set a cookie. It would still require client-user intervention,
and that's a good thing, obviously.
------------------------------
Date: 1 Nov 1997 15:31:02 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Reference to class method (\&{$foo->you})
Message-Id: <63fhvm$i3f$1@lyra.csx.cam.ac.uk>
Andrew M. Langmead <aml@world.std.com> wrote:
>Don Thomson <thomson@zinger.adp.wisc.edu> writes:
>
>>Hmmmm..... I'm trying to create a reference to a class method, as in
>>'\&{$foo->you}' in the following code snippet.
>
>How about if you create an anonymous subroutine that calls the method?
>
>$subref = sub { $foo->you() };
No need to do that. Use the built-in function:
$subref = $foo->can('you');
See perldoc UNIVERSAL
Mike Guy
------------------------------
Date: Sat, 1 Nov 1997 07:14:15 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: using -s to get file size
Message-Id: <ebohlmanEIyHFr.Bv0@netcom.com>
JoyDivisin (joydivisin@aol.com) wrote:
: Ok, in followup, here's my code:
You've already gotten responses to the primary source of your problem,
but here's a couple comments.
: $currdir = "/usr/web/docs/";
This is a classic case of a bad choice of variable name. "currdir"
subtly conveys the misleading notion that the directory specified there is
in fact the "current directory." When you stare at your code trying to
figure out where you went wrong, that name creates a false expectation
that distracts your attention from the real problem. You might want to
look at Gerald Weinberg's _The Psychology of Computer Programming_
(probably out of print by now, but may be available in libraries) which
has a whole chapter on how programming style can introduce subtle
perceptual biases that make debugging difficult. Here's a quote:
"Mnemonic symbols are particularly susceptible of inducing a torpor in
the program reader. Mnemonic symbols expose us to misreading for several
reasons:
1. They tend to make programs seem "sensible" by their satisfaction of
our general set toward sense over nonsense.
2. The play upon our tendency to believe in the name, rather than the
denotation of the name. Who would believe that the symbol "FIVE" denoted
a value of 4? But it did, in one case where the programmer had to modify
his code and didn't have time to change all references to "FIVE." He
did, however, have time to rerun the program--after having taken much
time to locate the source of difficulty.
..."
"Psychological set," by the way, is the technical term for our bias toward
seeing what we expect to see rather than what's actually in front of us
(i.e. it's the basis for Douglas Adams' SEP field). One of the properties
of a good programming style is that it minimizes the opportunity for set
to make you believe that your code is doing something different than what
it's actually doing. Proper choice of variable names is one aspect of
such a style.
: opendir(DOT, $currdir) || die "Cannot open current dir";
With just a little more effort, you could have your program tell you
exactly *why* it couldn't open the directory. $! is your friend.
"DOT" is once again a bad name for your dirhandle, since it seems to come
from the fact that "." means "current directory." It only strengthens the
set against seeing that you aren't actually working with the current
directory.
: print "Content-type: text/html\n\n";
: print "<html><head><title>Directory of currdir</title></head>\n";
^^^^^^^
Once again, this is quite misleading. Why not just interpolate the
directory name into the output rather than using a fixed label?
: print "<body bgcolor=#ffffff>\n";
This will result in invisible or hard-to-read output to anyone who has
their browser set to use a light color for text. If you're going to set
one of the five optional <body> color attributes, you really have to set
the rest of them as well.
: print "<table border=0>\n";
: print "<tr><th>Name</th><th>Size</th></tr>\n";
: while ($name = readdir(DOT)) {
This will quit prematurely if you have a file named "0" in your directory;
while (defined($name=readdir(DOT))) {
is safer. (Another example of set: I had to scan what I typed a couple
times before realizing that I was originally missing a closing paren.)
: open(EP, $name);
Already dealt with in other replies.
: if (($pos = index($name,".")) >0) {
It's somewhat poor style to use a variable name that's also the name of a
built-in function. Your code prompted me to try to look up information
about the return values of index() in the Camel, but I found myself
looking up pos() instead.
: @info = stat $name;
: $size = @info[7];
: $uid = @info[4];
The above two lines work by accident. They're actually assigning the
first element of an array slice to a scalar.
You could actually write them as
($size,$uid)=@info[7,4];
or even as
($size,$uid)=(stat "$currdir/$name")[7,4];
: $total += $size;
Again a matter of style, but I really prefer to explictly initialize
variables like $total to zero before starting to count. It will save you
lots of grief if you ever wind up cutting and pasting this loop into an
outer loop or a subroutine where there's the possiblity of executing it
more than once (on all but the first execution, $total will have the
leftover value from the previous execution, which may not be what you
want).
: print "<tr><td>$name</td><td>$size</td><td>$uid</td></tr>\n";
: }
: }
More style: loop code is more readable if closing braces line up
vertically with the statement that opened the block.
: print "<tr><td></td><td>$total</td></tr>\n";
: closedir(DOT);
: print "</table></body></html>";
------------------------------
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 1258
**************************************