[11864] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 5464 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Apr 23 12:07:29 1999

Date: Fri, 23 Apr 99 09:00:19 -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           Fri, 23 Apr 1999     Volume: 8 Number: 5464

Today's topics:
    Re: Calling sub from generated html page (Tom Gerstel)
        CHAT engine wanted ($) <ours@casema.net>
    Re: combining multiple grep statements into one... <tchrist@mox.perl.com>
        Help understanding this script gustavo9000@my-dejanews.com
    Re: How to make an array name to be a variable? Mike.Wescott@ColumbiaSC.NCR.COM
    Re: How to make an array name to be a variable? <tchrist@mox.perl.com>
        How to receive a mail with Perl? <olivier.maas@at-lci.com>
    Re: I need help with pipes in perl! <Wm.Blasius@ks.sel.alcatel.de>
    Re: Lockfile-Problem <tchrist@mox.perl.com>
    Re: NN? ['Nother Newbie Question] <staffan@ngb.se>
    Re: Perl 'split' function in C?? <aqumsieh@matrox.com>
    Re: Perl 'split' function in C?? <tchrist@mox.perl.com>
        Perl Debugger <mableyp@logica.com>
    Re: Perl Debugger <tchrist@mox.perl.com>
    Re: Please, HELP with uninitialized value error <aqumsieh@matrox.com>
    Re: Problems with the connect function <tchrist@mox.perl.com>
    Re: regex: I see THAT it works, but I don't see WHY (Larry Rosler)
    Re: regex: I see THAT it works, but I don't see WHY <tchrist@mox.perl.com>
        removing rows from table (html tags) pcluong@yahoo.com
    Re: reset $. in one-liner <mthomas+posting@cs.cmu.edu>
    Re: split help <Allan@due.net>
    Re: The question about debug and design <carfield@polyu.hknet.com>
    Re: Unix files in MacPerl <haakon.alstadheim@sds.no>
    Re: yet another Abigail sig (hymie!)
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Fri, 23 Apr 1999 15:30:00 GMT
From: tgerstel@world.std.com (Tom Gerstel)
Subject: Re: Calling sub from generated html page
Message-Id: <FAnF20.HHH@world.std.com>

Henry Vermeulen <hvermeulen@correctnl.com> writes:

>Hi all.
>I have the following problem.
>I wrote a cgi script that, while running, creates a html form in the
>browser when a certain filename exist.
>Th user has tree actions to choose from.
>Each button has to call a subroutine in the running script but i can't
>get it working this way.
>Calling the sub from inside the script all goes well.
>Below the generated form.
>Has anyone a hint or who knows which manpage/faq contains information
>about it.

Well, if the script is a CGI, it's no longer running once
the HTTP connection is terminated.

Remember, HTTP is a statelsss protocol -- it doesn't
return something to you and keep the connection open waiting
for your next response.

So, you'll need to write some sort of persistence into your
script, either by keeping track of previous data via cookies,
or in a server side data file, or encapsulated in the form
data (try hidden fields -- they work pretty well.)

I'm sure the fine folks in comp.infosystem.www.authoring.cgi
have something in their FAQ regarding this type of thing --
it's a fairly common thing to have to do. 

Good luck.

-tg

-- 
Tom Gerstel		tom.gerstel@turner.com
Senior Webmaster	tgerstel@world.std.com
CNN Interactive		http://cnn.com/
Bringing a world of news to the World Wide Web


------------------------------

Date: Fri, 23 Apr 1999 17:57:29 -0700
From: "Ours" <ours@casema.net>
Subject: CHAT engine wanted ($)
Message-Id: <7fq59m$drc$1@news.casema.net>

Featuring:

Frames->autoscroll/reload
Avatars
File xfer
Whispering
Multiple rooms
Every room it's own config (background, etc.)
Switching possible
Search user


Willing to pay for good results.

Anyone?

Mailme!




------------------------------

Date: 23 Apr 1999 09:44:45 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: combining multiple grep statements into one...
Message-Id: <3720956d@cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, syran@best.com (Jim Matzdorff) writes:
:I am wondering if there's a neat perl trick to combine multiple perl
:grep statements into one.  

The best way is to write a proper loop.

--tom
-- 
There are probably better ways to do that, but it would make the parser
more complex.  I do, occasionally, struggle feebly against complexity...  :-)
            --Larry Wall in <7886@jpl-devvax.JPL.NASA.GOV>


------------------------------

Date: Fri, 23 Apr 1999 15:03:56 GMT
From: gustavo9000@my-dejanews.com
Subject: Help understanding this script
Message-Id: <7fq24o$v3r$1@nnrp1.dejanews.com>

Hello

I need some help understanding the following lines in a HTML source code.

<p><!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">

Thanks
Gustavo Lopez

PS: It4s an ASP Container

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


------------------------------

Date: 23 Apr 1999 11:08:18 -0400
From: Mike.Wescott@ColumbiaSC.NCR.COM
Subject: Re: How to make an array name to be a variable?
Message-Id: <x4aevzwf19.fsf@wwest3m.i-did-not-set--mail-host-address--so-shoot-me>

