RE: Uploading Help

2002-06-18 Thread Scot Robnett

Unless you run your own server, this may not work because the web host may
not have decided to update their version of Perl or CGI.pm yet.

For instance, my hosting service is still using Perl 5.005_03 with CGI.pm
version 2.46. So I tried the preferred upload method with no success. The
previous method for reading uploaded files might have been slightly
convoluted, but it still works...

Scot Robnett
inSite Internet Solutions
[EMAIL PROTECTED]
http://www.insiteful.tv

"There are only two things in life,
 but I forget what they are." - John Hiatt
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.370 / Virus Database: 205 - Release Date: 6/5/2002


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




Re: Uploading Help

2002-06-18 Thread John Brooking

--- Ovid <[EMAIL PROTECTED]> wrote:
> --- Janek Schleicher <[EMAIL PROTECTED]> wrote:
> > I'm also not an expert of uploading files.
> > But you do two things to read the file:
> > 
> > $file = $q->param("file$i");
> > Now $file contains a string.
> > 
> > Then you use something like
> > my $uploaded = <$file>;
> > 
> > So now you use $file as a Filehandle,
> > but in fact it's still a simple stupid string.
> 
> It would seem that way, but this is not the case. 
> From the CGI.pm documentation:
> 
> When the form is processed, you can retrieve the
> entered filename
> by calling param(): 
> 
>$filename = $query->param('uploaded_file');
>
> [snip]
> 
> The filename returned is also a file handle. You
> can read the 
> contents of the file using standard Perl file
> reading calls: 
> 

In fact, there is now another way! According to _CGI
Programming with Perl_ ("The Rat Book"?), 2nd Edition,
Chapter 5, you can also get the file handle via the
new "upload" method, passing it the filename
parameter. From page 99:

  "The upload method was added to CGI.pm in Version
2.47. Prior to that, you could use the value returned
by 'param' as a file handle in order to read from the
file. This actually still works, but there are
conflicts with strict mode and other problems, so
'upload' is the preferred way to get a file handle
now."

- John


=
"Now it's over, I'm dead, and I haven't done anything that I want; or, I'm still 
alive, and there's nothing I want to do." - They Might Be Giants, http://www.tmbg.com

__
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com

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




Re: refreshing problem

2002-06-18 Thread John Brooking

Okay, I gotcha. The same script generates the form
everytime. If it has some parameters, it processes
them first, then regardless, it draws the form for the
next time.

I think the browser is "working as intended". No
matter what the current URL is, the "Refresh" button
simply re-requests it, including any parameters that
were included in the last request. That's just how it
works. I've seen this lots of times with my own stuff.

I think what you need to do is separate your form and
your processing script. You should be able to still
have the form page be a script of some sort, in case
there is any data lookups and so forth to be done, but
if it can be plain HTML and maybe a little client-side
Javascript, all the better. Have the form call the
script, which now does only the processing but no
output, then have the script redirect back to the form
page at the end. Then the "Refresh" button will repeat
the request to show the form page only, and not the
entire processing script.

Hope this helps!

- John

--- spider man <[EMAIL PROTECTED]> wrote:
> 
>  The redirection to itself actually works. I wonder
> if there are any flaws in this process. It seems to
> be more of a work around instead of an actual
> correct way of doing things. What do you think?
>   spider man <[EMAIL PROTECTED]> wrote: 
> My script has HTML code generated at the at the
> file. There is an "if" condition on the param()
> values at the beginning for processing. Regardless
> of the "if" condition, the code to generate HTML
> code is executed at the end. So the form is
> http:////form.pl and when you submit the
> form it doesn't redirect and run the same script
> again for the HTML. So you will see
> http://.../.../form.pl again. Would redirect to
> another URL and then back to the script form do the
> trick?


=
"Now it's over, I'm dead, and I haven't done anything that I want; or, I'm still 
alive, and there's nothing I want to do." - They Might Be Giants, http://www.tmbg.com

__
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com

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




Re: refreshing problem

2002-06-18 Thread spider man


 The redirection to itself actually works. I wonder if there are any flaws in this 
process. It seems to be more of a work around instead of an actual correct way of 
doing things. What do you think?
  spider man <[EMAIL PROTECTED]> wrote: 
