[10253] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3846 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Sep 28 21:07:57 1998

Date: Mon, 28 Sep 98 18:00:20 -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           Mon, 28 Sep 1998     Volume: 8 Number: 3846

Today's topics:
    Re: "select $variable" then print to it? <95ncp@eng.cam.ac.uk>
    Re: DBI/mysql <dpuryear@usa.net>
    Re: Input Separator Matching (Matt Knecht)
    Re: mod_perl woes (Jon Drukman)
    Re: Need help with $1 pattern melLA@west.net
    Re: need help with bar graph creation (Martien Verbruggen)
        open command and time out??? (Daniel Pray)
        Passing variable from form to form gclimb@my-dejanews.com
    Re: Passing variable from form to form <slug@labyrinth.net.au>
    Re: Passing variable from form to form <95ncp@eng.cam.ac.uk>
    Re: Passing variable from form to form (Rufus Xavier Sarsaparilla)
        Passing variable through forms gclimb@my-dejanews.com
    Re: Passing variable through forms (Alastair)
    Re: Perl and viruses <gellyfish@btinternet.com>
    Re: Shell Command...... <ludlow@us.ibm.com>
        Sockets and setsockopt with multicasting <jnichols@leland.stanford.edu>
    Re: STDIO redirection & child process <baliga@synopsys.com>
    Re: Unix & Perl Newbie Questions (Craig Berry)
    Re: Unix & Perl Newbie Questions (Abigail)
        What's wrong with this script? cpenter@earthlink.net
    Re: What's wrong with this script? <uri@camel.fastserv.com>
    Re: Where can I find a member() function? (Brian Kendig)
        Where to find Win32 Systems Admin scripts or docs? <kristina@greatbasin.net>
    Re: Where to put cgi-lib.pl (Wotan)
    Re: Win32 and OLE/ADO (Jan Dubois)
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: Mon, 28 Sep 1998 23:06:16 +0100
From: Nigel Parker <95ncp@eng.cam.ac.uk>
To: Larry Rosler <lr@hpl.hp.com>
Subject: Re: "select $variable" then print to it?
Message-Id: <Pine.HPP.3.96L.980928224643.19769A-100000@club.eng.cam.ac.uk>

[also posted to c.l.p.misc]

On Mon, 28 Sep 1998, Larry Rosler wrote:

: on Mon, 28 Sep 1998 21:04:30 +0100, Nigel Parker <95ncp@eng.cam.ac.uk> 
: says...
: > 
: > Does anyone know how I can select a variable and print to it?  Similar to
: > how you would "select STDOUT" or "select MAIL" then print to those.
: 
: $variable = sprintf $format, whatever...;


Thanks.  I've gone for the building up the string method similar to what
you suggested below.


: > I want to build up a big "$variable" then send it to my uucoding routine,
: > and then "print MAIL $uu_coded_variable".
: > 
: > I've taught myself perl in the last few weeks, so there may be an easy
: > solution which I've not come across!  There's a lot to be printed so
: > something like  $message = $message."Some more text.\n";  isn't really a
: > a very nice solution.
: 
:   $message .= "Some more text.\n";
: 
: is a bit nicer, and
: 
:   join "", $string1, $string2,  ...;
: 
: is nicer yet.

I've also just worked out that I can use here-document strings (I thought
they were only used with print <<... - until just now):

	sub return_message {
		$message .= <<"html_boundary";
			loads and loads of html
	html_boundary
		return $message;
	}


So now all I need to do is add:

	$message = &return_message;
	print STDOUT $message;
	print MAIL &mail_header;
	print MAIL &uu_code($message);

and I'll get one email and one http version of the document.

You wouldn't believe how long it's taken to sort this out... :-/  All
because my subroutines were printing stuff, rather than returning a string
to be printed!


Nigel
-- 
Girton College, Cambridge, England, CB3 0JG.             Tel: 0411 384803

http://welcome.to/nigels                             nigel.parker@iee.org



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

Date: Mon, 28 Sep 1998 17:25:53 -0500
From: Dustin Puryear <dpuryear@usa.net>
Subject: Re: DBI/mysql
Message-Id: <36100CF1.AA09CA6C@usa.net>

I just want to say I appreciate the responses I got for my DBI/SQL
question. All good answers, no flames. Uncommonly nice.

