[15434] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2844 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Apr 22 21:05:25 2000

Date: Sat, 22 Apr 2000 18:05:10 -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: <956451910-v9-i2844@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Sat, 22 Apr 2000     Volume: 9 Number: 2844

Today's topics:
        A baby Perl question: Why/why is & optional in a subrou (Kenny McCormack)
    Re: A baby Perl question: Why/why is & optional in a su <uri@sysarch.com>
    Re: A baby Perl question: Why/why is & optional in a su (Kenny McCormack)
    Re: CGI-Cookies (Rafael Garcia-Suarez)
    Re: Converting HTML hex characters to characters <godzilla@stomp.stomp.tokyo>
    Re: Converting HTML hex characters to characters <tony_curtis32@yahoo.com>
    Re: Converting HTML hex characters to characters mongoose@wpi.edu
    Re: Converting HTML hex characters to characters <tony_curtis32@yahoo.com>
    Re: Converting HTML hex characters to characters <gellyfish@gellyfish.com>
    Re: Converting HTML hex characters to characters (Kragen Sitaker)
        Counting Form Submissions <kupernik@bcn.net>
    Re: Counting Form Submissions (Kragen Sitaker)
    Re: creating a =~ operator <gellyfish@gellyfish.com>
    Re: crypt() not working? gettyman@my-deja.com
        Date conversion <mikecook@dcranch.com>
    Re: Date conversion <tmp0001@unixsnedkeren.dk>
    Re: Date conversion <mikecook@dcranch.com>
        Date standardization without Date::Manip danrode@my-deja.com
        delaying page redirection?  <chris@aol.com>
    Re: emulate a browser <nomail@nomail.com>
    Re: Form to Html template sample code neede <msouth@fulcrum.org>
    Re: Form to Html template sample code neede <grassdan@hotmail.com>
    Re: GET <gellyfish@gellyfish.com>
    Re: ICQ client (Tony L. Svanstrom)
    Re: If Statement <lr@hpl.hp.com>
    Re: If Statement <gellyfish@gellyfish.com>
        Invoking perl program from other program dersein@my-deja.com
    Re: Make Test Error in GD.pm <yaqoota@emirates.net.ae>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: 22 Apr 2000 13:05:30 -0500
From: gazelle@yin.interaccess.com (Kenny McCormack)
Subject: A baby Perl question: Why/why is & optional in a subroutine call (and when is it required) ?
Message-Id: <8dspla$95q$1@yin.interaccess.com>

The "Novice goofs" section of the Camel book says that you should always use
the & to call a function/subroutine.  However, I generally leave it off and
it works OK.

Why/why is it optional and when is it required ?


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

Date: Sat, 22 Apr 2000 18:59:25 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: A baby Perl question: Why/why is & optional in a subroutine call (and when is it required) ?
Message-Id: <x7bt3255df.fsf@home.sysarch.com>

>>>>> "KM" == Kenny McCormack <gazelle@yin.interaccess.com> writes:

  KM> The "Novice goofs" section of the Camel book says that you should
  KM> always use the & to call a function/subroutine.  However, I
  KM> generally leave it off and it works OK.

which camel book, pink or blue?

  KM> Why/why is it optional and when is it required ?

in perl5 the & was made optional if it looks like a sub call with
parens. without parens it is a bareword and needs to be declared in
advance sothe compiler can parse it as a sub call.

in perl4 the only way to call a sub was with &. you can still use & in
perl5 for a bareword call like &foo but most prefer to do foo() these
days. so & is not needed except for some special cases (which i won't
cover as they are not newbie related).

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com


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

Date: 22 Apr 2000 19:13:08 -0500
From: gazelle@yin.interaccess.com (Kenny McCormack)
Subject: Re: A baby Perl question: Why/why is & optional in a subroutine call (and when is it required) ?
Message-Id: <8dtf6k$b9r$1@yin.interaccess.com>

In article <x7bt3255df.fsf@home.sysarch.com>,
Uri Guttman  <uri@sysarch.com> wrote:
 ...