My script has HTML code generated at the at the file. There is an "if" condition on 
the param() values at the beginning for processing. Regardless of the "if" condition, 
the code to generate HTML code is executed at the end. So the form is 
http:////form.pl and when you submit the form it doesn't redirect and run the 
same script again for the HTML. So you will see http://.../.../form.pl again. Would 
redirect to another URL and then back to the script form do the trick?
John Brooking wrote: When you say that after the text is processed, the
same form is regenerated back to user, how are you
doing that? Via a redirect? Another leading question
would be what is the URL shown in the address bar the
first time you enter the form, versus subsequent
times. Is it the same? If, on subsequent times, the
URL shown is still your processing script, that would
explain why Refresh appears to submit it again.

Come to think of it, that's similar to a problem I've
noticed with one of my scripts. Unfortunately for both
of us, I haven't bothered debugging it yet! :-)

- John

--- spider man 
wrote:
> I got a simple form running on NT IIS web server.
> Everything works fine. The simple form consist of
> text fields. When you fill out the text and submit
> the form, the text is processed and regenerates the
> same form back to the user. When the form
> regenerates, the fields are blanked out. At this
> point, if the user hits the refresh button on the
> browser with the same script then the same data is
> transferred again for processing. How can I prevent
> this?


=
"Now it's over, I'm dead, and I haven't done anything that I want; or, I'm still 
alive, and there's nothing I want to do." - They Might Be Giants, http://www.tmbg.com

__
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com


-
Do You Yahoo!?
Sign-up for Video Highlights of 2002 FIFA World Cup


-
Do You Yahoo!?
Sign-up for Video Highlights of 2002 FIFA World Cup


Re: refreshing problem

2002-06-18 Thread spider man


 My script has HTML code generated at the at the file. There is an "if" condition on 
the param() values at the beginning for processing. Regardless of the "if" condition, 
the code to generate HTML code is executed at the end. So the form is 
http:////form.pl and when you submit the form it doesn't redirect and run the 
same script again for the HTML. So you will see http://.../.../form.pl again. Would 
redirect to another URL and then back to the script form do the trick?
  John Brooking <[EMAIL PROTECTED]> wrote: When you say that after the text is 
processed, the
same form is regenerated back to user, how are you
doing that? Via a redirect? Another leading question
would be what is the URL shown in the address bar the
first time you enter the form, versus subsequent
times. Is it the same? If, on subsequent times, the
URL shown is still your processing script, that would
explain why Refresh appears to submit it again.

Come to think of it, that's similar to a problem I've
noticed with one of my scripts. Unfortunately for both
of us, I haven't bothered debugging it yet! :-)

- John

--- spider man 
wrote:
> I got a simple form running on NT IIS web server.
> Everything works fine. The simple form consist of
> text fields. When you fill out the text and submit
> the form, the text is processed and regenerates the
> same form back to the user. When the form
> regenerates, the fields are blanked out. At this
> point, if the user hits the refresh button on the
> browser with the same script then the same data is
> transferred again for processing. How can I prevent
> this?


=
"Now it's over, I'm dead, and I haven't done anything that I want; or, I'm still 
alive, and there's nothing I want to do." - They Might Be Giants, http://www.tmbg.com

__
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com


-
Do You Yahoo!?
Sign-up for Video Highlights of 2002 FIFA World Cup


Re: refreshing problem

2002-06-18 Thread John Brooking

When you say that after the text is processed, the
same form is regenerated back to user, how are you
doing that? Via a redirect? Another leading question
would be what is the URL shown in the address bar the
first time you enter the form, versus subsequent
times. Is it the same? If, on subsequent times, the
URL shown is still your processing script, that would
explain why Refresh appears to submit it again.

Come to think of it, that's similar to a problem I've
noticed with one of my scripts. Unfortunately for both
of us, I haven't bothered debugging it yet! :-)

- John

--- spider man <[EMAIL PROTECTED]> wrote:
> I got a simple form running on NT IIS web server.
> Everything works fine. The simple form consist of
> text fields. When you fill out the text and submit
> the form, the text is processed and regenerates the
> same form back to the user. When the form
> regenerates, the fields are blanked out. At this
> point, if the user hits the refresh button on the
> browser with the same script then the same data is
> transferred again for processing. How can I prevent
> this?


=
"Now it's over, I'm dead, and I haven't done anything that I want; or, I'm still 
alive, and there's nothing I want to do." - They Might Be Giants, http://www.tmbg.com