Regards, Dustin


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

Date: Mon, 28 Sep 1998 22:01:06 GMT
From: hex@voicenet.com (Matt Knecht)
Subject: Re: Input Separator Matching
Message-Id: <CGTP1.972$7Q6.6507612@news2.voicenet.com>

Jonathan Stowe <gellyfish@btinternet.com> wrote:
>if you start messing with $/ then you are effectively altering what Perl
>thinks of as being a line ...

You can always localize it:

$old_sep = $/;

{
    local $/ = 'something else';
}

print "old_sep and \$/ are equal\n" if $/ eq $old_sep;

-- 
Matt Knecht - <hex@voicenet.com>


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

Date: 28 Sep 1998 23:17:33 GMT
From: jsd@hudsucker.gamespot.com (Jon Drukman)
Subject: Re: mod_perl woes
Message-Id: <slrn7106dr.2g7.jsd@hudsucker.gamespot.com>

In article <6uonq7$5hm@bolt.sonic.net>, Peter Rowell wrote:
>I assume you know where and what your globals are and can simply
>create a routine call initialize_globals to be called each time
>you start a new transaction.  I find it easier to do this at the
>start of a transaction (rather than at the end) because of the
>way my brain is wired.  When creating this routine, it may dawn
>on you that "Damn!  I have a *lot* of globals!", which is a good
>learning experience in and of itself.

btw, while over-reliance on globals is usually a sign of sloppy
design... if you do find yourself with a ton, you might consider
putting them in a hash, so you can undef it with one statement instead 
of many.  (what is a namespace anyway but a hash?)

>This routine also would be a good place to reset any of perl's globals
>that you might have messed with.  For instance, $/ may have been set to
>a different input record separator half-way through the script, but you
>expected it to be the default value for the first half.  So remember to
>set these to their expected initial state.

and consider using the much-maligned local() command for its One True
Purpose: quick and dirty changing of Perl globals... ie:

{
  local $/="some wacky record separator";
  ... stuff with $/ ...
}
 ... at this point $/ is back to whatever it was before the block
started ...

with mod_perl i find use strict to be absolutely invaluable.  if your
program runs clean under strict, you are WAY ahead of the game.

-- 
Jon Drukman                                            jsd@gamespot.com
-----------------------------------------------------------------------
Fear the government that fears your computer.


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

Date: Tue, 29 Sep 1998 00:57:17 GMT
From: melLA@west.net
Subject: Re: Need help with $1 pattern
Message-Id: <3610301f.14493341@news.west.net>

kpreid@ibm.net (Kevin Reid) wrote:

><melLA@west.net> wrote:
>
>> I'd like to thank everyone who responded. I finally got the reg exp to
>> work, but... originally, 
>> $string =
>> "state=Alaska|county=Talkeetna|city=Anchorage|addr=0|zip=0|tel=0|";
>> 
>> The problem now is that my reg exp grabs not only the city name, but
>> everything else except the last pipe. How can I restrict the reg exp
>> to stop evaluating at the first pipe so that $1 does not include
>> almost everything to the end of the string?
>
>Change (.+) to ([^|]+). That forces it to match only non-| characters.
>(Note that a | is not special within a character class, and does not
>need to be escaped.)
>
>-- 
>  Kevin Reid.      |         Macintosh.
>   "I'm me."       |      Think different.

Thanks Kevin, it worked like a charm ;-)

Regards,
Milt
(remove all CAPS from my e-addr)


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

Date: Mon, 28 Sep 1998 23:42:59 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: need help with bar graph creation
Message-Id: <7aVP1.16$cs.121982@nsw.nnrp.telstra.net>

In article <360f328b.0@blushng.jps.net>,
	"Dexter Maxwell" <dexter@coolcounter.com> writes:

> The problem comes when I've got a value of "0" for one in the list.  It is
> not sorting it correctly.  I have also tried @Newbar = sort reverse @bar;
> But that didn't work either.

# perldoc -f sort
=item sort SUBNAME LIST

=item sort BLOCK LIST

=item sort LIST

Sorts the LIST and returns the sorted list value.  If SUBNAME or BLOCK
is omitted, sorts in standard string comparison order.
                              ^^^^^^
[snip]
    # sort numerically ascending
    @articles = sort {$a <=> $b} @files;
