[Q] Help on File Update?!

2002-04-03 Thread Bhanu Prakash

Greetings Perl Listers,
  I'm trying to write a program in which I
will be updating an employee database( a flat file
here)., with Employee Id as the key.

   For the sake of simplicity , assuming that the
fields are like
EmpId Salary
EmpIe2 Salary2
..
.
Can somebody help me finding out how does the code
look like , if I've to do something like..

if( record with EmpId exists ) {
   update with the new input
} else {
insert the new record at the end of the input
}

Thanks for your help
Bhanu.



__
Do You Yahoo!?
Yahoo! Tax Center - online filing with TurboTax
http://taxes.yahoo.com/

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




[Q] Exporting variables?

2002-02-24 Thread Bhanu Prakash

Perl Listers,

Is there a way I can export the values of certain
variables from this cgi to another?
 Cookies are one way of doing this, if I'm not wrong!
Can somebody tell me how exactly do I implement this ?
Thanks for the help
Bhanu.

=
Bhanu Prakash G V S

__
Do You Yahoo!?
Yahoo! Sports - Coverage of the 2002 Olympic Games
http://sports.yahoo.com

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




[Q] Unable to Retrieve Cookies.

2002-02-24 Thread Bhanu Prakash

Perl Listers,
   I'm unable to retrieve cookies once I set them! I
can see my html headers on my page once they are set,
along with the page, but when I move out to another
page, I'm not able to retrieve them, in the new cgi
script. My script is complaining Can't call method
value on an undefined value
Any Help?!
Thanks
Bhanu.

=
Bhanu Prakash G V S

__
Do You Yahoo!?
Yahoo! Sports - Coverage of the 2002 Olympic Games
http://sports.yahoo.com

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




[Q] Exporting variables?

2002-02-24 Thread Bhanu Prakash

Perl Listers,

Is there a way I can export the values of certain
variables from this cgi to another?
 Cookies are one way of doing this, if I'm not wrong!
Can somebody tell me how exactly do I implement this ?
Thanks for the help
Bhanu.

=
Bhanu Prakash G V S

__
Do You Yahoo!?
Yahoo! Sports - Coverage of the 2002 Olympic Games
http://sports.yahoo.com

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




[Q] Unable to Retrieve Cookies.

2002-02-24 Thread Bhanu Prakash

Perl Listers,
   I'm unable to retrieve cookies once I set them! I
can see my html headers on my page once they are set,
along with the page, but when I move out to another
page, I'm not able to retrieve them, in the new cgi
script. My script is complaining Can't call method
value on an undefined value
Any Help?!
Thanks
Bhanu.

=
Bhanu Prakash G V S

__
Do You Yahoo!?
Yahoo! Sports - Coverage of the 2002 Olympic Games
http://sports.yahoo.com

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




[Q]Setting global variables.

2002-02-22 Thread Bhanu Prakash

Perl Gurus,
   How can I set global variables in perl.?
I'm trying to do something like..

