Weekly list FAQ posting

2002-07-11 Thread casey

NAME
beginners-faq - FAQ for the beginners-cgi mailing list

1 -  Administriva
  1.1 - I'm not subscribed - how do I subscribe?

Send mail to [EMAIL PROTECTED]

You can also specify your subscription email address by sending email to
(assuming [EMAIL PROTECTED] is your email address):

[EMAIL PROTECTED].

  1.2 -  How do I unsubscribe?

Now, why would you want to do that? Send mail to
[EMAIL PROTECTED], and wait for a response. Once you
reply to the response, you'll be unsubscribed. If that doesn't work,
find the email address which you are subscribed from and send an email
like the following (let's assume your email is [EMAIL PROTECTED]):

[EMAIL PROTECTED]

  1.3 - There is too much traffic on this list. Is there a digest?

Yes. To subscribe to the digest version of this list send an email to:

[EMAIL PROTECTED]

To unsubscribe from the digest, send an email to:

[EMAIL PROTECTED]

  1.4 - Is there an archive on the web?

Yes, there is. It is located at:

http://archive.develooper.com/beginners-cgi%40perl.org/

  1.5 - How can I get this FAQ?

This document will be emailed to the list once a month, and will be
available online in the archives, and at http://beginners.perl.org/

  1.6 - I don't see something in the FAQ, how can I make a suggestion?

Send an email to [EMAIL PROTECTED] with your suggestion.

  1.7 - Is there a supporting website for this list?

Yes, there is. It is located at:

http://beginners.perl.org/

  1.8 - Who owns this list?  Who do I complain to?

Casey West owns the beginners-cgi list. You can contact him at
[EMAIL PROTECTED]

  1.9 - Who currently maintains the FAQ?

Kevin Meltzer, who can be reached at the email address (for FAQ
suggestions only) in question 1.6

  1.10 - Who will maintain peace and flow on the list?

Casey West, Kevin Meltzer and Ask Bjoern Hansen currently carry large,
yet padded, clue-sticks to maintain peace and order on the list. If you
are privately emailed by one of these folks for flaming, being
off-topic, etc... please listen to what they say. If you see a message
sent to the list by one of these people saying that a thread is closed,
do not continue to post to the list on that thread! If you do, you will
not only meet face to face with a XQJ-37 nuclear powered pansexual
roto-plooker, but you may also be taken off of the list. These people
simply want to make sure the list stays topical, and above-all, useful
to Perl/CGI beginners.

  1.11 - When was this FAQ last updated?

Sept 07, 2001

2 -  Questions about the 'beginners-cgi' list.
  2.1 - What is the list for?

A list for beginning Perl programmers to ask questions in a friendly
atmosphere. The topic of the list is, of course, CGI with Perl.

  2.2 - What is this list _not_ for?

* SPAM
* Homework
* Solicitation
* Things that aren't Perl related
* Non Perl/CGI questions or issues
* Lemurs
  2.3 - Are there any rules?

Yes. As with most communities, there are rules. Not many, and ones that
shouldn't need to be mentioned, but they are.

* Be nice
* No flaming
* Have fun
  2.4 - What topics are allowed on this list?

Basically, if it has to do with Perl/CGI , then it is allowed. If your
question has nothing at all to do with Perl/CGI, it will likely be
ignored.

  2.5 - I want to help, what should I do?

Subscribe to the list! If you see a question which you can give an
idiomatic and Good answer to, answer away! If you do not know the
answer, wait for someone to answer, and learn a little.

  2.6 - Is there anything I should keep in mind while answering?

We don't want to see 'RTFM'. That isn't very helpful. Instead, guide the
beginner to the place in the FM they should R :)

  2.7 - I don't want to post a question if it is in an FAQ. Where should I
look first?

Look in the FAQ! Get acquainted with the 'perldoc' utility, and use it.
It can save everyone time if you look in the Perl FAQs first, instead of
having a list of people refer you to the Perl FAQs :) You can learn
about 'perldoc' by typing:

perldoc perldoc

At your command prompt. You can also view documentation online at:

http://www.perldoc.com and http://www.perl.com

3 - Other Resources
  3.1 - What other websites may be useful to a beginner ?

* Perl Home Page - http://www.perl.com
* PerlMonks - http://www.perlmonks.org
* Perldoc - http://www.perldoc.com
* Perl Archives - http://www.perlarchives.com
  3.2 - What resources may be harmful to a beginner?