[snip]

You would really do yourself a favour if you learned how to use the 
documentation that comes with perl. Start with

# perldoc perldoc
# perldoc perl
# perldoc perltoc

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | Little girls, like butterflies, need no
Commercial Dynamics Pty. Ltd.       | excuse - Lazarus Long
NSW, Australia                      | 


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

Date: Mon, 28 Sep 1998 23:33:19 GMT
From: daniel@intecomp.com (Daniel Pray)
Subject: open command and time out???
Message-Id: <daniel-2809981634050001@usr1-dialup34.mix1.sacramento.cw.net>

Is there a way in the OPEN command to do one action if the file is
completely downloaded and something else if the file download times out or
the user stops downloading?  For example.

my $name  = "filexxxxx";
open(FILE, $name);
print "Content-Type: application/x-stuffit\n";
print "Location: $name\n\n";
close FILE;

open MAIL ...

I want to email myself one thing if the download is complete and another
thing if it is canceled or it times out.

Does any one have any ideas.


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

Date: Mon, 28 Sep 1998 22:55:45 GMT
From: gclimb@my-dejanews.com
Subject: Passing variable from form to form
Message-Id: <6up45h$def$1@nnrp1.dejanews.com>

I'm trying to learn CGI programming using perl, and I have a question
regarding forms. I want to build a site that requires multiple forms, and
wish to have some variables that were defined in one form passed to the next.
One example would be the persons name...by passing the variable I can use
their name to address them in each successive form. I've tried my best, but
can't seem to get it to work. Any help would be appreciated.

Mark

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


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

Date: Tue, 29 Sep 1998 09:33:15 +1000
From: Reiner <slug@labyrinth.net.au>
Subject: Re: Passing variable from form to form
Message-Id: <36101CBB.3F28EF33@labyrinth.net.au>

Once you get the user's name, print it back in subsequent forms as a hiddn field.
Each new request you will need to read the user name from the input.

print "<INPUT TYPE=\"HIDDEN\" NAME=\"user\" VALUE=\"$user\">";


gclimb@my-dejanews.com wrote:

> I'm trying to learn CGI programming using perl, and I have a question
> regarding forms. I want to build a site that requires multiple forms, and
> wish to have some variables that were defined in one form passed to the next.
> One example would be the persons name...by passing the variable I can use
> their name to address them in each successive form. I've tried my best, but
> can't seem to get it to work. Any help would be appreciated.
>
> Mark
>

--
Test your knowledge @
http://www.labyrinth.net.au/~slug/quizzes.htm




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

Date: Tue, 29 Sep 1998 00:35:20 +0100
From: Nigel Parker <95ncp@eng.cam.ac.uk>
To: gclimb@my-dejanews.com
Subject: Re: Passing variable from form to form
Message-Id: <Pine.HPP.3.96L.980929001649.21708A-100000@club.eng.cam.ac.uk>

On Mon, 28 Sep 1998 gclimb@my-dejanews.com wrote:

: I'm trying to learn CGI programming using perl, and I have a question
: regarding forms. I want to build a site that requires multiple forms, and
: wish to have some variables that were defined in one form passed to the next.
: One example would be the persons name...by passing the variable I can use
: their name to address them in each successive form. I've tried my best, but
: can't seem to get it to work. Any help would be appreciated.

The output from your script(s) will include new forms?  If so you simply
need to add lines such as...

 $phone_no = $previous_form{'phone_no'};
 print "<input type=\"hidden\" name=\"phone_no\" value=\"$phone_no\">';