>  KM> Why/why is it optional and when is it required ?
>
>in perl5 the & was made optional if it looks like a sub call with
>parens. without parens it is a bareword and needs to be declared in
>advance sothe compiler can parse it as a sub call.
>
>in perl4 the only way to call a sub was with &. you can still use & in
>perl5 for a bareword call like &foo but most prefer to do foo() these
>days. so & is not needed except for some special cases (which i won't
>cover as they are not newbie related).

Thanks for the info.  It makes sense.

I've only used Perl5.


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

Date: Fri, 21 Apr 2000 15:57:07 GMT
From: garcia_suarez@hotmail.com (Rafael Garcia-Suarez)
Subject: Re: CGI-Cookies
Message-Id: <390242d8$0$17676@personalnews.de.uu.net>

Mike Gleason Jr Couturier wrote in comp.lang.perl.misc:
>Hello all
>Is there an easy way to know if someone's browser has cookies
>disabled ? To do that, I'm currently setting a cookie, then if I can't
>retreive it immediately,  it means that the user disabled cookies...

Yes. That's the right way to do it. No other way is reliable. But don't
make too many assumptions on the client. Cookies may have been disabled
between two requests, or may expire, or the browser could have been
restarted, or someone is using telnet to speak to your cgi scripts and
confuse them... (by the way, this question is independent from perl.)

-- 
Rafael Garcia-Suarez


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

Date: Sat, 22 Apr 2000 12:23:18 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Converting HTML hex characters to characters
Message-Id: <3901FC26.B0A5ECD4@stomp.stomp.tokyo>

mongoose@wpi.edu wrote:
> 
> Ok one of my fields in an html forms 
> returns a string a users wrote, but if
> the user puts in chars like ! or ? it 
> just returns the hex number in   %3F or
> something similiar. How do I convert these 
> hex strings into characters? I thought 
> this should work but this only seems to 
> not work with the \x character

> $data =~ s/\%([0-9A-F]{2})/\x$1/g;


Stop using cgi.pm and write your own
read and parse routine which includes
code similar to this within your looping
mechanism to decode input variables from
your form action:

  $key =~ s/%(..)/pack("c",hex($1))/ge;
  $val =~ s/%(..)/pack("c",hex($1))/ge;


Your problems will vanish when you write
your own read and parse. Be sure to address
basic security issues once you rid your
script of cgi.pm. You will find your
script is more efficient and runs faster
by not using cgi.pm at all.

Again, address basic security issues
when you write your own read and parse.


Godzilla!



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

Date: 22 Apr 2000 14:55:12 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: Converting HTML hex characters to characters
Message-Id: <87d7nh9ahr.fsf@shleppie.uh.edu>

>> On Sat, 22 Apr 2000 01:41:27 -0500,
>> mongoose@wpi.edu said:

> Ok one of my fields in an html forms returns a string a
> users wrote, but if the user puts in chars like ! or ?
> it just returns the hex number in %3F or something
> similiar. How do I convert these hex strings into
> characters? I thought this should work but this only
> seems to not work with the \x character

> $data =~ s/\%([0-9A-F]{2})/\x$1/g;

This article is brought to you by the words "abstraction"
and "encapsulation".

perldoc CGI

The CGI.pm module does it all for you.

hth
t


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

Date: Sat, 22 Apr 2000 17:46:03 -0500
From: mongoose@wpi.edu
Subject: Re: Converting HTML hex characters to characters
Message-Id: <39022BAB.34E8DA2@wpi.edu>

"Godzilla!" wrote:
> 
> mongoose@wpi.edu wrote:
> >
> > Ok one of my fields in an html forms
> > returns a string a users wrote, but if
> > the user puts in chars like ! or ? it
> > just returns the hex number in   %3F or
> > something similiar. How do I convert these
> > hex strings into characters? I thought
> > this should work but this only seems to
> > not work with the \x character
> 
> Your problems will vanish when you write
> your own read and parse. Be sure to address
> basic security issues once you rid your
> script of cgi.pm. You will find your
> script is more efficient and runs faster
> by not using cgi.pm at all.
> 
> Again, address basic security issues
> when you write your own read and parse.

  I looked at CGI.pm and did some basic stuff with it. It seems kinda
pointless in alot of respects. Im just using template pages and am
parsing through them myself. Thats easy enough for me.


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

Date: 22 Apr 2000 17:43:42 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: Converting HTML hex characters to characters
Message-Id: <87ya657o4h.fsf@shleppie.uh.edu>