David Cassell wrote:

> Tom Christiansen wrote:
>> I don't know why people are always thinking about this problem in a
>> broken way.  I really don't.  This question is asked every day
>> around here.  And no, I am not exaggerating.

> I only wish you were exaggerating.  But I have an idea.  This is how
> people write code in some other languages.  They don't know better.
> And they don't really know about hashes, because they haven't
> learned enough about them yet.

I think it's a bit more subtle than that. There are several mental
hurdles that one must jump before one becomes a competent
programmer. In this case, I think, it's the ability to concieve of,
and design a complex data structure and to use "unnamed" memory.

Fortunately, or perhaps unfortunately, Perl is expressive enough that
one can write some quite useful programs without that ability; stuff
that would not be possible in, for example, C.

What we're seeing here are people that have reached this hurdle in
their development as programmers and are balking. They've got a
problem that involves multiple instances of the same kind of data
structures in the program simultaneously. When it's a sequential
problem they just gave the data a name and processed it, then replaced
that data with new data, keeping the same name. Now they've got a
problem where they need an arbitrary number of "names" for the data
and that's how they see the problem: managing the name of the data
item. They haven't made the leap to thinking of aggregates as
components of other aggregates.

--
	Mike Wescott
	NCR Corp
	mike.wescott@columbiasc.ncr.com


------------------------------

Date: 23 Apr 1999 09:29:20 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: How to make an array name to be a variable?
Message-Id: <372091d0@cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, 
    Mike.Wescott@ColumbiaSC.NCR.COM writes:
:What we're seeing here are people that have reached this hurdle in
:their development as programmers and are balking. 

[deletia]

That was a very finely put article!  I think it shines light on 
the root of the problem.  Amendment proposals for the appropriate
FAQ welcome. :-)

--tom
-- 
    What I tell you three times is true.


------------------------------

Date: Fri, 23 Apr 1999 17:33:21 +0200
From: Olivier Maas <olivier.maas@at-lci.com>
Subject: How to receive a mail with Perl?
Message-Id: <372092C1.CD090910@at-lci.com>

Hello
I have a form, which, when submited, sends an email, I would like the
recipient of this email to email back and the verify the answer with a
perl script.