You could, of course, just put the  $previous_form{'phone_no'}  part
directly into the print statement (I didn't, to try and make it clearer).

You could have a &print_hidden routine which does something like:

 if (defined $form{'name'}) {
  print "<input type=\"hidden\" name=\"name\" value=\"$form{'name'}\">";
 }

I believe that CGI.pm is good at retaining data, because if you use that
to create forms then any input fields you create will take the previously
entered value if defined. eg...

 new CGI;
 CGI->print_header;
 CGI->start_form;
 CGI->text_input(name="phone_no");
 etc...

Now *I think* that if the form which called the script had an input named
"phone_no" into which you entered "12345", then the new form (output by
the script) will automatically have the value "12345".

I personally don't like CGI.pm, but everyone else on the planet seems to
like it!

Cheers.


Nigel
-- 
Girton College, Cambridge, England, CB3 0JG.             Tel: 0411 384803

http://welcome.to/nigels                             nigel.parker@iee.org



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

Date: 28 Sep 1998 16:50:32 -0700
From: kirbyk@best.com (Rufus Xavier Sarsaparilla)
Subject: Re: Passing variable from form to form
Message-Id: <6up7c8$svv$1@shell2.ba.best.com>

In article <36101CBB.3F28EF33@labyrinth.net.au>,
Reiner  <slug@labyrinth.net.au> wrote:
>Once you get the user's name, print it back in subsequent forms as a hiddn field.
>Each new request you will need to read the user name from the input.
>
>print "<INPUT TYPE=\"HIDDEN\" NAME=\"user\" VALUE=\"$user\">";
>
>
A small code fragment I find useful:

foreach ($query->param()) {
	print $query->hidden(-name=>$_, -default=>$query->param($_)); }

This preserves all the cgi parameters nicely.  Be careful to remove any that
you don't want duplicated before you get to this spot - particularly
watch out for things you'll want to change, so they don't end up in getting
passed on twice, with the old and the new values.  But, this definitely
did the trick in my code.

-- 
Kirby Krueger      O-     kirbyk@best.com 
<*> "Most .sigs this small can't open their own jump gate."


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

Date: Mon, 28 Sep 1998 23:52:32 GMT
From: gclimb@my-dejanews.com
Subject: Passing variable through forms
Message-Id: <6up7g0$h2i$1@nnrp1.dejanews.com>

Hello,

I'm trying to design a site that uses multiple forms, each with a script
behind them. I'd like to be able to pass certain variables, for instance,
Name, from form to form. I've been trying very dilligently to get this
accomplished, but so far have only been able to pass the variable name. Any
help that can be provided would be very much appreciated.

Mark

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


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

Date: Tue, 29 Sep 1998 00:13:52 GMT
From: alastair@calliope.demon.co.uk (Alastair)
Subject: Re: Passing variable through forms
Message-Id: <slrn710d9i.4k.alastair@calliope.demon.co.uk>

gclimb@my-dejanews.com <gclimb@my-dejanews.com> wrote:
>Hello,
>
>I'm trying to design a site that uses multiple forms, each with a script
>behind them. I'd like to be able to pass certain variables, for instance,
>Name, from form to form.

No need to post this _twice_ (and with a different subject line). The CGI module
should help with this - read the docs (it has examples that do this) ;

http://stein.cshl.org/~lstein/

HTH.

-- 

Alastair
work  : alastair@psoft.co.uk
home  : alastair@calliope.demon.co.uk


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

Date: 28 Sep 1998 23:08:50 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: Perl and viruses
Message-Id: <6up4u2$1bj$1@gellyfish.btinternet.com>

On 28 Sep 1998 19:58:03 GMT Tom Christiansen <tchrist@mox.perl.com> wrote:
>  [courtesy cc of this posting sent to cited author via email]

> In comp.lang.perl.misc, Jonathan Stowe <gellyfish@btinternet.com> writes:
> :identifying virii 

> Pardon me, but just which declension would that be?  For noun plurals,
> I know several "-us" rules.  I know of "-us to -uses", "-us to -i",
<etc>
>                                                It follows from nothing
> I have ever read.

Er, yes you are absolutely correct of course. I suppose I could'nt blame
it on the "Typematic" could I :-?

That'll be Comprehensive education for you...

/J\
-- 
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>


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

Date: Mon, 28 Sep 1998 19:20:06 -0500
From: James Ludlow <ludlow@us.ibm.com>
Subject: Re: Shell Command......
Message-Id: <361027B6.ADA6782A@us.ibm.com>

sblenkhorn@my-dejanews.com wrote:
[snip]

"d:\\www\\rp\\cgi-bin\\documents\\".$dir_type."\\".$dir_name."\\".$file_name.
> "\\ *.*";
   ^^^^^^^

>         $testdir = "d:\\www\\rp\\cgi-bin\\out.txt";
                                           ^^^
You asked if there was any difference between the two.  One that jumps
out right away is the space that you have in the first example that
doesn't appear the second.

-- 
James Ludlow (ludlow@us.ibm.com)
Disclaimer: This isn't technical support, and all opinions are my own.


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

Date: Mon, 28 Sep 1998 16:46:45 -0700
From: Jonathan Nichols <jnichols@leland.stanford.edu>
Subject: Sockets and setsockopt with multicasting
Message-Id: <36101FE5.2AB8549B@leland.stanford.edu>

I currently have a C program that sets up a socket to read UDP packets
and I want to
write a PERL script that does the exact same thing.  The C program  does
this sequence of commands:

/******/
/* 0 */*sockfd_p = socket(AF_INET, SOCK_DGRAM, 0);  /* Open Socket */

/* 1 */mreq.imr_multiaddr.s_addr = inet_addr(IP_ADDR);
/* 2 */mreq.imr_interface.s_addr = htonl(INADDR_ANY);
/* 3 */setsockopt(*sockfd_p, IPPROTO_IP, IP_ADD_MEMBERSHIP, &mreq,
sizeof(mreq) );  /* Turn on multicast option */

/* 4 */bind(*sockfd_p, (struct sockaddr*)
&serveraddr_s,sizeof(serveraddr_s));
/* 4 */setsockopt(*sockfd_p, SOL_SOCKET, SO_REUSEPORT,&setreuse,
sizeof(setreuse));
/******/

I can replicate every command in PERL except for line /* 3 */.  The
structure mreq is of type ip_mreq
which is defined in in.h (On a DEC at least).  How do I create a
PERL object that contains the
same information as mreq so I can pass it into PERL's setsockopt
function?  Every permutation
I try gives me an ERRNO=22 (bad argument).  So, I'm obviously not
sending the right argument
to PERL's setsockopt.  And, if I leave out the setsockopt command, I
don't receive any data from
the socket.

Also, what is the best PERL reference for issues such as these?  The
camel book is not very informative.

Thanks, and please respond by email if possible.

jon




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

Date: Mon, 28 Sep 1998 17:48:18 -0700
From: Yogish Baliga <baliga@synopsys.com>
To: Stephen Elias <steven_elias@ml.com>
Subject: Re: STDIO redirection & child process
Message-Id: <36102E52.60D39AED@synopsys.com>

You can open the command as a file in perl and use read it to read the
output of
the command.

  for example:
       open FILE, "mycmd | ";
       <FILE> # This read the output of the command.

-- Baliga

Stephen Elias wrote:

> Hello,
>
> Is there a way to communicate with a child process via STDIN-STDOUT
> using perl.
>
> For instance
>
> system("mycmd") ;
>
> # mycmd is running, how do I pass it "commands" and read *it's* STDOUT
>
> Note this is different from
>
> @output = `mycmd` ;  # one shot deal
>
> thanks (using WIN32 Perl)





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

Date: 28 Sep 1998 23:14:21 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Unix & Perl Newbie Questions
Message-Id: <6up58d$gnc$1@marina.cinenet.net>

Dan Bialek (dan.bialek@mindspring.com) wrote:
: Hello. I am a Windows user who is interested in learning about the Unix
: OS and Perl programming.

Welcome, escapee from the Evil Empire! :)