>> On Sat, 22 Apr 2000 17:46:03 -0500,
>> mongoose@wpi.edu said:

> "Godzilla!" wrote:
>>  mongoose@wpi.edu wrote: > > Ok one of my fields in an
>> html forms > returns a string a users wrote, but if >
>> the user puts in chars like ! or ? it > just returns
>> the hex number in %3F or > something similiar. How do I
>> convert these > hex strings into characters? I thought
>> > this should work but this only seems to > not work
>> with the \x character
>> 
>> Your problems will vanish when you write your own read
>> and parse. Be sure to address basic security issues
>> once you rid your script of cgi.pm. You will find your
>> script is more efficient and runs faster by not using
>> cgi.pm at all.
>> 
>> Again, address basic security issues when you write
>> your own read and parse.

>   I looked at CGI.pm and did some basic stuff with
> it. It seems kinda pointless in alot of respects. Im
> just using template pages and am parsing through them
> myself. Thats easy enough for me.

Well you know, CGI.pm has been a standard module for a
number of years.  While you are of course free to use
whatever method you want for handling CGI data, CGI.pm has
proven its worth as an abstracted and encapsulated method
of dealing with such data in a cross-platform way.  I'm
sure lots of people can tell you that this is so.  I'm
interested: *why* do you think it is "pointless in alot
[sic] of respects"?  Surely parsing data read in from
files in a program invoked through CGI is orthogonal to
parsing data passed through the CGI interface?

tony


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

Date: 22 Apr 2000 23:03:19 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Converting HTML hex characters to characters
Message-Id: <8dt7j7$p21$1@orpheus.gellyfish.com>

On Sat, 22 Apr 2000 12:23:18 -0700 Godzilla! wrote:
> mongoose@wpi.edu wrote:
>> 
>> Ok one of my fields in an html forms 
>> returns a string a users wrote, but if
>> the user puts in chars like ! or ? it 
>> just returns the hex number in   %3F or
>> something similiar. How do I convert these 
>> hex strings into characters? I thought 
>> this should work but this only seems to 
>> not work with the \x character
> 
>> $data =~ s/\%([0-9A-F]{2})/\x$1/g;
> 
> 
> Stop using cgi.pm and write your own
> read and parse routine which includes
> code similar to this within your looping
> mechanism to decode input variables from
> your form action:
> 
>   $key =~ s/%(..)/pack("c",hex($1))/ge;

Use CGI.pm  Even that said  the decoding code I presented is marginally 
faster :


#!/usr/bin/perl -w

use strict;
use Benchmark;

my $string = "This is a string with & ; + stuff in";

$string =~ s/([^a-zA-Z0-9])/sprintf "%%%02X",ord($1)/eg;


timethese 100000,
                {
                  Mine => sub {
                                my $destring = $string; 
                                $destring =~ s/%([0-9A-F]{2})/chr(hex($1))/ieg;
                               },
                  Its => sub  {
                                my $destring = $string; 
                                $destring =~ s/%(..)/pack("c",hex($1))/ge; 
                               }
                  }; 
  

[gellyfish@orpheus clpmtest]$ perl debench.pl
Benchmark: timing 100000 iterations of Its, Mine...
       Its: 12 wallclock secs (10.82 usr +  0.00 sys = 10.82 CPU) @ 9242.14/s (n=100000)
      Mine: 10 wallclock secs (10.13 usr +  0.00 sys = 10.13 CPU) @ 9871.67/s (n=100000)

Godzilla heh ! Gobshite more like.

Do not listen to the troll use CGI.pm where appropriate.

/J\
-- 
Please, please, kids, stop fighting. Maybe Lisa's right about America
being the land of opportunity, and maybe Adil's got a point about the
machinery of capitalism being oiled with the blood of the workers.
-- 
fortune oscar homer


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

Date: Sun, 23 Apr 2000 00:50:28 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Converting HTML hex characters to characters
Message-Id: <oNrM4.713$RM6.667366@news-east.usenetserver.com>