I know it is possible but I just miss the way to have the perl script
recieve the mailed back data... anybody out there who knows how or where
to get the necessary commands? (whatch the incoming mail and load it
into the adequate perl script.

Thanks for any help.

Olivier Maas
please also mail answers to : maas@ensae.fr



------------------------------

Date: Fri, 23 Apr 1999 17:11:23 +0200
From: William Blasius #42722 <Wm.Blasius@ks.sel.alcatel.de>
To: Moralis Athanasios <amoral@netmode.ntua.gr>
Subject: Re: I need help with pipes in perl!
Message-Id: <37208D9B.2781E494@ks.sel.alcatel.de>

[ a copy of this post was sent to Moralis Athanasios
<amoral@netmode.ntua.gr> ]
Moralis Athanasios wrote:
> 
> I have written this script :
> 
> #!/usr/local/bin/perl -w
> $| = 1;
> open T, "prog |" || die;
> select(STDOUT);
> $| = 1;
> while (<T>)
>  {
>         @fields=split(/ /,$_);
>         print "$fields[0] $fields[1]\n";
>  }
> close T;
> 
> However, the result of the script seems to be buffered. It appears in
> pages, as if it is waiting for some amount of data to be collected. When
> this amount is collected it is printed immediately in the STDOUT, then i
> halts printing until another amount of data is collected.
> 
> Does anyone know how I can overcome this problem and have unbuffered
> printing?

Maybe you can't..."prog" is doing the buffering, not your script. If you
can
coerce prog to operate unbuffered, great; otherwise not. You might try
using
an open(HANDLE, "|-") then setting the O_NDELAY flag explicitly before
doing
an exec to run prog. If prog inherits the fds and doesn't reset the
fcntl it
might work. See perlfaq 8.4.

hth

Wm Blasius
Stuttgart
-- 
* Failure is not an option! It comes bundled with your Microsoft
software *
 ...now I'm <wm.blasius@ks.sel.alcatel.de> - no matter what my Emailer
says!


------------------------------

Date: 23 Apr 1999 09:44:02 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Lockfile-Problem
Message-Id: <37209542@cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, pircher@informatik.tu-muenchen.de writes:
:What's the best solution fot the Lockfile-Problem?

The best solution is to learn how to use Perl's built-in
flock() function correctly.  Script kiddies can skate Cobol.

--tom
-- 
"Beware of the bugs in the above code; I have only proved it correct, not tried
 it." - Donald Knuth


------------------------------

Date: Fri, 23 Apr 1999 17:26:33 +0200
From: Staffan Liljas <staffan@ngb.se>
Subject: Re: NN? ['Nother Newbie Question]
Message-Id: <37209129.AB39E897@ngb.se>

Hi Mark!

Mark Stegemeyer wrote:
>  Step 1. Check the documentation. Did this.
>  Step 2. Check DejaNews. Did this.
>  Step 3. Repeat Steps 2 & 3. Did this.
>  Step 4. Check relavancy of post. Did this (I think).

You forgot:

   Step 5. Post some code. 

When you forget this, people start complaining about the ESP module
being in alpha. Are you, for instance, using the CGI.pm module in your
script?

Post some code, and you'll be helped.

Staffan
PS: If you're not using CGI, I think you should.


------------------------------

Date: Fri, 23 Apr 1999 09:54:30 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: Perl 'split' function in C??
Message-Id: <x3ypv4vtpbe.fsf@tigre.matrox.com>


hdiwan@diwanh.stu.rpi.edu () writes:

> In article <37218884.5540010@news.skynet.be>, Bart Lateur wrote:
> >Krusty276 wrote:
> >
> >>Does anyone have one, or know of a site that has the split funtion of Perl
> >>converted to C?   Sorry I'm just lazy, and wanna save sometime before I start
> >>working on this?
> It is possible to embed perl in C/C++. Perhaps someone more familiar with 
> the exact details can inform you better.

It would be a real waste of memory to embed the whole Perl interpreter
in a C program just to use the split() function. I would look at the
source code for split(), and steal some ideas.



------------------------------

Date: 23 Apr 1999 09:25:51 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Perl 'split' function in C??
Message-Id: <372090ff@cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, 
    Ala Qumsieh <aqumsieh@matrox.com> writes:
:It would be a real waste of memory to embed the whole Perl interpreter
:in a C program just to use the split() function. 

That's what libperl.so is for.

--tom
-- 
/* This bit of chicanery makes a unary function followed by
   a parenthesis into a function with one argument, highest precedence. */
        --Larry Wall in toke.c from the perl source code


------------------------------

Date: Fri, 23 Apr 1999 16:25:53 +0100
From: "Paul Mabley" <mableyp@logica.com>
Subject: Perl Debugger
Message-Id: <7fq3e7$r78@romeo.logica.co.uk>

Why can't I view the values of 'my' variables in the perl debugger?  My
understanding was that you simply entered X <var_name> at the prompt.
I have searched around for info on this problem but all I could find was a
brief mention of a bug in the perl5 debugger.  Is this a bug and, if it is,
is there a work-around?




------------------------------

Date: 23 Apr 1999 09:46:18 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Perl Debugger
Message-Id: <372095ca@cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, 
    "Paul Mabley" <mableyp@logica.com> writes:
:Why can't I view the values of 'my' variables in the perl debugger?  

Because you're doing it wrong.

:My
:understanding was that you simply entered X <var_name> at the prompt.

No, use 'x' not 'X'.

--tom
-- 
        "Every normal man must be tempted at times to spit on his
	 hands, hoist the black flag, and begin slitting throats."
					 --H.L. Mencken


------------------------------

Date: Fri, 23 Apr 1999 10:07:21 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: Please, HELP with uninitialized value error
Message-Id: <x3yogkftopz.fsf@tigre.matrox.com>


"Pieter Brouwer" <p.brouwer@prevalent.nl> writes:

> What happens in a.pls with respect to the mentioned filehandle is this:
> 
>   open DEFILE, "$file" || do {

This is wrong. The || binds more strongly than the comma, so your
snippet actually looks like:

	open (DEFILE, ("$file" || do { .... }));

which is definitely not what you want. Either use brackets to resolve
the uncertainty to the compiler, or you 'or' instead of '||'.

	oprn DEFILE, $file or do { ... }

>     print OUTFILE "kan file $file niet openen; skipping\n";
>     return;
>   };
> 
>   print OUTFILE "Scanning (1) file $file ...\n";

I take it that OUTFILE is properly open() for writing/appending.

>   while ( $regel = <DEFILE> ) {

depending on which version of Perl you're using, you might want to
change the above to:

	while (defined ($regel = <DEFILE>)) {

The reason is that if $regel reads a '0' or an empty string, the
while() loop will not execute since $regel will be false. For versions
> 5.004, an implicit defined() is placed for you.

>     $regelnummer = $.;
>     &checkLine($regel,$file,$regelnummer);
>   }
>   close DEFILE;
> 
> The linenumber of the error (360) has absoluteley nothing to do with
> <DEFILE>. It doesn't even have anything to do with the sub checkLine. It
> always gives me the error on the first line (with the defined-statement) in
> this sub:
> 
> # add_var
> sub add_var {
>   my $varnaam = shift;
> 
>   defined ($varlijst{$varnaam}) || ($varlijst{$varnaam} = 1);
> }

Is %varlijst a global hash?
You might also need to change the defined() to exists(). Judging from
the name of your sub, I would likely do it. Check out the
entries for defined() and exists() in perlfunc.

You might also want to add a print statement inside the add_var() sub,
just to check out the value of $varnaam.

> no matter how I tossle the subs's around. So I don't think there is a
> problem with ; or }-mismatches.
> 
> I must be overlooking something, but I have had enough staring at the code.
> Can somebody tell me what I am doing wrong?

HTH,
Ala



------------------------------

Date: 23 Apr 1999 09:13:46 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Problems with the connect function
Message-Id: <37208e2a@cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, John L Singleton <jsinglet@jaguar.ir.miami.edu>,
whose slightly-longer-than regulation signature is

:*-------------------------*--------------------------------------------*
:* John Lawrence Singleton *                singleto@ocala.cs.miami.edu *
:*  Computer Engineering   *               jsinglet@coeds.eng.miami.edu *
:*   University of Miami   *               jsinglet@jaguar.ir.miami.edu *
:*    (305)-689-9850       *                      johnsingleton@usa.net *
:*-------------------------*--------------------------------------------*

writes the following...

John, because it looks like you're a student, I'm going to criticize your
program as though it were an assignment turned in for a grade.  I'll
omit the grade, but leave the comments. :-)  Please take the following
harshness in a constructive fashion.  Think of it as "tough love",
hacker-style.  You're obviously trying to get this Perl and CGI and
HTML thing down, and you've made some serious mistakes I've
seen a hundred times in a hundred very poorly written mass-market books.
I'd like to take a chance to nip your bad habits in the bud.  Again,
please take this in the spirit it is meant.

--tom


:#!/usr/bin/perl
:&GetFormInput;

Rolling your own form cracker?  Please don't.  Use the standard CGI.pm,
because then you won't make all the mistakes that you've made.

:$username = $field{'username'} ;	 

Strange, I didn't see a use strict, a -w, or a $^W=1 anywhere.

:my($Server) = 'jaguar.ir.miami.edu'; 
:print "Content-type: text/html\n\n";
:print "<HTML>\n" ;

Is it really HTML?  I don't see a DOCTYPE or a DTD reference.
It sure doesn't look like proper HTML to me.

:print "<HEAD>\n" ;

Why do you have spaced before your semicolons?

:print "<TITLE></TITLE>\n" ;

That's a fascinating title.

:print "\n" ;

Why do you keep emitting newlines?

:print "</HEAD>\n" ;
:print "<BODY BGCOLOR=FFFFFF TEXT=000000 LINK=0000FF VLINK=800080>\n" ;

You forgot to quote those values.  This is not complaint.

Why do you change the color?  Don't you respect your users' choices?
I'm certainly glad that I have configured my htreader to ignore such
usurpations of my ability to make my own choices.

:print '<font face="Arial" size="2">Your selected user IS logged in. Below

Why do you change the font?  Don't you respect your users' choices?
I'm certainly glad that I have configured the web proxy I use to ignore
such usurpations of my ability to make my own choices.

I don't see <font> in the HTML 3.2 spec.  Where did

Why are you using CAPITAL LETTERS for strong/emphatic text?  Why
aren't you using the HTML tags that specify such?

:you have the option to '."\n" ;

Why the bizarre dot?  Why not a comma?  Why didn't you use double quotes
around the whole thing and single ones around the tags?  Why are you
emitting a newline?

:print "send them email or to send them an IM  (instant message) as they
:are logged in. The\n" ;

Why did you put a two newlines in your print, one from the wicked
word wrap that your word processing excuse for a program editor
introduced, the other which you placed yourself by saying \n.  Both
are irrelevant.

:print "IM will appear on their screen as they are working.\n" ;

Whoa!  Where's your <H1> tag?  How are we supposed to analyse your
structure?  Running this through the W3C validator, I get this
description of your outline:

    Outline

    Below is an outline for this document, automatically generated from
    the heading tags (<H1> through <H6>.)

    If this doesn't look like a real outline, it is likely that the
    heading tags are not being used properly. (Headings should reflect
    the logical structure of the document; they should not be used simply
    to add emphasis, or to change the font size.)

Ahem.

:print "\n" ;
:print "<br>\n" ;
:print "".$username."\n" ;

What is "" supposed to mean there?  What is "\n" supposed to mean there?
How is that different from:

    print $username;

:print "<br>\n" ;
:print "<HR>\n" ;
:print "<BR>\n" ;
:print "<BR>\n" ;

Two breaks?  What is that supposed to mean?  I'm trying to understand
the logical structure you're declaring here, and I don't understand what
two breaks could possibly mean.  Are you confusing a structure definition
with some pixel layout system?  HTML is not a pixel layout system.
Think of <BR> as an idempotent element.

I tested your code in four different htreaders without corrective proxies
enabled: lynx, arena, amaya, and netscape.  Of these, only the last one
paid any appreciable notice to your bizarre double break.  The rest
ignored you.  I bet you didn't mean to be ignored.

Maybe you mean <P> instead of <BR><BR>.  It's highly unclear.
Fortunately, the web proxy I use deletes meaningless mistakes of
repetitious redundancy that you've put in here more than once to no
particular purpose so it's no there more than once.

Perhaps you should be using <PRE> instead.  Or text/plain.

:print '<font face="Arial" size="+1">the UM IM via JSEND: (the im
:sender)</font>'."\n" ;