: My two basic questions are(in several parts each):
: 
: 1. How do I get a copy Unix and what version should I use (e.g. Linux)

Linux is probably your best bet, simply because (a) it's good, and (b)
it's currently very hot, so support is easy to find.

:     And once I get this software, can I run it on a PC that also runs
: Windows 98, and if so how?

Dual-booting is usually the way.  Have two partions, one each for Linux
and 93, and use a boot manager to decide which way to go at boot time.

: 2. How and where do I write Perl programs and test them. Can I write
: them in Windows and
:     test them with some sort of compiler, or do I have to write them on
: a Unix system?

The perl interpreter is available in native binary form for Win32, only a
couple of revisions back from the current just-barely-released version.
Typically, you'd use a Windows programming-oriented text editor (e.g.,
Emacs, PFE, BBEdit) to write the code, then run it in a DOS box from the
command line.

: I apologize for the great deal of ignorance on my part for not knowing
: this type of information.

Never apologize about ignorance while you're trying to remove it. :)

: Any clear, concise answers would be very helpful.

Hope mine passed muster!

---------------------------------------------------------------------
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      "Ripple in still water, when there is no pebble tossed,
       nor wind to blow..."


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

Date: 28 Sep 1998 23:58:04 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Unix & Perl Newbie Questions
Message-Id: <6up7qc$7a9$1@client3.news.psi.net>