__
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com

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




refreshing problem

2002-06-18 Thread spider man

I got a simple form running on NT IIS web server. Everything works fine. The simple 
form consist of text fields. When you fill out the text and submit the form, the text 
is processed and regenerates the same form back to the user. When the form 
regenerates, the fields are blanked out. At this point, if the user hits the refresh 
button on the browser with the same script then the same data is transferred again for 
processing. How can I prevent this?


-
Do You Yahoo!?
Sign-up for Video Highlights of 2002 FIFA World Cup


Re: about awk 2 perl

2002-06-18 Thread Ramprasad A Padmanabhan

convert any awk script to perl directly by using a2p


like
echo '{print $1,$2}' | a2p


Chang Ming Huei wrote:
> Hi all:
> 
>   I want to use perl to do something like a awk script as following:
> 
>   cat file.txt | awk '{print $1,$2}'
> 
>  How can I do it ?
> 



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




RE: more redirect script problems

2002-06-18 Thread Bob Showalter

> -Original Message-
> From: Hughes, Andrew [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, June 18, 2002 10:02 AM
> To: [EMAIL PROTECTED]
> Subject: more redirect script problems
> 
> 
> I am still trying to create this redirect script that is 
> called when the
> referring page refreshes after 0 seconds (with a meta tag) to the
> redirect.pl.  I am having a couple of problems.  The first is 
> that when it
> refreshes the scripted does not recognize the page as the 
> referring page.
> Each time I test it, my "else" statement is executed with the message,
> "CGI=HASH(0x80fbc2c)->referer is not a valid. Please check 
> the address and
> try again."  When I hard code a link to the script, and click 
> on it, I get
> an error that reads, "Undefined subroutine &main::meta called 
> at redirect.pl
> line 14."  Does anyone have an idea on how to make this 
> script work or to go
> about it differently?  Any/All suggestions are appreciated.
> 
> Thanks,
> Andrew
> _
> 
> #!/usr/bin/perl -wT
> use CGI; 
> use CGI::Carp 'fatalsToBrowser';
> use strict;
> 
> my $q = new CGI;
> 
> my $referer = $q->referer;
> #my $onesite_atlhmbnk =
> $q->param('http://www.mysite.com/atlhmbnk/index.html');
> #my $onesite_atlcas = 
> $q->param('http://www.mysite.com/atlcas/index.html');
> #my $onesite_brook = 
> $q->param('http://www.mysite.com/brook/index.html');
> 
> 
> if ($referer eq "http://www.mysite.com/atlhmbnk/index.html";) {
> print $q->header("text/html"),
>   $q->start_html(-head=>meta({-http_equiv=>'Refresh',
>-content=>'0;
> URL=http://www.mysite.com/atlcas/site.html'})),
>   $q->p("This is atlcas"),
>   $q->end_html;
> }
> 
> 
> elsif ($referer eq "http://www.mysite.com/atlcas/index.html";) {
> print $q->header("text/html"),
>   $q->start_html(-head=>meta({-http_equiv=>'Refresh',
>-content=>'0;
> URL=http://www.mysite.com/atlhmbnk/site.html'})),
>   $q->p("This is atlhmbnk"),
>   $q->end_html;
> }
> 
> 
> elsif ($referer eq "http://www.mysite.com/brook/index.html";) {
> print $q->header("text/html"),
>   $q->start_html(-head=>meta({-http_equiv=>'Refresh',
>-content=>'0;
> URL=http://www.mysite.com/brook/site.html'})),
>   $q->p("This is brook"),
>   $q->end_html;
> }
> 
> else {
> print $q->header("text/html"),
>   $q->start_html,
>   $q->p("$q->referer is not a valid.  Please check the 
> address and try
> again."),
>   $q->end_html;
> }

A couple of comments/observations:

1. The CGI module has a redirect() method for handling redirects. Have you
looked at that?

2. In my experience, the browser does not update the Referer: header when
doing a redirect. The safest technique is to probably pass the referer
along with the redirect uri, rather than depending on any particular client
behavior.

3. You can't expand method calls inside double quotes like 

   $q->p("$q->referer is not a valid").

That's why you're getting

   CGI=HASH(0x80fbc2c)->referer is not a valid

Try just:

   $q->p($q->referer . " is not a valid").

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




more redirect script problems

2002-06-18 Thread Hughes, Andrew

I am still trying to create this redirect script that is called when the
referring page refreshes after 0 seconds (with a meta tag) to the
redirect.pl.  I am having a couple of problems.  The first is that when it
refreshes the scripted does not recognize the page as the referring page.
Each time I test it, my "else" statement is executed with the message,
"CGI=HASH(0x80fbc2c)->referer is not a valid. Please check the address and
try again."  When I hard code a link to the script, and click on it, I get
an error that reads, "Undefined subroutine &main::meta called at redirect.pl
line 14."  Does anyone have an idea on how to make this script work or to go
about it differently?  Any/All suggestions are appreciated.

Thanks,
Andrew
_

#!/usr/bin/perl -wT
use CGI; 
use CGI::Carp 'fatalsToBrowser';
use strict;

my $q = new CGI;

my $referer = $q->referer;
#my $onesite_atlhmbnk =
$q->param('http://www.mysite.com/atlhmbnk/index.html');
#my $onesite_atlcas = $q->param('http://www.mysite.com/atlcas/index.html');
#my $onesite_brook = $q->param('http://www.mysite.com/brook/index.html');


if ($referer eq "http://www.mysite.com/atlhmbnk/index.html";) {
print $q->header("text/html"),
  $q->start_html(-head=>meta({-http_equiv=>'Refresh',
 -content=>'0;
URL=http://www.mysite.com/atlcas/site.html'})),
  $q->p("This is atlcas"),
  $q->end_html;
}


elsif ($referer eq "http://www.mysite.com/atlcas/index.html";) {
print $q->header("text/html"),
  $q->start_html(-head=>meta({-http_equiv=>'Refresh',
 -content=>'0;
URL=http://www.mysite.com/atlhmbnk/site.html'})),
  $q->p("This is atlhmbnk"),
  $q->end_html;
}


elsif ($referer eq "http://www.mysite.com/brook/index.html";) {
print $q->header("text/html"),
  $q->start_html(-head=>meta({-http_equiv=>'Refresh',
 -content=>'0;
URL=http://www.mysite.com/brook/site.html'})),
  $q->p("This is brook"),
  $q->end_html;
}

else {
print $q->header("text/html"),
  $q->start_html,
  $q->p("$q->referer is not a valid.  Please check the address and try
again."),
  $q->end_html;
}

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




RE: Is it a difference?

2002-06-18 Thread Bob Showalter

> -Original Message-
> From: Todd Wade [mailto:[EMAIL PROTECTED]]
> Sent: Monday, June 17, 2002 6:40 AM
> To: [EMAIL PROTECTED]
> Subject: Re: Is it a difference?
> 
> 
> 
> "Bob Showalter" <[EMAIL PROTECTED]> wrote in message
> 2E4528861499D41199D200A0C9B15BC031BAD4@FRISTX">news:2E4528861499D41199D200A0C9B15BC031BAD4@FRISTX...
> > >
> > > my $q = new CGI;
> > > my $q = CGI -> new();
> > >
> > > Can I use any of these 2 lines with no problem.
> > > I haven't seen explanations for the differences between 
> these lines.
> >
> > These are equivalent. See the discussion under "Method Invocation"
> > in perldoc perlobj.
> 
> Not quite. The former is called "indirect object notation", a 
> subject that
> owns almost the entire page 446 in the cookbook. Near the the 
> beginning of
> the discussion it starts: "It has two grave problems" and 
> finishes with:
> "... The infix arrow notation using -> dosent suffer from 
> either of these
> disturbing ambiguities, so we recommend you use it exclusively."
> 
> True, for this example it produces the same result, but IMHO, 
> its usually in
> our best interest to follow the recommendations of Mr. 
> Christiansen and Mr.
> Torkington

Yes, you are correct. As a matter of fact, I was just recently
"burned" by one of these ambiguities when I tried to do something
along the lines of the following inside a method:

   package Bar;

   sub new
   {
  my $class = shift;
  bless {}, $class;
   }

   sub run
   {
  my $package = 'Foo';
  my $obj = new $package;   # Create a new Foo? Nope!
  $obj->baz();
   }

That didn't do what I wanted until I changed it to:

   my $obj = $package->new();   # Create a new Foo. Yes!

(the package name is actually derived at run-time; thus the need
to store it in a variable. My module is something similar to 
Apache::Registry)

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