There you go changing fonts again.  How annoying!

:print "<BR>\n" ;
:print '<FORM  METHOD="GET"
:ACTION="http://www.getfreepress.com/cgi-bin/jaguar.pl">'."\n" ;

Why are you executing libraries?  Don't you mean to 

    ACTION="http://www.getfreepress.com/cgi-bin/jaguar">

Instead?  Did you know that .pl is used for libraries?  Did you
know that there's no reason to configure your web server to require
the wrong extension -- nor any extension whatsoever -- just to run
that?  Just put

    ScriptAlias /cgi-bin/ /home/httpd/cgi-bin/

Or whatever into your srm.conf file.  Then turn on the execute
bit on your program and you don't need that incorrect .pl at all.

:print 'Username : <INPUT TYPE="text" NAME="user"  SIZE="15" MAXLENGTH="30"
:> &nbsp Server Name: &nbsp <INPUT TYPE="text" NAME="mailServer"  SIZE="15"

Where is your semi-colon?  Shouldn't that be &nbsp; instead?  Don't
you think it's pretty sloppy to omit the admittedly optional terminating
semi-colon on an entity?

:MAXLENGTH="30" >'."\n" ;

Why do you put a space before the closing bracket?  Why do you
use a dot?  Why do you emit a newline?  Why do you put a space
before the semicolon?