In article <3901FC26.B0A5ECD4@stomp.stomp.tokyo>,
Godzilla! <godzilla@stomp.stomp.tokyo> wrote:
>mongoose@wpi.edu wrote:
>> Ok one of my fields in an html forms 
>> returns a string a users wrote, but if
>> the user puts in chars like ! or ? it 
>> just returns the hex number in   %3F or
>> something similiar.
>
>Stop using cgi.pm and write your own
>read and parse routine 

Presumably if mongoose@wpi.edu is having this problem, you're not using
CGI.pm --- if you were using CGI.pm, the problem would not happen.  Use
CGI.pm.

Writing your own read and parse routine can be fun, but CGI.pm will
give you a program that works more reliably (unless you're infallible)
and is easier to write and maintain.

>You will find your
>script is more efficient and runs faster
>by not using cgi.pm at all.

That's true, but usually irrelevant.
-- 
<kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
The Internet stock bubble didn't burst on 1999-11-08.  Hurrah!
<URL:http://www.pobox.com/~kragen/bubble.html>
The power didn't go out on 2000-01-01 either.  :)


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

Date: Fri, 21 Apr 2000 11:14:47 -0400
From: "James M Kupernik" <kupernik@bcn.net>
Subject: Counting Form Submissions
Message-Id: <390242cd$0$17676@personalnews.de.uu.net>

I have to gather results from a new form. The only thing I need to know is
how many times the form is submitted. I already have the program processing
the information submitted by the visitor, now I just need to know how to
tell the program to keep a count of how many times people use the form. This
is most likely something simple, but I can't figure it out. Please help.




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

Date: Sun, 23 Apr 2000 00:41:39 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Counting Form Submissions
Message-Id: <7FrM4.668$RM6.567582@news-east.usenetserver.com>

In article <390242cd$0$17676@personalnews.de.uu.net>,
James M Kupernik <kupernik@bcn.net> wrote:
>I have to gather results from a new form. The only thing I need to know is
>how many times the form is submitted. I already have the program processing
>the information submitted by the visitor, now I just need to know how to
>tell the program to keep a count of how many times people use the form. This
>is most likely something simple, but I can't figure it out. Please help.

perldoc -q increment

(no, it's not an obvious keyword like "count" or "hits", that would be
too obvious)
-- 
<kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
The Internet stock bubble didn't burst on 1999-11-08.  Hurrah!
<URL:http://www.pobox.com/~kragen/bubble.html>
The power didn't go out on 2000-01-01 either.  :)


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

Date: 22 Apr 2000 21:21:09 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: creating a =~ operator
Message-Id: <8dt1jl$ob1$1@orpheus.gellyfish.com>

On Sat, 22 Apr 2000 09:12:36 -0700 Larry Rosler wrote:
> In article <Pine.LNX.4.20.0004221002470.2805-100000@ethyl.addictmud.org> 
> on Sat, 22 Apr 2000 14:57:59 GMT, dwb1@home.com <dwb1@home.com> says...
>> 
>> 
>> Is it possible to create a function that can be used with the =~ operator, or
>> maybe make use of some other operator?  so that for example, I could do
>> something like this:
>> 
>> $somevar =~ &function;
>> 
>> insetad of
>> 
>> $somevar = &function($somevar);
>> 
>> I'm assuming that it's not possible, but I figured I would ask anyways :)
> 
> #!/usr/bin/perl -w
> use strict;
> 
> sub regex { my $string = shift; qr{$string} }
> 
> 'foo' =~ regex($_) and print "Matched $_\n" for qw( foo f.o bar );
> 

Lawdy Laz just stop doing that alright.  I cant think on the best of
saturdays ;-}

/J\
-- 
Donuts. Is there anything they can't do?
-- 
fortune oscar homer


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

Date: Sun, 23 Apr 2000 00:48:50 GMT
From: gettyman@my-deja.com
Subject: Re: crypt() not working?
Message-Id: <8dth9f$9jg$1@nnrp1.deja.com>

  bart.lateur@skynet.be (Bart Lateur) wrote:
> It's a start. Where's the rest? It should either say
> "ERROR:" followed by the error message, or by the encrypted string,
> which is a longish "word" with "az" somewhere near the start. It looks
> like you get nothing ?!?! Not even an error?

