Re: my( $string )

2003-03-07 Thread Bob X
David Gilden [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Quick question:
 my( $string ) = you ordered  . $q-param('quantity') .  foobars\n;


 What with the '( )'  do I need them every time I declare a variable?


You can declare them like this:

my $foo;
my $bar;

Or you can declare like this:

my ($foo, $bar);

I prefer the first way...

Bob



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



multipart form problem

2003-03-07 Thread Li Ngok Lam
Hi all, I am totally new about CGI and Perl, and now, I've facing my first problem so 
hope  somebody
can help...

I have this html code :

form action=getfile.pl method=post enctype=multipart/form-data
input type=file name=file
input type=submit
/form

and I have this Perl code :

 #!C:/Perl/bin/perl.exe
print Content-type: text/html\n\n;
print OK;

my problem sounds strange ... when I am uploading a text file, result comes fine.
but when I upload a binary file ( *.exe *.jpg), my browser directly point me to 
that Cannot open page die page. 

Note, the Cannot open page die page prompts immediately when I click on Submit,
It doesn't looks like other script errors, some delay  will taking place before take 
me to
that die page.

I also tried the fatalsToBrowser (the piece from CGI.pm), but still no use. The browser
sounds take me to that die page without thinking...  Both IE and NS result the same on 
both ME and Win2K also...

Why ? Please help. Thank you.






RE: Getting a STDOUT value

2003-03-07 Thread wiggins
Remember to include the list in your replies, so that everyone can help and be helped.


On Fri, 7 Mar 2003 08:52:04 -0600, Scot Robnett [EMAIL PROTECTED] wrote:

 Thanks - but I don't understand how that redirect works. I've read about
 open, select, and filehandles and I still don't get the STDERR or STDOUT
 redirect. 

Essentially the process being called needs to know how to handle this type of 
interaction so using regular opens/filehandles is not likely to work. However, since 
you are calling a process using backticks or you can use the IPC::Open3 mechanism then 
either in the former case the process will be the shell, which does understand how to 
do redirects, etc. or in the latter that is the very reason for Open3.

I don't see any examples of working code with the 21
 functionality and I don't know in what context that gets used.
 

21 are parameters that are parsed by the shell and instructs it how to handle the 
outputs of the process it is about to run. Because backticks gets its information from 
the shell, specifically STDOUT (of the shell) then if you tell the shell to redirect 
the stderr of the process into the stdout (which is what 21) does then the STDERR 
will show up on the STDOUT channel, which will be caught by the backticks.  The only 
context where you need to watch out for this is when the process is *NOT* shelled out, 
which I believe only occurs in the multiple argument version of 'system' (please list 
correct me if I have this backwards).

 I am able to get the pid with IPC::Open2, but I want to display the results
 of the process, not the ID of the process.
 

Sorry I should have been more specific on this, I believe Open2 will not accomplish 
what you need since it only works for STDOUT/STDIN. Open3 should be able to handle it 
however as it handles STDIN/STDOUT/STDERR. You will *NOT* want to use the 21 
construct with an Open3!!  Check the docs for info on getting the output, but 
essentially you call Open3 on the command giving it filehandles where it should send 
the output, then you should just read from those file handles like a normal 'open'd 
file handle. 

 Here's what it looks like using a standard filehandle, but the results
 aren't being saved into my variable and therefore not displaying in the
 browser. What should this code look like with the missing link added?
 
 #!/usr/bin/perl -w
 
 use strict;
 use CGI::Carp qw(fatalsToBrowser);
 
 my $cmd  = `perl -c myscript.cgi`;

Change the above to:

my @output = `perl -c myscript.cgi 21`;

Then you will want to test $? for the return code, on a failed return code (likely 
anything but 0) then you will want to step through the @output array and print the 
stderr.  Check in:

perldoc perlop

Under the section qx/STRING/ for examples and further description.


 open(STDERR,$cmd); # No idea how to redirect 21 here
 while($line = STDERR) {
  print $line;
 }
 close(STDERR);
 

Here if my understanding is correct you are re-opening your own STDERR using the 
command's STDOUT (which doesn't have anything on it). Then reading your own STDERR and 
printing on own STDOUT. Which won't print anything because there is nothing on your 
own STDERR because there is nothing on the processes STDOUT...  but then you really 
don't want to do things this way, at least outside of the context of an obfuscated 
Perl contest :-).

HTH,

http://danconia.org

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



RE: Getting a STDOUT value

2003-03-07 Thread Scot Robnett
Wow! Quite a detailed response...thank you.