:print " \n" ;
:print " \n" ;

Why do you have two newlines?  Don't you know they're ignored?  Why do you
spaces before those two newlines?  Don't you know they too are ignored?

:print " <BR>\n" ;
:print "<BR>\n" ;
:print "\n" ;
:print '	<CENTER><TEXTAREA  NAME="message"  ROWS="10"  COLS="50"
:></TEXTAREA></CENTER><br>'."\n" ;

<CENTER> was a mistake from a proprietary vendor with their
own agenda.  In the browsers I tested your code against,
half of them ignored you.  Why?  It's a bogus, deprecated tag.
http://www.w3.org/TR/REC-html40/present/graphics.html#edef-CENTER says
this about it:

    The CENTER element is exactly equivalent to specifying the DIV
    element with the align attribute set to "center".  The CENTER element
    is deprecated.

:print "	\n" ;

Wow, what are all those spaces?  Didn't you know that all stretches
of non-tag-quoted whitespace (tabs, linefeeds, spaces) collapse?

:print "\n" ;
:print "\n" ;
:print '<CENTER><INPUT TYPE="submit" NAME="submit" VALUE="submit">'."\n" ;
:print '	<INPUT TYPE="reset" VALUE="Clear My Work"></CENTER>'."\n" ;
:print "</FORM>\n" ;
:print "<br>\n" ;
:print "<br>\n" ;
:print "<BR>\n" ;
:print "<BR>\n" ;

Oh boy.  Four <BR> for the price of one.

:print '<FORM  METHOD="GET"
:ACTION="http://getfreepress.com/cgi-bin/emailer.pl">'."\n" ;
:print '<font face="Arial" size="+1">EMAIL JSEND: (the
:Web-emailer)</font><br>'."\n" ;
:print 'TO: &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp
:&nbsp<INPUT TYPE="text" NAME="email"  SIZE="25" MAXLENGTH="30" ><br>'."\n"

You know, you'd think you were trying to do pixel placement.  
That's wrong.  Instead of those many &nbsp; (de-semi-colon-ed) entities, 
you should be using a <PRE> or a <TABLE> or text/plain or some dumb
gif for the whole page.

:print 'From: &nbsp(optional)&nbsp<INPUT TYPE="text" NAME="from"  SIZE="25"
:MAXLENGTH="30" ><br>'."\n" ;
:print 'Sub: &nbsp(optional)&nbsp  &nbsp<INPUT TYPE="text" NAME="subject"
:SIZE="25" MAXLENGTH="30" ><br>'."\n" ;
:print "\n" ;
:print "<br>\n" ;
:print "<BR>\n" ;
:print '	<CENTER><TEXTAREA  NAME="emailtext"  ROWS="10"  COLS="50"
:></TEXTAREA></CENTER><br>'."\n" ;
:print "\n" ;
:print '<CENTER><INPUT TYPE="submit" NAME="submit" VALUE="submit">'."\n" ;
:print '	<INPUT TYPE="reset" VALUE="Clear My Work"></CENTER>'."\n" ;
:print "</FORM>\n" ;
:print "</font>\n" ;
:print "\n" ;
:print "</BODY>\n" ;

That's all pretty raunchy.  See above for why.  Now lets
go on to the code.