Dan Bialek (dan.bialek@mindspring.com) wrote on MDCCCLIV September
MCMXCIII in <URL:news:360FE947.FE39C211@mindspring.com>:
++ To whom it may concern,
++ 
++ Hello. I am a Windows user who is interested in learning about the Unix
++ OS and Perl programming.
++ 
++ My two basic questions are(in several parts each):
++ 
++ 1. How do I get a copy Unix and what version should I use (e.g. Linux)

Let's not answer this. There are many variants of Unices, all having
their advantages and disadvantages. First, make up your mind on what
you want to use Unix for, and how much you want to spend on hardware
and a license. Then you go out for shopping.

++     And once I get this software, can I run it on a PC that also runs
++ Windows 98, and if so
++     how?

Of course you can. Many Unices run on a wide range of platforms, including
the Intel and lookalike architectures.

++ 2. How and where do I write Perl programs and test them. Can I write
++ them in Windows and
++     test them with some sort of compiler, or do I have to write them on
++ a Unix system?

Yes. And once you've learned Perl, the details will become clear.

++ I apologize for the great deal of ignorance on my part for not knowing
++ this type of information.

That's what FAQs are for.

++ Any clear, concise answers would be very helpful.
++ 
++ I do not mind being referred to any of the numerous FAQ's found on the
++ Net. However,
++ more personal, plain-English answers from a human being would be much
++ greatly appreciated.

What makes you think FAQs aren't written in plain English? What do you
expect? Obfuscated Klingon with animated pictures sun raster graphics?



Abigail
-- 
sub f{sprintf$_[0],$_[1],$_[2]}print f('%c%s',74,f('%c%s',117,f('%c%s',115,f(
'%c%s',116,f('%c%s',32,f('%c%s',97,f('%c%s',0x6e,f('%c%s',111,f('%c%s',116,f(
'%c%s',104,f('%c%s',0x65,f('%c%s',114,f('%c%s',32,f('%c%s',80,f('%c%s',101,f(
'%c%s',114,f('%c%s',0x6c,f('%c%s',32,f('%c%s',0x48,f('%c%s',97,f('%c%s',99,f(
'%c%s',107,f('%c%s',101,f('%c%s',114,f('%c%s',10,)))))))))))))))))))))))))


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

Date: Mon, 28 Sep 1998 21:45:04 GMT
From: cpenter@earthlink.net
Subject: What's wrong with this script?
Message-Id: <6up010$90a$1@nnrp1.dejanews.com>

If anyone can help me with this CGI-Perl script I would really appreciate it I
can't get it to work thanks
<HTML>
  <HEAD>
  <TITLE> Pizza Snack Online Ordering</TITLE>
  </HEAD>
  <BODY BGCOLOR="beige">
  <!-- pizza.html -->
  <FORM ACTION="cgi-bin/pizza.pl" METHOD="GET">
  <H2>
  <CENTER>
  Welcome to Pizza Snack Online ordering!
  </CENTER>
  </H2><br>
  <H3>
  <P ALIGN=Center>
   Makin it Late and Helpin you Gain Weight!
  </H3>
  <P>
  <HR>
  May we have your name and number? <BR>
  Name:
  <INPUT TYPE="text" SIZE=50 NAME="name"><BR>
  Phone:
  <INPUT TYPE="text" SIZE=15 NAME="phone"><BR>
  <HR>
  Will this be takeout or delivery?
  <INPUT TYPE="radio" NAME="PickupORTakeout" VALUE="Takeout" CHECKED> Takeout
  <INPUT TYPE="radio" NAME="PickupORTakeout" VALUE="Delivery"> Delivery
  <HR>
  Select the type of crust:
  <INPUT TYPE="radio" NAME="crust" VALUE="Thin" CHECKED> Thin
  <INPUT TYPE="radio" NAME="crust" VALUE="Hand Tossed"> Hand tossed
  <INPUT TYPE="radio" NAME="crust" VALUE="Pan"> Pan
  <INPUT TYPE="radio" NAME="crust" VALUE="Sicilian"> Sicilian <BR>
  <HR>
  Choose one of our specialty pizzas:
  <SELECT NAME="specialty" Multiple Size = 4>
  <OPTION> Meat Lovers
  <OPTION> Cheese Lovers
  <OPTION> The Edge
  <OPTION SELECTED> Supreme
  <OPTION> Veggie Lovers
  <OPTION> Da Works </SELECT>
  <HR>
  Choose a size:
  <SELECT NAME="size">
  <OPTION> Small
  <OPTION> Medium
  <OPTION> Large
  <OPTION SELECTED> Jumbo </SELECT>
  <HR>
  What toppings would you like? <BR>
  Pepperoni:
  <INPUT TYPE="checkbox" NAME="Topping" VALUE="Pepperoni" CHECKED> Mushroom:
  <INPUT TYPE="checkbox" NAME="Topping" VALUE="Mushroom"> Green Onion:
  <INPUT TYPE="checkbox" NAME="Topping" VALUE="GreenOnion"> Onion:
  <INPUT TYPE="checkbox" NAME="Topping" VALUE="Onion">Pineapple
 <INPUT TYPE="checkbox" NAME="Topping" VALUE="Pineapple">
  <HR>
  <CENTER>
  <INPUT TYPE=SUBMIT VALUE="Submit Order">
  <INPUT TYPE=RESET VALUE="Clear">
 </CENTER>