-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Friday, March 07, 2003 9:25 AM
To: Scot Robnett
Cc: [EMAIL PROTECTED]
Subject: RE: Getting a STDOUT value


Remember to include the list in your replies, so that everyone can help and
be helped.


On Fri, 7 Mar 2003 08:52:04 -0600, Scot Robnett [EMAIL PROTECTED] wrote:

 Thanks - but I don't understand how that redirect works. I've read about
 open, select, and filehandles and I still don't get the STDERR or STDOUT
 redirect.

Essentially the process being called needs to know how to handle this type
of interaction so using regular opens/filehandles is not likely to work.
However, since you are calling a process using backticks or you can use the
IPC::Open3 mechanism then either in the former case the process will be the
shell, which does understand how to do redirects, etc. or in the latter that
is the very reason for Open3.

I don't see any examples of working code with the 21
 functionality and I don't know in what context that gets used.


21 are parameters that are parsed by the shell and instructs it how to
handle the outputs of the process it is about to run. Because backticks gets
its information from the shell, specifically STDOUT (of the shell) then if
you tell the shell to redirect the stderr of the process into the stdout
(which is what 21) does then the STDERR will show up on the STDOUT
channel, which will be caught by the backticks.  The only context where you
need to watch out for this is when the process is *NOT* shelled out, which I
believe only occurs in the multiple argument version of 'system' (please
list correct me if I have this backwards).

 I am able to get the pid with IPC::Open2, but I want to display the
results
 of the process, not the ID of the process.


Sorry I should have been more specific on this, I believe Open2 will not
accomplish what you need since it only works for STDOUT/STDIN. Open3 should
be able to handle it however as it handles STDIN/STDOUT/STDERR. You will
*NOT* want to use the 21 construct with an Open3!!  Check the docs for
info on getting the output, but essentially you call Open3 on the command
giving it filehandles where it should send the output, then you should just
read from those file handles like a normal 'open'd file handle.

 Here's what it looks like using a standard filehandle, but the results
 aren't being saved into my variable and therefore not displaying in the
 browser. What should this code look like with the missing link added?

 #!/usr/bin/perl -w

 use strict;
 use CGI::Carp qw(fatalsToBrowser);

 my $cmd  = `perl -c myscript.cgi`;

Change the above to:

my @output = `perl -c myscript.cgi 21`;

Then you will want to test $? for the return code, on a failed return code
(likely anything but 0) then you will want to step through the @output array
and print the stderr.  Check in:

perldoc perlop

Under the section qx/STRING/ for examples and further description.


 open(STDERR,$cmd); # No idea how to redirect 21 here
 while($line = STDERR) {
  print $line;
 }
 close(STDERR);


Here if my understanding is correct you are re-opening your own STDERR using
the command's STDOUT (which doesn't have anything on it). Then reading your
own STDERR and printing on own STDOUT. Which won't print anything because
there is nothing on your own STDERR because there is nothing on the
processes STDOUT...  but then you really don't want to do things this way,
at least outside of the context of an obfuscated Perl contest :-).

HTH,

http://danconia.org

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

question about uninitialized variable

2003-03-07 Thread Tony Bandy
Hello everyone,

Fairly new to the list here (and perl), so if this is an inappropriate
post, please forgive me. I've got the Learning Perl book plus a few
others...but I'm still scratching my head over this one.

Just a beginning test page where the end-user submits a name and gets a
page back with that name in it.  The page works,however, the warning I
keep getting is:

Use of uninitialized value in concatenation (.) or string...

I also noticed this same type of warning when I attempt to take the same
thing (user input) and try to compare it to another variable, using this
example-- $my other variable=~/$name/ operator. I can't get anything to
match.

Here is a snippet of code that will generate the error messsage above:


#!c:\Perl\Perl5.00402\bin\perl.exe -w
#Set Perl Parameters
#use strict;
#The CGI.pm module will take input from the form and process it for you.
use CGI qw(:standard);
my $name=param(name);

print h2You entered: $name p\n;


Thanks in advance for any help you might be able to provide a newbie.


-- 
Tony Bandy [EMAIL PROTECTED]
OHIONET


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



Help with File::Find

2003-03-07 Thread Kipp, James
Hi
Is there a way to get File::Find to TOTALLY ignore a directory?? See
comments in code for what I mean:

find ( \wanted, 'f:/users/user1');

sub wanted
{
## HERE: even though it returns when it sees a dir called 
  # with Profile, it comes right back to where it left of, in other
  # words it still iterates thru the dircectory, it just skips the
processing of it
  # any way to tell it to skip/ignore the dir and it subdirs and files
TOTALLY??
# next has the same effect.
return if ($File::Find::dir =~ /Profile/i );
next unless ($File::Find::name =~ /.*\.pst$/);
print $File::Find::name\n; 
}
 