:sub GetFormInput {

Why are you doing this by hand?  It's wrong, you know.
Use the standard module and avoid your horrible mistakes.

:
:	(*fval) = @_ if @_ ;

Why are you assigning to a typeglob?  Why aren't you 
localizing it?  Why are you clobbering a global variable?

:	local ($buf);

Why are you snatching the global $buf variable?  Shouldn't
you be using a private variable? Did you know that local()
does not create a local variable?  Did you forget to use strict?

:	if ($ENV{'REQUEST_METHOD'} eq 'POST') {
:		read(STDIN,$buf,$ENV{'CONTENT_LENGTH'});

Hello?  What's the return value of read?  How do you know it
complete successfully?  

repeat { 
    ALWAYS CHECK THE RETURN VALUES OF YOUR SYSTEM CALLS.
    ALWAYS CHECK THE RETURN VALUES OF YOUR SYSTEM CALLS.
    ALWAYS CHECK THE RETURN VALUES OF YOUR SYSTEM CALLS.
} until clued();

:	}
:	else {
:		$buf=$ENV{'QUERY_STRING'};
:	}

Well, that's a crazy notion.  There are several other kinds of requests
than POST, you know.  Please check the spec.  At the very least, this
should react correctly to a HEAD.

:	if ($buf eq "") {
:			return 0 ;

Why are you returning 0?  Do you mean to return false?
Do you know what this does in list context?  Wouldn't
a simple "return;" work better?  Then again, why are you
returning anything -- you didn't bother to check the return
value.  You just kept barrelling through your program
irrespective of the return value.

:		}
:	else {
: 		@fval=split(/&/,$buf);
:		foreach $i (0 .. $#fval){
:			($name,$val)=split (/=/,$fval[$i],2);
:			$val=~tr/+/ /;
:			$val=~ s/%(..)/pack("c",hex($1))/ge;
:			$name=~tr/+/ /;
:			$name=~ s/%(..)/pack("c",hex($1))/ge;

Doesn't it bother you to see the same code twice in a row? 
Doesn't it bother you to see the same code twice in a row? 
It is difficult to imagine an instinct more important to the
programmer than that of seeing redundancy and combining these.

By the way, are you sure you want signed characters?

:
:			if (!defined($field{$name})) {

Or "unless(defined" if you want something that reads better.

:				$field{$name}=$val;
:			}
:			else {
:				$field{$name} .= ",$val";

What if you have commas in the data?  And can't you figure out a way to
combine that into one statement?

:				
:				#if you want multi-selects to goto into an
:array change to:
:				#$field{$name} .= "\0$val";

You're a pretty queer notion of an array.   I see no array there
whatsoever.  This is an array

    @fred

This is an element of a hash:

    $field{$name}

I see no array in what you're talking about.  And using ASCII NULs like
that is a pretty embarrassingly primitive alternative to the arrays
you allude to but never deliver on.

Here's a clue:

    push @{ $hash{"whatever"} }, $something;

In fact, your entire naughty code starting with the !defined crud
should of course just be:

    push @{ $field{$name} }, $val;

:			}
:		   }
:		}
:return 1;

Oh boy.  A return value.  Too bad you ignore it.

:}
:
:
:
:#finger protocol that works on jaguar
:
:use Socket;
:use strict;

Little late for that.  Put it at the top of your program.
:
:#for the example
:
:
:my($proto)      = getprotobyname("tcp")        || 6;

Or 6?  Or 6???  That's an evil magic number.
Don't do that.  And why is that in list context? 
Don't you must want the scalar context return value?

:my($port)       = 79;

79?  Or 79???  That's an evil magic number.  Don't do that.  Don't you
know what getservbyname() is for?

:my($serverAdd) = (gethostbyname($Server));

I'm so confused.  Why is the left-hand-side in list context?  Why did
you put parens around the right-hand side?  What happens if the
call fails?  Did you check it.

:socket(jacko, AF_INET(), SOCK_STREAM(), $proto)
:    or die("socket: $!");

That's an all-lower-case filehandle name.  Tsk tsk.
Didn't you use -w?  

:#my($packFormat) = 'S n a4 x8';   # Windows 95, SunOs 4.1+
:my($packFormat)= 'S n c4 x8';   # SunOs 5.4+ (Solaris 2)

Why is that in list context?  Why is that a hardcoded constant?
Why aren't you using the Socket::sockaddr_in() function?  Why
aren't you consulting $^O if you care?   Why are you setting
something up that sometimes takes 3 fields, and sometimes
takes 6 of them?

:#printf("I am COnnecting john\n\n\n");

Why are you using printf() when print() would suffice?  Did you
really mean to use stdout?  Shouldn't there be debug flags or
something?  Did you think about using stderr or syslog?

:connect(jacko, pack($packFormat,AF_INET(), $port, "\201\253\40\12"))
:   or die("connect: $!");

What is "\201\253\40\12"?  Don't you think you should be
using the return value $serverAdd above?  Also, you have
nastytasteincapitalizationofvariablenames.

:#printf("connected\n\n\n");
:
:my($inpBuf) = '';

Why is that in list context?

:#send(jacko,  "-i ",0);
:send(jacko,  "$username\r\n'",0 );

Say what?  send()?  Why are you using send?  Is this a UDP packet?
I think not.  Why aren't you using print()?  Why are you using the
incorrect \r\n?  Do you know what those mean?  Do you realize they
don't work everywhere?  Why aren't you using what the protocol requires?
You can use \cJ and likely get away with it, but you should probably be
using \cM\cJ to be pedantically correct.  You were just lucky this time.
It's not like \r\n is guaranteed to generate \cM\cJ you know.  I can 
show you systems where it doesn't.

Now, where's the check on the return value?  You made a system call.
It might have failed.  You need to check that.