</FORM>
</BODY></HTML>

   require "html.pl";
   $Title = "Thank you for your order!";
   $MaxData =6+;
   ($Name, $Phone, $Delivery, $Crust, $Type, $Toppings) =
          (0..5+);
   $Delivery = 1;
   @Crust = ("Thin", "Hand Tossed", "Pan", "Sicilian");
   @Type = ("Meat Lovers", "Cheese Lovers", "The Edge", "Supreme",
     "Veggie Lovers", "Da Works");
   @Size = ("Small", "Medium", "Large");
   @Toppings = ("Pepperoni", "Mushroom", "Green Onion", "Onion", "Pineapple"0;
   $DataLen = $ENV{'CONTENT_LENGTH'};
   read (STDIN, $QueryString, $DataLen);
   @NameValuePairs = split (/&/, $QueryString);
   $n = 0;
   foreach $NameValue (@NameValuePairs)
   {
   ($Name, $Value[$n1]) = split (/=/, $NameValue);
   $n++;
   }
   &HTML_Header ($Title);
   print "<BODY>\n";
   print "<H1>$Title</H1>\n";
   print "<HR>\n";
   print "<B>Thank You </B>"\n;
   print "<B>Phone $Phone[$Value[$Phone]]</B><BR><HR> ";

   print "<B>Crust $Crust[$Value[$Crust]]</B>><HR>";
   print "<B>Type $Type[$Value[$Type]]</B>";
   print "<B>Toppings $Toppings[$Value[$Toppings]]</B>";
   print "Your";
   if (!$Takeout)
   }
   print "order";
   }
   print " will be ready for pickup in 20 minutes;
   if (!$Delivery)
     }
   print "order";
   }
   print " will arrive in 30 minutes\n";
   &HTML_Ender;

   End Pizza.pl

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


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

Date: 28 Sep 1998 18:05:41 -0400
From: Uri Guttman <uri@camel.fastserv.com>
To: cpenter@earthlink.net
Subject: Re: What's wrong with this script?
Message-Id: <saryar3vqoa.fsf@camel.fastserv.com>


use CGI.pm will solve all the problems in your life, including class
assignments.

and it helps if you say what is not working with your program. but since
it looks like a class assignment i will leave the answer as an exercise
to the reader.

uri

-- 
Uri Guttman                  Fast Engines --  The Leader in Fast CGI Technology
uri@fastengines.com                                  http://www.fastengines.com


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

Date: 28 Sep 1998 16:33:07 -0700
From: fox-at-enchanter-net@SPAM.BLOCK (Brian Kendig)
Subject: Re: Where can I find a member() function?
Message-Id: <6up6bj$hag$1@shell11.ba.best.com>

Thank you all for your detailed solutions to the problem!

Just an FYI: I *did* search on numerous sources of information for the
answer, including the FAQ.  What tripped me up is that the Perl FAQ
manages to answer this question without once mentioning the word
"member", a feat which I didn't imagine possible.