There are a couple of blank lines at the end which would mean that crypt
() is returning NULL.


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Sat, 22 Apr 2000 15:21:44 -0700
From: "Michael Cook" <mikecook@dcranch.com>
Subject: Date conversion
Message-Id: <HBpM4.703$2J4.33614@news.uswest.net>

Hi folks,
    I'm sure this has been done & have searched the docs & perl.com but
can't find it. Any ideas on how to display a day 2 weeks from now (allowing
for end of month, different # of days in a month, etc.)?
        Thanks!
            Michael




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

Date: Sun, 23 Apr 2000 00:32:58 +0200
From: Thorbjoern Ravn Andersen <tmp0001@unixsnedkeren.dk>
Subject: Re: Date conversion
Message-Id: <3902289A.396661FD@unixsnedkeren.dk>

Michael Cook wrote:
> 
> Hi folks,
>     I'm sure this has been done & have searched the docs & perl.com but
> can't find it. Any ideas on how to display a day 2 weeks from now (allowing
> for end of month, different # of days in a month, etc.)?

Adapt the FAQ answer to "How do I find yesterday's date?" to work with
14 days instead.  You might find "perldoc -q date" helpful.

-- 
  Thorbjørn Ravn Andersen               "...plus...Tubular Bells!"
  http://www.mip.sdu.dk/~ravn


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

Date: Sat, 22 Apr 2000 16:01:38 -0700
From: "Michael Cook" <mikecook@dcranch.com>
Subject: Re: Date conversion
Message-Id: <iaqM4.871$2J4.35357@news.uswest.net>

This works perfectly - thanks!!!
    Michael