:#read(jacko, $inpBuf,500);
:recv(jacko, $inpBuf, 100000, 0);

Huh?  More UDP-looking stuff?  What's this recv() thing?  Why aren't
you using readline (aka <>), read, or sysread?  And why are you asking
for so much data?  And where is the check of the return value?

:close(jacko);

And if that failed?  That's a function that's defined to return
a status indicating its success.  It's your job to check for this.
I've said that before.

:#printf("closed socket!\n\n");
:#print("$inpBuf\n\n");
:
:sub GetFormInput {

Gee, this again?  It was wrong before, and it's wrong again.
If you had bothered to use -w, you would have detected the
function redefinition.

Well, class, your call: what grade does this program deserve?

--tom
-- 
    "Oh, I'm totally outrageous--I just never seem to inspire any outrage.  :-)"
    	--Larry Wall


------------------------------

Date: Fri, 23 Apr 1999 08:03:48 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: regex: I see THAT it works, but I don't see WHY
Message-Id: <MPG.118a2ba65867e50c98991f@nntp.hpl.hp.com>

[Posted and a courtesy copy sent.]

In article <x74sm7bghp.fsf@home.sysarch.com> on 23 Apr 1999 09:42:26 -
0400, Uri Guttman <uri@sysarch.com> says...
> >>>>> "DG" == Daniel Grisinger <dgris@moiraine.dimensional.com> writes:
> 
>   DG> Uri Guttman <uri@sysarch.com> writes:
> 
>   DG> 5- The lazy ?
>   DG> ?.? ;                    # i'm done for the day
>   >> 
>   >> who really uses this (it is also deprecated)? 
> 
>   DG> I do.
> 
> why? it is deprecated, very obscure, and can be easily done with the
> regular m// (as the camel says, just break out of the loop). if i were
> to see m?? i might not even know what is is for a second. what benefit
> do you get from only matching the first time it is used before a call to
> reset? show some code where it actually is useful.

It is 'vaguely deprecated', whatever that means.  The doc warns that it 
may go away in the future, but we can all wink at that.  Never happen...

I have used it as a one-time-only switch which keeps its own state, 
rather than using a separate variable.  I'm not sure if I should be 
proud of this code, or just blush.  I agree that it is obscure.

$SIG{'__DIE__'}  = sub {       # Intercept fatal errors and report.
    1 =~ ?1? or exit;          # Prevent recursion from another fatal
    ...                        #   error while processing this error.
    exit;
}

If $_ is defiined, it can be written even more concisely:

    ?? or exit;

*Now* I'll blush.  :-)

-- 
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


------------------------------

Date: 23 Apr 1999 09:41:32 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: regex: I see THAT it works, but I don't see WHY
Message-Id: <372094ac@cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, 
    Uri Guttman <uri@sysarch.com> writes:
:  DG> 5- The lazy ?
:  DG> ?.? ;                    # i'm done for the day
:  >> who really uses this (it is also deprecated)? 

You're inventing deprecations.  The manpage says:

    This usage is vaguely deprecated, and may be removed in some
    future version of Perl.

Notice *vaguely*.  If it doesn't give warnings under -w, it's not 
at risk.  

    % grep -ci deprecat /usr/src/perl5.005_56/pod/perldiag.pod
    10

I suggest you look into those ten deprecations.  They're all there is.

:
:  DG> I do.
:
:why? it is deprecated, very obscure, and can be easily done with the

Just many people don't know something doesn't mean to throw it away.
It is extremely useful, because it saves useless state variables.
I use it a good bit.  And it's not going away any time soon, if I 
have anything to say about it -- which, I think, I do. :-)

It's phenomenally useful in things like

    ( ?^$? : $in_header : $in_body ) = 1;

A simple variant of which you'll see in perlop.  Notice also perlsyn
for emulating sed:

       Note that if there were a continue block on the above code, it
       would get executed even on discarded lines.  This is often used
       to reset line counters or ?pat? one-time matches.

           # inspired by :1,$g/fred/s//WILMA/
           while (<>) {
               ?(fred)?    && s//WILMA $1 WILMA/;
               ?(barney)?  && s//BETTY $1 BETTY/;
               ?(homer)?   && s//MARGE $1 MARGE/;
           } continue {
               print "$ARGV $.: $_";
               close ARGV  if eof();           # reset $.
               reset       if eof();           # reset ?pat?
           }

--tom
-- 
    X-Windows: The Cutting Edge of Obsolescence.
	--Jamie Zawinski


------------------------------

Date: Fri, 23 Apr 1999 15:14:10 GMT
From: pcluong@yahoo.com
Subject: removing rows from table (html tags)
Message-Id: <7fq2ns$vmd$1@nnrp1.dejanews.com>

# hi all,
# i have a text string..
  $_ = "<table>...\n<tr bgcolor=one>.keep-me.\n</tr>\n<tr>.remove-
me.\n</tr>\n</table>\n";

# i can remove the set of TR tags likes this..
  s{<tr\b.*?</tr>}{}s;
  print $_, "________\n";