Beware of Perl4-like code-- You might find some script archives and
unauthorized mirrors with old Perl4 versions of Selena Sol and Matt
Wright scripts. Don't use those scripts. They are outdated and may even
in some cases contain bugs or security problems since many may not have
been updated in 

mail filters

2002-07-11 Thread David Gerler

Hi,
I am trying to setup mail filters on my domain that is on a virtual host.
I have a copy of TPJ #18 (Summer 2000) and have read the article about mail
filtering. The problem I am having is finding out where to put the .forward
or .qmail file to direct mail to my script. I have attempted to use find on
the server without any luck.
If anybody has any input. I would appreciate it.

David Gerler
Gerler Enterprises
PO BOX 16357
Chesapeake VA 23328
http://www.GerlerEnterprises.com/

Nationwide Dial-up from $12.45
http://www.EasySitesForLess.com/


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: mail filters

2002-07-11 Thread fliptop

David Gerler wrote:

 Hi,
   I am trying to setup mail filters on my domain that is on a virtual host.
   I have a copy of TPJ #18 (Summer 2000) and have read the article about mail
 filtering. The problem I am having is finding out where to put the .forward
 or .qmail file to direct mail to my script. I have attempted to use find on
 the server without any luck.


put it in your home directory.

for example, my login is fliptop, and my home directory is

/home/fliptop

so i'd create the file

/home/fliptop/.forward


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: Accessing Extra Information in die()

2002-07-11 Thread Camilo Gonzalez

Will $! suffice for you?

-Original Message-
From: John Pitchko [mailto:[EMAIL PROTECTED]]
Sent: Thursday, July 11, 2002 10:21 AM
To: [EMAIL PROTECTED]
Subject: Accessing Extra Information in die()


Hello,

I wrote a custom error message to be displayed in my CGI pages instead of
the standard die. It works fine, but I was wondering if there was a way I
could access all the special/extra information that is included in a die
message, such as line number and filename of the error.

Thanks,

John Pitchko
Data Services
Saskatchewan Government Insurance

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: Accessing Extra Information in die()

2002-07-11 Thread Nikola Janceski

why aren't you using:

use CGI::Carp 'fatalsToBrowser';



 -Original Message-
 From: Camilo Gonzalez [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, July 11, 2002 11:27 AM
 To: 'John Pitchko'; [EMAIL PROTECTED]
 Subject: RE: Accessing Extra Information in die()
 
 
 Will $! suffice for you?
 
 -Original Message-
 From: John Pitchko [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, July 11, 2002 10:21 AM
 To: [EMAIL PROTECTED]
 Subject: Accessing Extra Information in die()
 
 
 Hello,
 
 I wrote a custom error message to be displayed in my CGI 
 pages instead of
 the standard die. It works fine, but I was wondering if there 
 was a way I
 could access all the special/extra information that is 
 included in a die
 message, such as line number and filename of the error.
 
 Thanks,
 
 John Pitchko
 Data Services
 Saskatchewan Government Insurance
 
 -- 
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 



The views and opinions expressed in this email message are the sender's
own, and do not necessarily represent the views and opinions of Summit
Systems Inc.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Fw: What is this string type? How to play with?

2002-07-11 Thread Jonathan

What Connie is looking for is something that translates an ordinary string
to a urlencoded string,
I don't know what does that but I got around the problem myself by using
the modules:
LWP::UserAgent;
HTTP::Request::Common;

Jonathan


- Original Message -
From: [EMAIL PROTECTED]
To: Connie Chan [EMAIL PROTECTED]; [EMAIL PROTECTED];
[EMAIL PROTECTED]
Sent: Thursday, July 11, 2002 2:53 PM
Subject: Re: What is this string type? How to play with?


 Connie,
 Something like the following is probably what you are looking for.  Of
course what you should be
 doing is using CGI.pm or some other tested form of input retrieval.
 --
--
 my @variables = split(/[\\;]/, $input);
 foreach $variable (@variables) {
 next if ($variable !~ /\=/);

 my ($name, $value) = split(/\=/, $variable);

 $name =~ tr/+/ /;
 $name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack(C, hex($1))/eg;
 $value =~ tr/+/ /;
 $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack(C, hex($1))/eg;

 # assignment to some form of a variable structure that you will be
 # using out side this loop.  Keep in mind, you may have multiple
 # values for the same name.
 }
 --
--

 Regards,
 David



 - Original Message -
 From: Connie Chan [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
 Sent: Wednesday, July 10, 2002 4:21 PM
 Subject: What is this string type? How to play with?


 Hi all,

 With get method from form, we always see that the
 $ENV{QUERY_STRING} like this :
 message=%20%2F%15+..

 btw, what is the name of that string in types of ? Escape ? Unicode ?

 With simple tr/// and s///, I can get back what exact the input
 is, but, how can I make a the input back to the above format ?
 Totally have no idea...

 Rgds,
 Connie




 --
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: Accessing Extra Information in die()

2002-07-11 Thread John Pitchko

I am, but I created my own custom Error subroutine/module to display information 
instead of just calling the die() function and displaying a bunch of crazy technical 
information to the user. As for $!, it only passes the type of error and not the file 
and line numbers.

John Pitchko
Data Services
Saskatchewan Government Insurance

 Nikola Janceski [EMAIL PROTECTED] 07/11/02 09:34am 
why aren't you using:

use CGI::Carp 'fatalsToBrowser';



 -Original Message-
 From: Camilo Gonzalez [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, July 11, 2002 11:27 AM
 To: 'John Pitchko'; [EMAIL PROTECTED]
 Subject: RE: Accessing Extra Information in die()
 
 
 Will $! suffice for you?
 
 -Original Message-
 From: John Pitchko [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, July 11, 2002 10:21 AM
 To: [EMAIL PROTECTED]
 Subject: Accessing Extra Information in die()
 
 
 Hello,
 
 I wrote a custom error message to be displayed in my CGI 
 pages instead of
 the standard die. It works fine, but I was wondering if there 
 was a way I
 could access all the special/extra information that is 
 included in a die
 message, such as line number and filename of the error.
 
 Thanks,
 
 John Pitchko
 Data Services
 Saskatchewan Government Insurance
 
 -- 
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 



The views and opinions expressed in this email message are the sender's
own, and do not necessarily represent the views and opinions of Summit
Systems Inc.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: mail filters

2002-07-11 Thread fliptop

David Gerler wrote:

 
  Thanks. It seems to find it but it kills all mail delivery. This is
  what I am putting in the text file:
 
  |/home/gerleren/test.pl
 
 
  Where test is a test script copied from TPJ that should kill only
  specific email addresses (not the exact duplicate of TPJ chuckmail
  but based on it). Is that correct? The mail server is exim.

dunno.  i use procmail and sendmail.  here's what i put in my 
..procmailrc file:

:0:
*
| /home/fliptop/bin/filter.pl

this is off topic for a cgi mailing list, perhaps you should try another 
more appropriate list?  maybe [EMAIL PROTECTED]?


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: Accessing Extra Information in die()

2002-07-11 Thread Bob Showalter

 -Original Message-
 From: John Pitchko [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, July 11, 2002 12:42 PM
 To: [EMAIL PROTECTED]; [EMAIL PROTECTED];
 [EMAIL PROTECTED]
 Subject: RE: Accessing Extra Information in die()
 
 
 I am, but I created my own custom Error subroutine/module to 
 display information instead of just calling the die() 
 function and displaying a bunch of crazy technical 
 information to the user. As for $!, it only passes the type 
 of error and not the file and line numbers.

perldoc -f caller

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: mail filters

2002-07-11 Thread David Gerler

The following message was sent by fliptop [EMAIL PROTECTED] on Thu, 11 Jul 
2002 11:11:01 -0400.

 David Gerler wrote:
 
  Hi,
  I am trying to setup mail filters on my domain that is on a virtual host.
  I have a copy of TPJ #18 (Summer 2000) and have read the article about mail
  filtering. The problem I am having is finding out where to put the .forward
  or .qmail file to direct mail to my script. I have attempted to use find on
  the server without any luck.
 
 
 put it in your home directory.
 
 for example, my login is fliptop, and my home directory is
 
 /home/fliptop
 
 so i'd create the file
 
 /home/fliptop/.forward
 

Thanks. It seems to find it but it kills all mail delivery. This is what I am putting 
in the text file:

|/home/gerleren/test.pl 


Where test is a test script copied from TPJ that should kill only specific email 
addresses (not the exact duplicate of TPJ chuckmail but based on it). Is that correct? 
The mail server is exim.

Dave Gerler

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: What is this string type? How to play with?

2002-07-11 Thread Connie Chan

Hi David,

Hehe... Thanks in advice. Anyway what I am looking for is making
those stuff back to what they looks like when they come, that is,  the
$input in your script...

However, may I have some questions about your sample ? =)

 my @variables = split(/[\\;]/, $input);
; has no problem, why you would like to escape( \ )it ?

 next if ($variable !~ /\=/);
= also no problem , why you would like to escape it too ?
Besides, if you 'next' it if that $variable is not a name=value pair,
so is that mean this var will throw away ?

 $name =~ tr/+/ /;
 $name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack(C, hex($1))/eg;

Hmmm... what is this purpose ? $name is probrably going to be a
var's name, how come it goes with a blank ? and with an assumption
that the $name is coming as a URI escaped string ?

 .. Keep in mind, you may have multiple
 # values for the same name.

Just hard to imagine how come a request coming with same name.
Aren't we supposing the later come value with same name will overwrite
the first one ?

Maybe I am still new to Perl... so I'm try to write my script to handle a
form request
like this ? Would you and the list comment on me ? ( except telling me to
use CGI,
because I won't use it unless I have to deal with multipart form =))

my %data = undef;
my $input = undef;

($ENV{REQUEST_METHOD} eq POST) ?
{ read (STDIN, $input, $ENV{CONTENT_LENGTH)} :
{ $input = $ENV{QUERY_STRING}} ;

my @vars = split (/\/, $input);

for (@vars)
{ my ($name, $value) = split (/=/, $_);
$value=~ tr/+/ /;
$value=~ s/%([a-fA-F0-9][a-fA-F0-9])/pack(C, hex($1))/eg;
$data{$name} = $value;
}

Rgds,
Connie


 --
--
 my @variables = split(/[\\;]/, $input);
 foreach $variable (@variables) {
 next if ($variable !~ /\=/);

 my ($name, $value) = split(/\=/, $variable);

 $name =~ tr/+/ /;
 $name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack(C, hex($1))/eg;
 $value =~ tr/+/ /;
 $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack(C, hex($1))/eg;

 # assignment to some form of a variable structure that you will be
 # using out side this loop.  Keep in mind, you may have multiple
 # values for the same name.
 }
 --
--

 Regards,
 David



 - Original Message -
 From: Connie Chan [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
 Sent: Wednesday, July 10, 2002 4:21 PM
 Subject: What is this string type? How to play with?


 Hi all,

 With get method from form, we always see that the
 $ENV{QUERY_STRING} like this :
 message=%20%2F%15+..

 btw, what is the name of that string in types of ? Escape ? Unicode ?

 With simple tr/// and s///, I can get back what exact the input
 is, but, how can I make a the input back to the above format ?
 Totally have no idea...

 Rgds,
 Connie




 --
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: What is this string type? How to play with?

2002-07-11 Thread perl-dvd

Oops, let me make one small revision to my code:

if (exists($form_vars{$name})) { # if this is the first of this form input name.

should be

if (!exists($form_vars{$name})) { # if this is the first of this form input name.

Sorry about that all.

Regards,
David


- Original Message -
From: [EMAIL PROTECTED]
To: Connie Chan [EMAIL PROTECTED]; [EMAIL PROTECTED]; [EMAIL PROTECTED]
Sent: Thursday, July 11, 2002 11:53 AM
Subject: Re: What is this string type? How to play with?


Connie,

 ; has no problem, why you would like to escape( \ )it ?
I know that = and ; don't have a problem, I escape them because I escape every special 
character,
that way I don't have to worry about what I do and don't need to escape.  I know, bad 
habit (old
habits die hard).

 Besides, if you 'next' it if that $variable is not a name=value pair,
 so is that mean this var will throw away ?
This is a safety net incase somebody types in the url with something like this:
http://www.domain.com/test.cgi?namea=valueanamebnamec=valuec
You don't try to split on = when there's not an = in there.
Trust me, I've put a lot of thought into this code over the last 2 1/2 years.  I don't 
particularly
care for CGI.pm either (but we wont go into that), I wrote my own called Form.pm which 
I hope to get
up on CPAN one of these days.  It handles both GET and POST as well as command line 
parameters
(Along with post [MIME], I also accept files).  It also works on Linux and Windows.  
Its also much
faster than CGI.pm because its strait to the point, the only thing its intended to do 
is retrieve
data and give it in a useable format.

 Hmmm... what is this purpose ? $name is probably going to be a
 var's name, how come it goes with a blank ? and with an assumption
 that the $name is coming as a URI escaped string ?
Well that's exactly what we are doing, unescaping a URI, we just happen to split it 
into name and
value before unescaping it (this is important incase somebody has a %26 in their name 
or value).

 Just hard to imagine how come a request coming with same name.
 Aren't we supposing the later come value with same name will overwrite
 the first one ?
How about this instance:
http://www.domain.com/test.cgi?name=joeprefscheckbox=YesEmailMeprefscheckbox=YesPhoneMeprefscheck
box=YesSnailMailMe
This is a scenario when you want all of the multiple values with the same name, so you 
need to put
it into an array instead of a scalar.

I knew right from when you mentioned $ENV{'QUERY_STRING'} That you were intending to 
write a form
input parser.  Well if you are only going to use get, consider the following:


my @variables = split(/[\\;]/, $ENV{'QUERY_STRING'});
my %form_vars;
foreach $variable (@variables) {
next if ($variable !~ /\=/);
my ($name, $value) = split(/\=/, $variable);
$name =~ tr/+/ /;
$name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack(C, hex($1))/eg;
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack(C, hex($1))/eg;
if ($value ne ){ # remove this if statement if you want to keep pairs where the 
name has an
empty value
if (exists($form_vars{$name})) { # if this is the first of this form input 
name.
$form_vars{$name} = $value; # setting the variable the hash with the name 
to the value
} else { # for repeated times in with the same form input name
$form_vars{$name} = [($form_vars{$name})] if (ref($form_vars{$name} ne 
ARRAY)); # make
this an array if this its not one yet
push(@{$form_vars{$name}}, $value); # adding the next element to the list
}
}
}

This essentially gives you a hash with name value pairs for every single value 
names, and an
array ref for every name that has multiple values.  Basically, it gives you anything 
that was sent
(optionally even name empty value sets assuming you remove the if statement around the 
assignment
block).
Eventually when I get it on CPAN, it will be a simple as
use Form;
my %input = Form();

Anyway, good luck,
David




- Original Message -
From: Connie Chan [EMAIL PROTECTED]
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]; [EMAIL PROTECTED]
Sent: Thursday, July 11, 2002 10:59 AM
Subject: Re: What is this string type? How to play with?


Hi David,

Hehe... Thanks in advice. Anyway what I am looking for is making
those stuff back to what they looks like when they come, that is,  the
$input in your script...

However, may I have some questions about your sample ? =)

 my @variables = split(/[\\;]/, $input);
; has no problem, why you would like to escape( \ )it ?

 next if ($variable !~ /\=/);
= also no problem , why you would like to escape it too ?
Besides, if you 'next' it if that $variable is not a name=value pair,
so is that mean this var will throw away ?

 $name =~ tr/+/ /;
 $name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack(C, hex($1))/eg;


Re: What is this string type? How to play with?

2002-07-11 Thread perl-dvd

Sorry, one more oops

$form_vars{$name} = [($form_vars{$name})] if (ref($form_vars{$name} ne ARRAY));

should be

$form_vars{$name} = [($form_vars{$name})] if (ref($form_vars{$name}) ne ARRAY);

Sorry about these, there were a few recommendations I've received, and I had not 
implemented them in
my original copy before writing this post.  So I decided to implement the 
recommendations before I
sent it on to you guys.  couple of typo's.

That should be all of them though.

Regards,
David



- Original Message -
From: [EMAIL PROTECTED]
To: Connie Chan [EMAIL PROTECTED]; [EMAIL PROTECTED]; [EMAIL PROTECTED]
Sent: Thursday, July 11, 2002 11:53 AM
Subject: Re: What is this string type? How to play with?


Connie,

 ; has no problem, why you would like to escape( \ )it ?
I know that = and ; don't have a problem, I escape them because I escape every special 
character,
that way I don't have to worry about what I do and don't need to escape.  I know, bad 
habit (old
habits die hard).

 Besides, if you 'next' it if that $variable is not a name=value pair,
 so is that mean this var will throw away ?
This is a safety net incase somebody types in the url with something like this:
http://www.domain.com/test.cgi?namea=valueanamebnamec=valuec
You don't try to split on = when there's not an = in there.
Trust me, I've put a lot of thought into this code over the last 2 1/2 years.  I don't 
particularly
care for CGI.pm either (but we wont go into that), I wrote my own called Form.pm which 
I hope to get
up on CPAN one of these days.  It handles both GET and POST as well as command line 
parameters
(Along with post [MIME], I also accept files).  It also works on Linux and Windows.  
Its also much
faster than CGI.pm because its strait to the point, the only thing its intended to do 
is retrieve
data and give it in a useable format.

 Hmmm... what is this purpose ? $name is probably going to be a
 var's name, how come it goes with a blank ? and with an assumption
 that the $name is coming as a URI escaped string ?
Well that's exactly what we are doing, unescaping a URI, we just happen to split it 
into name and
value before unescaping it (this is important incase somebody has a %26 in their name 
or value).

 Just hard to imagine how come a request coming with same name.
 Aren't we supposing the later come value with same name will overwrite
 the first one ?
How about this instance:
http://www.domain.com/test.cgi?name=joeprefscheckbox=YesEmailMeprefscheckbox=YesPhoneMeprefscheck
box=YesSnailMailMe
This is a scenario when you want all of the multiple values with the same name, so you 
need to put
it into an array instead of a scalar.

I knew right from when you mentioned $ENV{'QUERY_STRING'} That you were intending to 
write a form
input parser.  Well if you are only going to use get, consider the following:


my @variables = split(/[\\;]/, $ENV{'QUERY_STRING'});
my %form_vars;
foreach $variable (@variables) {
next if ($variable !~ /\=/);
my ($name, $value) = split(/\=/, $variable);
$name =~ tr/+/ /;
$name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack(C, hex($1))/eg;
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack(C, hex($1))/eg;
if ($value ne ){ # remove this if statement if you want to keep pairs where the 
name has an
empty value
if (exists($form_vars{$name})) { # if this is the first of this form input 
name.
$form_vars{$name} = $value; # setting the variable the hash with the name 
to the value
} else { # for repeated times in with the same form input name
$form_vars{$name} = [($form_vars{$name})] if (ref($form_vars{$name} ne 
ARRAY)); # make
this an array if this its not one yet
push(@{$form_vars{$name}}, $value); # adding the next element to the list
}
}
}

This essentially gives you a hash with name value pairs for every single value 
names, and an
array ref for every name that has multiple values.  Basically, it gives you anything 
that was sent
(optionally even name empty value sets assuming you remove the if statement around the 
assignment
block).
Eventually when I get it on CPAN, it will be a simple as
use Form;
my %input = Form();

Anyway, good luck,
David




- Original Message -
From: Connie Chan [EMAIL PROTECTED]
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]; [EMAIL PROTECTED]
Sent: Thursday, July 11, 2002 10:59 AM
Subject: Re: What is this string type? How to play with?


Hi David,

Hehe... Thanks in advice. Anyway what I am looking for is making
those stuff back to what they looks like when they come, that is,  the
$input in your script...

However, may I have some questions about your sample ? =)

 my @variables = split(/[\\;]/, $input);
; has no problem, why you would like to escape( \ )it ?

 next if ($variable !~ /\=/);
= also no problem , why you would 

Executing cgi from perl script

2002-07-11 Thread McElwee, Shane

Hi,

I want to execute a cgi script from a perl script that first updates the cgi
script. The basic code I'm using to open and update the file is:


print Content-type: text/html\n\n;
open RESULT, template.cgi;
while (RESULT) {
s/Insert content here/$output/g;
print;
}
close RESULT;

The cgi file calls the header and footer for the application. When I run it
like this I get a web page with cgi code in the header and footer and the
correct content. How do I execute the cgi file after updating it? I'm on the
right track?

Thanks

Shane

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Less than a second?

2002-07-11 Thread Octavian Rasnita

Hi all,

I want to calculate how much time a Perl script runs.
Can you tell me how to calculate using fractions of a second?

The script may run in less than a second, but  Perl always tell me 1 second,
or 2 seconds, etc.

Thank you.

Teddy Center: http://teddy.fcc.ro/
Mail: [EMAIL PROTECTED]



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]