Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I am novice to Perl Programming. I had question regarding perl program. I have a perl program which use to work on Unix environment. Now i want that same program to work locally on my machine and not on any server. I have Active Perl for Windows NT environment. I have a stand alone java application which takes the user inputs instead of a submit form which is generated by Perl program. So the stand-alone Java aplication takes the inputs and pass on those parameters to the perl program. I did that using .exec() and it is passing those parameters to the perl program. Depending upon the inputs the perl program will display the set of FLAT-FILES which are stored locally on my machine. what all additional changes i will have to make to the perl program in order to make it working locally. Thanx in advance

Replies are listed 'Best First'.
Re: passing parameters??
by dragonchild (Archbishop) on Aug 21, 2001 at 19:14 UTC
    The biggest question is what additional problems are you having in making it work locally? I'd start with that - just trying it out and fixing stuff.

    Some suggestions:

    • Make sure you use strict and warnings. They will help in any debugging efforts (as well as make you code better, anyways.)
    • Make sure you're thinking about what you're doing. Think through the ramifications of a given change and don't just "try it to try it".

    ------
    /me wants to be the brightest bulb in the chandelier!

    Vote paco for President!

Re: passing parameters??
by rob_au (Abbot) on Aug 21, 2001 at 19:14 UTC
    Without seeing any of your code or receiving a more description of any problems that you are experiencing, we are very much working in the dark here. See the node How to get the most of your question from the monks to see how the monks of the monastery can best help you.
     

     
    Ooohhh, Rob no beer function well without!
      can you please answer to my question. i have put the code and also the output it throws. thanx in advance!
Re: passing parameters??
by Anonymous Monk on Aug 21, 2001 at 19:35 UTC
    As i told you, i am passing values from Standalone java application to this perl program abc.pl. These are the variables which are set in the beginingof the program. This are with respect to the server. The program previously was the server. Now i want to make them with respect to my machine(LOCAL).
    $ErrloglogFile = "/export/data/secure03.principal.com/htdocs /logs/pension/ pnactval.log"; $AcclogFile = "/export/data/secure03.principal.com/htdocs/ logs/pension/pnactval.acclog"; $ArchiveDir = "/export/home/pension/logs/rsc"; $zone = `/usr/bin/date \+\%Z`; $gzip = "/usr/local/bin/gzip -d -c"; $grep = "/usr/bin/grep"; $cgi = "/cgi-bin/pension/utilities/rscdetail"; $cat = "/usr/bin/cat"; $tempDir = "/tmp"; $randnum = int( rand(99999999) ); $tempFile = "$today$randnum.pnactval";
    # ReadParse # Reads in GET or POST data, converts it to unescaped text, #and puts one key=value in each member of the list "@in" # Also creates key/value pairs in %in, using '\0' to #separate multiple selections # If a variable-glob parameter (e.g., *cgi_input) is passed #to ReadParse, information is stored there, rather than in #$in, @in, and #%in.
    sub ReadParse { local (*in) = @_ if @_; local ($i, $loc, $key, $val); # Read in text if ($ENV{'REQUEST_METHOD'} eq "GET") { $in = $ENV{'QUERY_STRING'}; } elsif ($ENV{'REQUEST_METHOD'} eq "POST") { read(STDIN,$in,$ENV{'CONTENT_LENGTH'}); } @in = split(/&/,$in); foreach $i (0 .. $#in) { # Convert plus's to spaces $in[$i] =~ s/\+/ /g; # Split into key and value. ($key, $val) = split(/=/,$in[$i],2); # splits on the first =. # Convert %XX from hex numbers to alphanumeric $key =~ s/%(..)/pack("c",hex($1))/ge; $val =~ s/%(..)/pack("c",hex($1))/ge; # Associate key and value $in{$key} .= "\0" if (defined($in{$key})); # \0 is the multiple se +parator $in{$key} .= $val; } return 1; # just for fun }
    As you can see it checks in the beginning portion whether $ ENV{'REQUEST_METHOD'}eq "GET" or "POST". now do i have to make any changes over here? PS: This is not the entire code(just the part of it).
      As I said earlier ... Have you even tried this out?? Monks like to help people who try stuff and get stumped. We don't do homework or assignments or tell you exactly how to do your job.

      You have a brain - use it. If you don't have the knowledge, ask about specific situations you have run into. Give us error messages. Give us things you've tried. Don't say "I have to do this and I'm stupid. Tell me what to do."

      ------
      /me wants to be the brightest bulb in the chandelier!

      Vote paco for President!

        Thanx a lot for ur advice!! I am directing the output to a file. So this is what it generates when i try to run it:
        contract_number =397011 member_id =000000003 start_date =10/01/2000 end_date =10/01/2000 Content-type: text/html Error Summary Report: No Errors in period </TABLE> <TABLE WIDTH=605 BORDER=0 CELLSPACING=0 CELLPADDING=0> <TR><TD COLSPAN="3">&nbsp;</TD></TR> <TR><TD COLSPAN="3" ALIGN=center><FORM NAME="Contract Query" METHOD="p +ost" ACTION="D:/rsc/rscdetail2"><INPUT TYPE=HIDDEN NAME="prev_contrac +t" VALUE=""> <INPUT TYPE=HIDDEN NAME="prev_start" VALUE="08/21/2001"> <INPUT TYPE=HIDDEN NAME="prev_end" VALUE="08/21/2001"> <INPUT TYPE=SUBMIT VALUE=Back></FORM></TD></TR> runtime=0 second(s)
        First 4 lines are just prints. I tried to test whether the inputs are getting passed from Java to Perl.