if(param())
{
my $myvar=param(myvar);
if(param(myvar2){
use $myvar here..
Has some script to show a form..

}
else {
On submitting the form, user enters here..
someother use of $myvar..
Here, my script is showing value of $myvar as null.
I wanted to use the same value of myvar which I had
before submitting the form.
}

Am I missing something? Or should I set a global
variable for myvar?!
Thanks
Bhanu.

=
Bhanu Prakash G V S

__
Do You Yahoo!?
Yahoo! Sports - Coverage of the 2002 Olympic Games
http://sports.yahoo.com

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




[Q]How can I pass Perl variables into shell?

2002-02-22 Thread Bhanu Prakash

Thanks  japhy and Wags ;)
   It works fine now with the backslashes!
Bhanu

On Feb 21, Wagner-David said:

   The $1 and $2 come out of reqex with parens.

That's not helping, though.  The answer he seeks is: 
backslash the $
signs.

-- 
Jeff japhy Pinyan  [EMAIL PROTECTED] 
http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/  
http://www.cpan.org/
** Look for Regular Expressions in Perl published by
Manning, in 2002 **
stu what does y/// stand for?  tenderpuss why,
yansliterate of course.
[  I'm looking for programming work.  If you like my
work, let me know.  ]


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

=
Bhanu Prakash G V S

__
Do You Yahoo!?
Yahoo! Sports - Coverage of the 2002 Olympic Games
http://sports.yahoo.com

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




[Q]Setting global variables.

2002-02-22 Thread Bhanu Prakash

Perl Gurus,
   How can I set global variables in perl.?
I'm trying to do something like..

if(param())
{
my $myvar=param(myvar);
if(param(myvar2){
use $myvar here..
Has some script to show a form..

}
else {
On submitting the form, user enters here..
someother use of $myvar..
Here, my script is showing value of $myvar as null.
I wanted to use the same value of myvar which I had
before submitting the form.
}

Am I missing something? Or should I set a global
variable for myvar?!
Thanks
Bhanu.

=
Bhanu Prakash G V S

__
Do You Yahoo!?
Yahoo! Sports - Coverage of the 2002 Olympic Games
http://sports.yahoo.com

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




[Q]Validating Forms?!

2002-02-22 Thread Bhanu Prakash

 And then you can also write an entire validate
 routine in Javascript,say 'validateForm' and
 associate that with onSubmit event. Pass the form 
 object itself, by invoking the function as FORM
 name... onSubmit=return validateForm(this);

Jonathan,
Validating in Perl?!I'm interested.! Can you send
me some sample scripts which validates in perl?!
Thanks
Bhanu.
Lets make the headline short:

ALWAYS VALIDATE IN PERL, BUT MAYBE VALIDATE IN
JAVASCRIPT ALSO

Why?  Because some really annoying person is going
to avoid using your Javascript, and send you bogus
information.  Don't think that because you use
Javascript that you're safe!  Always double check,
as even normal users switch Javascript off.

Jonathan Paton

__
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com

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

=
Bhanu Prakash G V S

__
Do You Yahoo!?
Yahoo! Sports - Coverage of the 2002 Olympic Games
http://sports.yahoo.com

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




[Q]Validating forms?!

2002-02-21 Thread Bhanu Prakash

Bhanu Prakash wrote:

HI All,
  Is there a way to Validate the fields of a
form? Say I have a
text field, and I should show an error to the user if
he does not enter
anything while submitting the form?
 Can somebody give me some sample script?! with some
high level explaination?
Thanks for the help
Bhanu.




__
Do You Yahoo!?
Yahoo! Sports - Coverage of the 2002 Olympic Games
http://sports.yahoo.com

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




Re: Sending Mail.

2002-02-21 Thread Bhanu Prakash

Chris,
I'm using Solaris to run my perl script. Did
you have a chance to write script in Solaris anytime?!
Should the script be different for Solaris and
Windows?
Thanks
Bhanu.


Bhanu,

  Not sure what operating system you are using, but I
have just done
something very similar in Windows.  The form the user
input data into was on
their intranet, and then the details of the form were
mailed out to the
client (in html orginally, but my clients are large
insurance firms and did
not accept html content - silly me!!),
 If you think that I can be any help, just let me
know,

 Chris Zampese.
[EMAIL PROTECTED]

- Original Message -
From: Johannes Franken [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Thursday, February 21, 2002 9:38 PM
Subject: Re: Sending Mail


 On Wed, Feb 20, 2002 at 08:58:41AM -0800, Bhanu
Prakash wrote:
  when a user submits a form, the input  entered by
him should be
  mailed to the address he specifies in one of teh
input fileds.!

 If you put that one on a public webserver, you
should consider a way
 to prevent bad people from using it as spam relay.

  can anybody give me some bare bone structure of
how I should
  accomplish this?

 For example, you could use Net::SMTP

 #!/usr/bin/perl -w
 #
 # sendmail.pl - httpd - smtp gateway
 #

#
 use CGI;
 use Net::SMTP;

 # defines
 $from=httpd\@jfranken.de;
 $mailhost=localhost;

 # Get CGI- query params
 $q  =new CGI;
 $subject=$q-param(subject);
 $text   =$q-param(text);
 $to =$q-param(to);
 die unless ($subject and $text and $to);

 # SMTP (RFC 821) -Header
 $smtp = Net::SMTP-new($mailhost) or die;
 $smtp-mail($from) or die;
 $smtp-to($to) or die;

 # Mail (RFC822) -Header
 $smtp-data() or die;
 $smtp-datasend(From: $from\n) or die;
 $smtp-datasend(To: $to\n) or die;
 $smtp-datasend(Subject: $subject\n) or die;

 # Mail (RFC822) -Body
 $smtp-datasend(\n$text\n) or die;
 $smtp-dataend() or die;
 $smtp-quit or die;

 # HTML Feedback to the user
 print Content-Type: text/html\n\nhtmlbody
bgcolor=\#ff\Your
message was sentpa href=\ . $ENV{HTTP_REFERER} .
\continue/A/body/html;

 exit

 --
 Johannes Franken

 Professional unix/network development
 mailto:[EMAIL PROTECTED]
 http://www.jfranken.de/

 --
 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]

=
Bhanu Prakash G V S

__
Do You Yahoo!?
Yahoo! Sports - Coverage of the 2002 Olympic Games
http://sports.yahoo.com

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




[Q] Validating Forms?!

2002-02-21 Thread Bhanu Prakash

HI All,
  Is there a way to Validate the fields of a
form? Say I have a
text field, and I should show an error to the user if
he does not enter
anything while submitting the form?
Thanks for the help
Bhanu.



=
Bhanu Prakash G V S

__
Do You Yahoo!?
Yahoo! Sports - Coverage of the 2002 Olympic Games
http://sports.yahoo.com

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




RE: [Q] Validating Forms?!

2002-02-21 Thread Bhanu Prakash

John,
 Thanks much for that information. It would be of
great help to me if you can provide me with some
sample scripts that will do these functions.! 
Of course I'd like to add more robustness to my
script.! But, I don't know how to :(
Looking for your help
Bhanu.


I would do this using javascript within the form. Then
when the field loses
focus you can validate it. This means the form doesn't
have to be submitted
before the user is alerted of a problem.

For extra robustness you can also validate the
submitted results in the perl
script and return the user to the form with highlights
on what is
wrong/missing.

HTH

John

-Original Message-
From: Bhanu Prakash [mailto:[EMAIL PROTECTED]]
Sent: 21 February 2002 10:59
To: [EMAIL PROTECTED]
Subject: [Q] Validating Forms?!


HI All,
  Is there a way to Validate the fields of a
form? Say I have a
text field, and I should show an error to the user if
he does not enter
anything while submitting the form?
Thanks for the help
Bhanu.



=
Bhanu Prakash G V S

__
Do You Yahoo!?
Yahoo! Sports - Coverage of the 2002 Olympic Games
http://sports.yahoo.com

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




=
Bhanu Prakash G V S

__
Do You Yahoo!?
Yahoo! Sports - Coverage of the 2002 Olympic Games
http://sports.yahoo.com

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




Re: Sending mail

2002-02-21 Thread Bhanu Prakash

Darren,
   Can I run this formmail from another cgi program?
Say I have some code fragment like this?

if(param(myinfo)) {
  Can I invoke formmail here?
}

Would you mind explaining me, how ?
Thanks
Bhanu.

try FormMail
http://worldwidemart.com/scripts/formmail.shtml

-Original Message-
From: Bhanu Prakash [mailto:[EMAIL PROTECTED]]
Sent: 20 February 2002 16:59
To: [EMAIL PROTECTED]
Subject: Sending Mail


Hi,
 I'm new to Perl and am trying to write some cgi
programs in Perl.
Currently I'm developing a tool in which , when a user
submits a form,
the input  entered by him should be mailed to the
address he specifies
in one of teh input fileds.!  Does anybody have some
sample scripts
which does soemthing similar to this? or can anybody
give me some bare
bone structure of how I should accomplish this?
Thanks for the help
Bhanu.

=
Bhanu Prakash G V S

__
Do You Yahoo!?
Yahoo! Sports - Coverage of the 2002 Olympic Games
http://sports.yahoo.com

-- 
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]

=
Bhanu Prakash G V S

__
Do You Yahoo!?
Yahoo! Sports - Coverage of the 2002 Olympic Games
http://sports.yahoo.com

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




Compare values

2002-02-21 Thread Bhanu Prakash

Hi Perl Gurus

Is there a way to compare the values in perl?
something like..

my $user = remote_user()
if ($user == $owner_of_page ) { 
do_something
} else {
do_something_else
}
Thanks
Bhanu.

__
Do You Yahoo!?
Yahoo! Sports - Coverage of the 2002 Olympic Games
http://sports.yahoo.com

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




[Q]File Handles.

2002-02-21 Thread Bhanu Prakash

Perl Gurus,
  Can somebody tell me what is the difference between
the two , with some examples?
open(|/usr/users/mydir/myfile);
and
open(/usr/users/mydir/myfile);
Thanks for the response
Bhanu.

=
Bhanu Prakash G V S

__
Do You Yahoo!?
Yahoo! Sports - Coverage of the 2002 Olympic Games
http://sports.yahoo.com

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




Re:[Q]Convert tcl list

2002-02-21 Thread Bhanu Prakash

Hi Wags,
   Whoops! That seems to solve the purpose.! But, How
do I read this data from a file into an array?!
Thanks
Bhanu.

$_ = 'mykey {{ abc xyz nnn mmm }} mykey2 {{ aaa bbb
ccc ddd}}';