# but how can i remove the last set??

# my best effort sofar..
  $_ = "<table>...\n<tr bgcolor=one>.keep-me.\n</tr>\n<tr>.remove-
me.\n</tr>\n</table>\n";
  @tr = m{<tr\b.*?</tr>}sg;  # grab rows
  s{$tr[$#tr-$i]}{}s;        # remove last row
  print $_, "________\n";

# thanQ for your helps!!!

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


------------------------------

Date: Fri, 23 Apr 1999 10:55:07 -0400 (EDT)
From: Mark Thomas <mthomas+posting@cs.cmu.edu>
Subject: Re: reset $. in one-liner
Message-Id: <14112.35275.58091.239065@ulysses.jprc.com>


Philip Newton <Philip.Newton@datenrevision.de> writes:
  > richard_chen@my-dejanews.com wrote:
  >> 
  >> I would like to insert a line at the beginning of
  >> many files. The following will not work
  >> 
  >> $ perl -pi -e 's|(.*)|#!/usr/bin/perl\n$1| if $.==1' *.pl

  > Error: -w not found anywhere before "\n" (see BUGS section in `perldoc
  > perl`).

  > Methinks your line would be more efficient if your bracketed regular
  > expression were (.) or even (^) instead of (.*):

There is no need to do any regular expression matching, just print the
shebang on the first line:

perl -pi -wle 'print q(#!/usr/bin/perl -w) if $.==1; close ARGV if eof' *.pl

If you process each *.pl file as one big chunk, you don't need to be
concerned with line counts at all:

perl -p0777i -we 'print qq(#!/usr/bin/perl -w\n)' *.pl

-Mark
--
http://www.ndim.edrc.cmu.edu/~mthomas/


------------------------------

Date: Fri, 23 Apr 1999 11:56:06 -0400
From: "Allan M. Due" <Allan@due.net>
Subject: Re: split help
Message-Id: <7fq4oo$pdm$1@nntp5.atl.mindspring.net>


RemarQ User wrote in message ...
:I have a tab delimited file and all the words are in quotes.I can split the
:words by using split(/\t, $_) but how can I get rid of the " around my
:words. I tried split(/"\t\"/, $_) but the very first word has one " to the
:left of it?
:


As long as there are no " in the text you want to keep:

@out=map{y/"//d;$_} split(/\t/,$in);

HTH

AmD

--
$email{'Allan M. Due'} = ' All@n.Due.net ';
--random quote --
Numbers are symbols for things; the number and the thing are not the same.
 - Ashley-Perry Statistical Axioms[1]





------------------------------

Date: Fri, 23 Apr 1999 23:16:34 +0800
From: Carfield Yim <carfield@polyu.hknet.com>
To: Thomas Eichberger <xsilly@java.at>
Subject: Re: The question about debug and design
Message-Id: <37208ED2.6C12CCB6@polyu.hknet.com>

what is the book name?

Thomas Eichberger wrote:

> Design: read the books from Peter Coad:-)
>
> Carfield Yim wrote:
>
> > I am a starter of programming,
> > I find I always have no idea how to design and I always debug by "try
> > and error"
> >
> > How can I train my design and debug skill?
>
> --    Thomas Eichberger
> --    Softwareentwicklung und Schulungen,
> --    Spezialisiert auf Java; Sun zertifizierter Java Trainer
> --    A-1230 Vienna, Austria (Europe), phone/fax: +43-01- 88 616 85
> --    http://www.java.at, e-mail: xsilly@java.at



------------------------------

Date: 23 Apr 1999 17:40:23 +0100
From: hals <haakon.alstadheim@sds.no>
Subject: Re: Unix files in MacPerl
Message-Id: <u3e1r1ea0.fsf@sds.no>

Jason Holland <jason.holland@dial.pipex.com> writes:
[snip]
> Thanks again, looks like I'll have to put aside some of the laziness and
> actually write a script to do it for me!
[snip]

Look at the CPAN.pm (module not site) that is used by MacPerl. Fairly
experimental still, but I seem to remember seeing som automagic for
converting text files after unpacking the tar.gz that it gets from
CPAN (the sites, not the perl module).


------------------------------

Date: 23 Apr 1999 15:19:31 GMT
From: hymie@lactose.smart.net (hymie!)
Subject: Re: yet another Abigail sig
Message-Id: <7fq323$rjd$1@news.smart.net>

In our last episode, the evil Dr. Lacto had captured our hero,
  snowhare@long-lake.nihongo.org (Benjamin Franz), who said:

>Irritate the NSA. Use modular exponentiation.

I work across the street from NSA -- literally.  I will do *nothing*
to irritate them.

(yet another random but appropriate sig)

 ..hymie!         http://www.smart.net/~hymowitz         hymie@lactose.smart.net
When troubles want to find me, I ain't hard to find. They know where I am.
                                                                   --Billy Joel


------------------------------

Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>


Administrivia:

Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing. 

]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body.  Majordomo will then send you instructions on how to confirm your
]subscription.  This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.

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 5464
**************************************

home help back first fref pref prev next nref lref last post