--

Thanks for any help,
Jim


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



RE: Help with File::Find

2003-03-07 Thread Kipp, James
Please ignore this post. This was meant for the perl-beginners list. My
apologies.
--

 -Original Message-
 From: Kipp, James 
 Sent: Friday, March 07, 2003 1:57 PM
 To: [EMAIL PROTECTED]
 Subject: Help with File::Find
 


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



RE: question about uninitialized variable

2003-03-07 Thread Hughes, Andrew
As a relative newbie myself, it appears that you have in essence applied a
variable to a variable.  I typically use the format

my $name=param(name);

when I have a form that has a field called name.  This form field value
(andrew for example) would be stored in param(name) which is then stored
in the variable $name.  Based on your code snippet, you do not appear to
have a value in either holder $name or param(name).

As I said earlier, I am pretty new at this too.  Others please jump in.

Andrew

-Original Message-
From: Tony Bandy [mailto:[EMAIL PROTECTED]
Sent: Friday, March 07, 2003 1:43 PM
To: [EMAIL PROTECTED]
Subject: question about uninitialized variable


Hello everyone,

Fairly new to the list here (and perl), so if this is an inappropriate
post, please forgive me. I've got the Learning Perl book plus a few
others...but I'm still scratching my head over this one.

Just a beginning test page where the end-user submits a name and gets a
page back with that name in it.  The page works,however, the warning I
keep getting is:

Use of uninitialized value in concatenation (.) or string...

I also noticed this same type of warning when I attempt to take the same
thing (user input) and try to compare it to another variable, using this
example-- $my other variable=~/$name/ operator. I can't get anything to
match.

Here is a snippet of code that will generate the error messsage above:


#!c:\Perl\Perl5.00402\bin\perl.exe -w
#Set Perl Parameters
#use strict;
#The CGI.pm module will take input from the form and process it for you.
use CGI qw(:standard);
my $name=param(name);

print h2You entered: $name p\n;


Thanks in advance for any help you might be able to provide a newbie.


-- 
Tony Bandy [EMAIL PROTECTED]
OHIONET


-- 
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: question about uninitialized variable

2003-03-07 Thread Wiggins d'Anconia


Hughes, Andrew wrote:
As a relative newbie myself, it appears that you have in essence applied a
variable to a variable.  I typically use the format
my $name=param(name);

when I have a form that has a field called name.  This form field value
(andrew for example) would be stored in param(name) which is then stored
in the variable $name.  
This is one way to think of it, though maybe not the best (at first). 
You are giving the impression that 'param(name)' is a container and 
that a value is stored in it, which in this case is not strictly 
correct.  'param' is a function, that takes an argument 'name' (in this 
case) and performs some action and then returns a value.  So in the 
sense that it is one way to access a particular value when given a 
particular parameter it appears to store the information. However 
there is no underlying structure 'param' that is storing anything, the 
value is being generated on the fly everytime.  Of course, advanced 
techniques using 'tie' blur the line here that I am drawing.


That is probably the underlying cause. The OP mentioned that the page 
worked, is the name displayed correctly?  What line number is indicated 
in the warning, and what line of code is that? This will give you an 
idea of which value is uninitialized.

http://danconia.org


-Original Message-
From: Tony Bandy [mailto:[EMAIL PROTECTED]
Sent: Friday, March 07, 2003 1:43 PM
To: [EMAIL PROTECTED]
Subject: question about uninitialized variable
Hello everyone,

Fairly new to the list here (and perl), so if this is an inappropriate
post, please forgive me. I've got the Learning Perl book plus a few
others...but I'm still scratching my head over this one.
Just a beginning test page where the end-user submits a name and gets a
page back with that name in it.  The page works,however, the warning I
keep getting is:
Use of uninitialized value in concatenation (.) or string...

I also noticed this same type of warning when I attempt to take the same
thing (user input) and try to compare it to another variable, using this
example-- $my other variable=~/$name/ operator. I can't get anything to
match.
Here is a snippet of code that will generate the error messsage above:

#!c:\Perl\Perl5.00402\bin\perl.exe -w
#Set Perl Parameters
#use strict;
#The CGI.pm module will take input from the form and process it for you.
use CGI qw(:standard);
my $name=param(name);
print h2You entered: $name p\n;

Thanks in advance for any help you might be able to provide a newbie.




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


Testing.....

2003-03-07 Thread Li Ngok Lam