my @MyData = ();
while ( /\{{2}([a-z0-9\s]+)\}{2}/g ) {
   push(@MyData, $1);
   
 }
 
my $MyId = 1;
foreach ( @MyData ) {
   printf %3d: %s\n, $MyId++, $_;
 }

Output:
  1:  abc xyz nnn mmm
  2:  aaa bbb ccc ddd

Wags ;)

-Original Message-
From: Bhanu Prakash [mailto:[EMAIL PROTECTED]]
Sent: Thursday, February 21, 2002 21:38
To: [EMAIL PROTECTED]
Subject: [Q] Convert tcl list


Hi All,
I have a list tcl list dumped onto a data file
which looks like
mykey {{ abc xyz nnn mmm }} mykey2 {{ aaa bbb ccc ddd
}},.
I want to extract the information in the flower braces
and put it into another data file. How easy / or
difficult to implement this in perl? Can somebody help
me accomplish this? 
  I know I can do this using regular expressions.! But
, I'm bad at regexps!!
Thanks for the help
Bhanu.

__
Do You Yahoo!?
Yahoo! Sports - Coverage of the 2002 Olympic Games
http://sports.yahoo.com

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



=
Bhanu Prakash G V S

__
Do You Yahoo!?
Yahoo! Sports - Coverage of the 2002 Olympic Games
http://sports.yahoo.com

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