"Thorbjoern Ravn Andersen" <tmp0001@unixsnedkeren.dk> wrote in message
news:3902289A.396661FD@unixsnedkeren.dk...
> Michael Cook wrote:
> >
> > Hi folks,
> >     I'm sure this has been done & have searched the docs & perl.com but
> > can't find it. Any ideas on how to display a day 2 weeks from now
(allowing
> > for end of month, different # of days in a month, etc.)?
>
> Adapt the FAQ answer to "How do I find yesterday's date?" to work with
> 14 days instead.  You might find "perldoc -q date" helpful.
>
> --
>   Thorbjørn Ravn Andersen               "...plus...Tubular Bells!"
>   http://www.mip.sdu.dk/~ravn




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

Date: Sat, 22 Apr 2000 19:59:33 GMT
From: danrode@my-deja.com
Subject: Date standardization without Date::Manip
Message-Id: <8dt0av$nkq$1@nnrp1.deja.com>

I need to filter dates and store them in a comon format (likely epoch time).
The input could be one of several date formats. MM/DD/YY, MM/DD/YY HH:MM,
WDAY MON  MDAY HH:MM:SS YYYY, and a few others. For dates that lack HH:MM:SS,
I would like to use the current time or some standard time like "00:00:00" as
a "filler".

Date::Manip seems to be capable of dealing with much of the work, but it's
large size would cause performance problems. Has anyone done something
similar? Any suggestions?

-Dan Rode


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Fri, 21 Apr 2000 10:42:50 -0700
From: Chris <chris@aol.com>
Subject: delaying page redirection? 
Message-Id: <390242d4$0$17676@personalnews.de.uu.net>

i'm currently designing a sophisticated Chat Board. I want my script to
serve some tailored html, wait a few seconds, then move back to the main
page automatically. <meta... refresh url...> doesn't work of course.
Getting the script to print Location: $url doesn't either because the
script has already served html. I've tried putting;
sleep 5;
print "Location: $url";

in a separate script and executing that from by origional script, but
that doesn't work either. Is there any way it can be done? Is perl
magical enough?




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

Date: Sat, 22 Apr 2000 15:06:59 -0400
From: "Jonah" <nomail@nomail.com>
Subject: Re: emulate a browser
Message-Id: <8dt3l6$1d4u$1@onlink3.onlink.net>

> Jonah wrote:
> >
> > This was from an older thread. I want this new post to be up front,
> > hope this isn't the wrong thing to do, if it is let me know.
>
> Threading good.  Ignoring threading bad.  Tarzan no like ignoring
> threading.

should have read a faq on usenet, sorry.

>
> > Basically, all I want to do is emulate the same effect as calling the
> > mailing list
> > manager script directly from the form, but I still want the form to call
my
> > script first so I can do what I have to do.....
>
> I'm still lost.  Could you break this down into ordered steps.  What do
> you want the user to do, what do you want accomplished on the server (by
> what programs e.g. is the mailing list thingie a C program or what?) and
> then what do you want returned to the user?
>
> You've jumped to telling us you want to emulate a browser but it isn't
> at all clear from what you've described that that is the appropriate way
> to go.  Expalin (so we can understand) first what you want to
> accomplish, then we'll be able to comment on whether LWP is the way to
> go to do that.

ok, here goes.

And thanks for your help!

The mailing list script is just an example. It could be any program/script
that processes any form on any webpage on any server.

Could be a mailing list form, an order form, a refer a friend thing, etc.

Let's call it x script.

Let's say my script writes "hello dolly" to a database.

It's important that whenever a visitor fills out a mailing list form, or
fills out
an order form, or whatever, that my script writes "hello dolly" to a
database
before x script does whatever it would normally do if my script wasn't there
in
the first place.

I don't want my script to interfere with the normal operations of x script,
but I still
need to write "hello dolly"!

Seeing as how x script could be anything, I can't insert my code into x
script itself.

:LWP::UserAgent is perfect, it does exactly what I want.

But LWP returns the reponse, and I'm not sure if that would be ok if x
script
happen to be processing an order....

I hope that makes sense....

I just want to write data to a file before the form gets processed by x
script, without having
to interfere with the x script in any way.

>
> > read (STDIN, $content, $ENV{'CONTENT_LENGTH'});
> > &parseform;
>
> Eeeeeeeeeeeeeeeeeeew.  Tarzan really hate bad parse routines.  Throw
> that away and use CGI.pm.

Which is part of the standard perl right?

use CGI qw(:all); ?

(or whatever method I have to use)

I haven't looked into CGI.pm for forms, I see so
many scripts parse forms like in my example that I thought it
was ok.

That's the one thing I hate about perl, you never know if you're
doing something wrong. I guess I should buy the camel books,
or take CGI.pm more seriously, or both.

thanks again!






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

Date: Sat, 22 Apr 2000 14:48:11 -0500
From: Michal South <msouth@fulcrum.org>
Subject: Re: Form to Html template sample code neede
Message-Id: <390201FB.3E358BE0@fulcrum.org>

ELPHIDE wrote:
> 
> Hello,
> 
> Could anyone send me a sample perl code for the following usage :
> 
> Grab a value from a form and send it to a precise placeholder in a Html
> template.
> 


(sorry if this is a repost.)

Here's the HTML with the form:

    <html>
    <head>
      <title>
         Simple Template Example
      </title>
    </head>
    <body bgcolor="#ffffff" >
      <form method="post" action="/cgi-bin/clpm/fill_template.pl">
        How long did you try before posting to clpm?
        <p>
        <select name="how_long">
          <option value="0">What? Try _before_ posting?
          <option value="5">I, uh, well...
          <option value="60">Starting to tear my hair out
          <option value=">60">Little hair remaining
        </select>
        <p>
        <input type="submit" name="whatever" value="Fill Template">
      </form>
    </body>

Here's the Perl:

    #!/usr/bin/perl -w
    use CGI;
    use HTML::Template;

    use strict;

    $| = 1;

    my $q = new CGI;
    if ($q->param){
      print $q->header;

      my $filename = '../../data/templates/clpm/simple_template.htmlt';
      my $template= new HTML::Template ( filename=>$filename);

      $template->param('how_long', $q->param('how_long'));

      print $template->output;
    }
    else {
      print $q->redirect(
        'http://fulcrum.org/projects/clpm/fill_template.html');
    }

Here's the template:

    <html>
    <head>
      <title>
        Here's the output
      </title>
    </head>
    <body bgcolor="#ffffff" >
      Based on your answer, I'm guessing you tried for about
      <b><tmpl_var name="how_long"></b> minutes
      before posting your question.
    </body>
    </html>

If everything's configured right (HTML::Template is installed,
the Perl program is executable, things are in the indicated directories,
etc), it should work about like this:

    http://fulcrum.org/projects/clpm/fill_template.html

mike


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