-- 
 ____    |\/|                  Brian Kendig   
 \  /\   / ..__.       fox at enchanter net     You are in a maze of twisty
  \/  \__\   _/    http://www.enchanter.net/    little passages, all alike.
   \__   __  \_       Be insatiably curious.  
      \____\___\            Ask "why" a lot.  


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

Date: Mon, 28 Sep 1998 15:53:17 -0700
From: Kristina Harris <kristina@greatbasin.net>
Subject: Where to find Win32 Systems Admin scripts or docs?
Message-Id: <3610135D.3C5A@greatbasin.net>

Hi, all. After using Perl to do hundreds of things on Un*x-based
systems, I'd like to do the same with NT.  Unfortunately, I'm
having a hard time finding documentation on the Win32:: calls
in ActivePerl.  I've tried several FAQ's, archives, etc, to little
or no avail.  Any pointers to good docs for this?  I've got
adding users to the system, but would also like to find, say,
mapping a virtual domain in IIS, creating a virtual FTP directory
for a user, and other Internetly things.  Any ideas most appreciated...
Anything so I don't have to do 8-million mouse clicks in the GUI
to perform tasks that are easily scriptable in Un*x. :)

Kristina


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

Date: Mon, 28 Sep 1998 22:41:55 GMT
From: wotan@databasix.co (Wotan)
Subject: Re: Where to put cgi-lib.pl
Message-Id: <3623a9b9.866583120@nntpd.databasix.com>

For some reason on Fri, 25 Sep 1998 09:19:24 -0500, 
Eric Von Zee <evonzee@tritechnet.com> babbled:

>I'll answer each question in turn...
>
>Timmins wrote:
>
>> Looks to me like you're as confused as the other guy (note the 'two' above)
>> ... so answer the question: Where does this 'BEGIN' block go?
>
>At the head of his Perl script.  It's a way of blocking the initialization stuff at
>the beginning of the script.  Observe.
>
>#!/usr/lib/perl5
>
>BEGIN {
>   $| = 1;
>   push(@INC, 'some.directory');
>}
>
>print "Here goes rest of code.";
>
>
>> Why not justput the cgi-lib.pl file in the same directory as the perl script that
>> is
>> calling it, since the web server already knows where this file is at?
>
>Because he doesn't want to.  Besides, the web server has nothing to do with where
>Perl looks for an included script.  Perl looks for 'require'd files in the @INC
>array.  Exclusively.

I think you answered the two main questions of the thread with this
one line.  How to use cgi-lib.pl, and what this has to do with perl.
Since cgi-lib isn't the only item that someone might want to use in
this manner.

-- 
The best book on programming for the layman is 
"Alice in Wonderland"; but that's because it's 
the best book on anything for the layman.


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

Date: Tue, 29 Sep 1998 00:28:35 +0200
From: jan.dubois@ibm.net (Jan Dubois)
Subject: Re: Win32 and OLE/ADO
Message-Id: <361c0c9e.19050222@news2.ibm.net>

[mailed & posted]

John Warner <support@acuity.com> wrote:

>I've been searching through the FAQs and all the on-line
>documentation I can find but I haven't been able to locate
>any examples of using the Win32 OLE package with a
>database.  All the examples seem to be for working with
>Excel.  In particular, I interested in using OLE and ADO to
>retrieve user login information from a MS Access 97
>database.  I have installed the MS Data Access Components
>SDK and have been reading through their docs but they have
>limited examples for VB.  Does anybody have links to good
>on-line OLE DB documentation?

Here is one of my standard samples to use ADO from Perl. If you have further
questions, don't hesitate to ask them on the Perl-Win32-Database mailing
list (put ADO and/or OLE on the subject line!).

-Jan

use strict;
use Win32::OLE qw(in);

my $Conn = Win32::OLE->new("ADODB.Connection");
$Conn->Open("AdvWorks");
my $RS = $Conn->Execute("SELECT * FROM Orders");

until ($RS->EOF) {
    foreach my $Field (in $RS->Fields) {
	printf "%-20s: %s\n", $Field->Name, $Field->Value;
    }
    $RS->MoveNext;
    print "\n";
}
$RS->Close;
$Conn->Close;



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

Date: 12 Jul 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 Mar 98)
Message-Id: <null>


Administrivia:

Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.

If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu. 


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

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