[Q] How can I pass Perl variables into shell?

2002-02-21 Thread Bhanu Prakash

Hi, 
Can I not do something like...

#!/usr/local/bin/perl 
use strict;
my $myname='hi There';
system ls,-la;
system echo,$myname;
qx{awk '{ if ($myname==$1) { do something } else print
$2,$1 }'};

My script is complaining about uninitialized
variables..
I suspect it is talking about $1 and $2s .Can I not
place them here?
Can I pass $myname to awk?
Thanks
Bhanu


__
Do You Yahoo!?
Yahoo! Sports - Coverage of the 2002 Olympic Games
http://sports.yahoo.com

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




[Q] How can I pass Perl variables into shell?

2002-02-21 Thread Bhanu Prakash

Wags,
Didn't get you there?! Any examples?! which does
similar thing?!
Thanks
Bhanu.


The $1 and $2 come out of reqex with parens.

Wags ;)

-Original Message-
From: Bhanu Prakash [mailto:[EMAIL PROTECTED]]
Sent: Thursday, February 21, 2002 23:05
To: [EMAIL PROTECTED]
Subject: [Q] How can I pass Perl variables into shell?


Hi, 
Can I not do something like...

#!/usr/local/bin/perl 
use strict;
my $myname='hi There';
system ls,-la;
system echo,$myname;
qx{awk '{ if ($myname==$1) { do something } else print
$2,$1 }'};

My script is complaining about uninitialized
variables..
I suspect it is talking about $1 and $2s .Can I not
place them here?
Can I pass $myname to awk?
Thanks
Bhanu


__
Do You Yahoo!?
Yahoo! Sports - Coverage of the 2002 Olympic Games
http://sports.yahoo.com

-- 
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]

=
Bhanu Prakash G V S

__
Do You Yahoo!?
Yahoo! Sports - Coverage of the 2002 Olympic Games
http://sports.yahoo.com

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




[Q]How can I pass Perl variables into Shell

2002-02-21 Thread Bhanu Prakash

Wags,
Let me try to explain what I wanted to do with awk
script. When the user enters some data in the form, I
want to search for this data as key in a datafile and
update the information next to that information with
another field entered by user .
e.g.,
my input file..

bhanu tclprogrammer
wags perlprogrammer

Now , assuming that I have $myuser=bhanu and
$mygoal=perlprogrammer,

My script should open this datafile and replace
tclprogrammer next to bhanu with perlprogrammer
i.e.,
After I run the script,
My output should look like

bhanu perlprogrammer
wags perlprogrammer.


I've been trying to do this with awk.! Donno if this
can be easily done with perl?!
Thanks
Bhanu.



__
Do You Yahoo!?
Yahoo! Sports - Coverage of the 2002 Olympic Games
http://sports.yahoo.com

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




Sending Mail

2002-02-20 Thread Bhanu Prakash

Hi,
 I'm new to Perl and am trying to write some cgi
programs in Perl.
Currently I'm developing a tool in which , when a user
submits a form,
the input  entered by him should be mailed to the
address he specifies
in one of teh input fileds.!  Does anybody have some
sample scripts
which does soemthing similar to this? or can anybody
give me some bare
bone structure of how I should accomplish this?
Thanks for the help
Bhanu.

=
Bhanu Prakash G V S

__
Do You Yahoo!?
Yahoo! Sports - Coverage of the 2002 Olympic Games
http://sports.yahoo.com

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