Date: Sat, 22 Apr 2000 17:22:25 -0700
From: "Dan Grass" <grassdan@hotmail.com>
Subject: Re: Form to Html template sample code neede
Message-Id: <sg4ghkugl6e43@corp.supernews.com>

"Michal South" <msouth@fulcrum.org> wrote in message
news:390201FB.3E358BE0@fulcrum.org...
<snip>
> If everything's configured right (HTML::Template is installed,
> the Perl program is executable, things are in the indicated directories,
> etc), it should work about like this:
>
>     http://fulcrum.org/projects/clpm/fill_template.html
>
> mike
>
I like the link..
Dan




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

Date: 21 Apr 2000 15:39:16 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: GET
Message-Id: <390242cf$0$17676@personalnews.de.uu.net>

On Tue, 18 Apr 2000 18:12:11 -0500 Jim Gaasedelen wrote:
> "Alan J. Flavell" wrote:
>> 
>> On Tue, 18 Apr 2000, Jim Gaasedelen wrote:
>> 
>> > Go to www.perlarchive.com. There are two articles on forms and query
>> > strings.
>> > They are on the first page under "Learning Center."
>> 
>> Hmmm, that seems to get us to the usual cargo-cult hand-knitted
>> decoding stuff.
>> 
>> I'd say that anyone who needs to ask, would be better off being
>> pointed to CGI.pm.  Anyone who is determined to reinvent the wheel
>> should already have their own reasons for doing so, and not need any
>> answers from us.
>> 
>> At least you quoted upside-down.  Still seems a pretty reliable alert
>> mechanism.
>
> I still say you better know the basics first.
> 

Then they should look to the specification of the CGI and take it from
there.  Then they should use CGI.pm .

And you still quoted upside down.

/J\
-- 
Marge! Look at all this great stuff I found at the Marina. It was just
sitting in some guy's boat!
-- 
fortune oscar homer


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

Date: Fri, 21 Apr 2000 17:43:21 +0200
From: tony@svanstrom.com (Tony L. Svanstrom)
Subject: Re: ICQ client
Message-Id: <390242d3$0$17676@personalnews.de.uu.net>

Yaroslav F. Vishnevsky <rick@zt.energy.gov.ua> wrote:

>     Is there a possibility to write a ICQ client with perl?

It's been done.


     /Tony
-- 
     /\___/\ Who would you like to read your messages today? /\___/\
     \_@ @_/  Protect your privacy:  <http://www.pgpi.com/>  \_@ @_/
 --oOO-(_)-OOo---------------------------------------------oOO-(_)-OOo--
 DSS: 0x9363F1DB, Fp: 6EA2 618F 6D21 91D3 2D82  78A6 647F F247 9363 F1DB
 ---ôôô---ôôô-----------------------------------------------ôôô---ôôô---
    \O/   \O/  ©1999  <http://www.svanstrom.com/?ref=news>  \O/   \O/


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

Date: Sat, 22 Apr 2000 12:16:24 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: If Statement
Message-Id: <MPG.136b9a5e5501472a98a95d@nntp.hpl.hp.com>

In article <3901E097.86504A3E@stomp.stomp.tokyo> on Sat, 22 Apr 2000 
10:25:43 -0700, Godzilla! <godzilla@stomp.stomp.tokyo> says...
> Anne Smith wrote:
> 
> > I am trying to validate a text field whether a 
> > user has entered any data or not.

 ...

> You have problem somewhere but it is not with
> this syntax you are using unless cgi.pm has 
> a bug when using this syntax of yours. Perhaps
> consider dumping cgi.pm and writing your own
> read and parse routine to handle this correctly.

Nonsense.  Use the CGI module, which is distributed with every modern 
version of Perl.

 ...

> #!/usr/local/bin/perl

No '-w', no 'use strict;'

> &Parse;
> 
> sub Parse
>  { # Parse #
>   local (*in) = @_ if @_;

Grotesque.

>   local ($i, $key, $val);

my(), not local().

>   read(STDIN,$in,$ENV{'CONTENT_LENGTH'});

Needs check on number of bytes actually read.

>   @in = split(/&/,$in);
>   foreach $i (0 .. $#in)
>    {
>     $in[$i] =~ s/\+/ /g;

Should be tr/+/ /;

>     ($key, $val) = split(/=/,$in[$i],2);
>     ($val eq "") && next;

An empty string should be stored as such, not discarded.

>     $key =~ s/%(..)/pack("c",hex($1))/ge;
>     $val =~ s/%(..)/pack("c",hex($1))/ge;
>     $in{$key} .= $val;

Multiple values get concatenated without a separator!

>    }
>   return 1;
>  } # Parse #
> 
> print "Content-Type: text/html\n\n";
> 
> $test = $in{Test};
> $user_input = $in{User_Input};
> 
> print
>  "<HTML><HEAD><TITLE>TEST USER INPUT</TITLE></HEAD><BODY>
>   <CENTER><HR><BR><U>TEST USER INPUT</U><P><P>
>   <FORM METHOD=\"POST\" ACTION=\"test.cgi\">
>   <INPUT TYPE=\"submit\" NAME=\"Button\" VALUE=\"Test User Input\">
>   <INPUT TYPE=\"hidden\" NAME=\"Test\" VALUE=\"test\">
>   <INPUT TYPE=\"text\" SIZE = \"20\" MAXLENGTH=\"20\"
>    NAME=\"User_Input\" VALUE=\"\">
>   </FORM></CENTER><P>";

You should use a here-document or alternate quotes or simply single-
quotes to avoid those ugly and unreadable backslashes.

> if ($test)
>  {
>   if ($user_input eq "")
>    { print "<P> No User Input <P>"; }
>   if ($user_input ne "")
>    { print "<P> $user_input <P>"; }
>  }

The above would draw warnings about using undefined variables.

All of the parsing code reduces to this:

    use CGI;
    my $test = param('Test');
    my $user_input = param('User_Input');

> print "</BODY></HTML>";
> 
> exit;

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


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

Date: 22 Apr 2000 22:09:49 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: If Statement
Message-Id: <8dt4et$oj7$1@orpheus.gellyfish.com>

On Sat, 22 Apr 2000 12:16:24 -0700 Larry Rosler wrote:
>
> All of the parsing code reduces to this:
> 
>     use CGI;

use CGI qw(:standard);

;-}

>     my $test = param('Test');
>     my $user_input = param('User_Input');
> 

/J\
-- 
I am so smart, I am so smart, s-m-r-t....I mean s-m-A-r-t.
-- 
fortune oscar homer


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

Date: Fri, 21 Apr 2000 15:31:36 GMT
From: dersein@my-deja.com
Subject: Invoking perl program from other program
Message-Id: <390242d2$0$17676@personalnews.de.uu.net>

Hi,
I am using perl for primarily parsing purposes.  However, I have to do
it consequtively.  Perl takes a lot of memory if I useinfinite loop.

Should I use C or Java to invoke the perl program?

Are there any problems for this?

Thanks,


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Sun, 23 Apr 2000 00:48:11 +0400
From: "Quaid Joher" <yaqoota@emirates.net.ae>
Subject: Re: Make Test Error in GD.pm
Message-Id: <8dt335$hem1@news.emirates.net.ae>

Dear Elaine,

Can you kindly explain me in more detail on your comments to my earlier
message.  I have a conflicting views in my mind and I can not decide what
should be done :{

QUAID

Elaine Ashton <elaine@chaos.wustl.edu> wrote in message
news:B5275438.2CBF%elaine@chaos.wustl.edu...
> in article 8dshaj$r8k2@news.emirates.net.ae, Quaid Joher at
> yaqoota@emirates.net.ae quoth:
> > With 'make test' I received following message;
> >
> > bash-2.01$ make test
> > PERL_DL_NONLAZY=1
> > /usr/bin/perl -Iblib/arch -Iblib/lib -I/usr/local/lib/perl5/5.
> > 00502/i386-freebsd -I/usr/local/lib/perl5/5.00502 -e 'use Test::Harness
> > qw(&runt
>
> I don't use freebsd but the error message looks a lot like the one I see
on
> Solaris. Lincoln has provided a patch script with the distribution that
you
> will need to apply to a fresh source copy of GD [not the module, the lib]
> then build and install it...then rebuild GD the module.
>
> Try that and let us know if that doesn't work.
>
> e.
>




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

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


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