Solved

some basic perl questions

Posted on 2004-04-11
6
215 Views
Last Modified: 2008-02-20
Hi,
 I am working on a code created by someone else in perl.
Since I am new to perl, I coudln't understand few things
in the program(though the program works perfectly)

1) For every function being called in the program the first print statement is
repeated twice , but in the output only one of the statement is printed. I tried
to remove one of the print statement, but the other print statement also doesn't
print, looks strange and weard, but I dont understand the reasoning behind it.

2) The program is called from the web url like
complete_path/program.pl?input1=something&input2=something&input3=something

It works perfectly when given input from the url, but when I tried
to execute it from Unix prompt by calling
perl program.pl input1=something&input2=something&input3=something

except for the first input rest are not assigned. Since I am new
to perl I believe it could be because of the param function being used.

like the function calls a CGI at first
$a = new CGI;
foreach($a->param)


I assume that the program supports only input throught URL(CGI mode) or
I am giving in the inputformat in a wrong way.

3) When the program is called it executed properly, but the IE screen is blank, in
order to view the output I have to look into view source, which has the proper output.
Is there a way to print the output on screen itself, I mean on the Internet Explorer.

Shankar
0
Comment
Question by:shanky1978
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 3

Expert Comment

by:prady_21
ID: 10803073
post the program here
0
 
LVL 20

Accepted Solution

by:
jmcg earned 125 total points
ID: 10803283
Even if you cannot post the entire script (do not post it if it bears copyright notices or if it is proprietary software), you could post a couple of lines giving an example of the first part of your question, the part relating to print statements.

Programs using the CGI module can be run from the command line but you need to be careful how you set them up for accepting their input. The shell syntax is sensitive to some of the characters, such as "&", so without quotes or other suitable treatment, the shell will split that line you showed into three separate commands. Thus:

   perl program.pl "input1=something&input2=something&input3=something"

would probably work.

There are a number of conditions that would cause IE to display a blank page even though the page contained something. It sounds as if there may be some malformed HTML being output, but without seeing a sample, I'm afraid I'm just guessing.
0
 
LVL 84

Expert Comment

by:ozo
ID: 10803383
You can call it from the command line as
perl program.pl input1=something input2=something input3=something

(to unix command shells, & means to run processes simultaneously)
0
[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

 

Author Comment

by:shanky1978
ID: 10805986
Hi,
 Thanks. I tried passing the input as you said and it does work. I am attaching the sample of the code, for the print statement issue. I am new to perl, but the logic here is really simple and still I dont understand why there are two print statements.

sub output
{
  my @args=@_;
  my $first = shift(@args);

 print"<first line of the output>\n";
# (this statement is ignored, it doesn't get printed but if i remove this line first line inside
# the if statement doesn't get printed)
 if ($first !~/^1.0$/)
      {
        print"<first line of the output>\n";
        print "<second line of the output>\n";
        print "<third line of the output>\n";
        return;
       }

#(Similarly in the following 2 lines only one of them is printed, if i remove or comment one of them
# the first line doesn't get printed)
          print"<first line of the output>\n";
        print"<first line of the output>\n";
        print "<second line of the output>\n";
        print "<third line of the output>\n";
        return;
}

Shankar
0
 
LVL 20

Expert Comment

by:jmcg
ID: 10806948
That's certainly peculiar, but I can't help thinking that your extraction of the examples has left out some vital clue. When I try this code with the version of Perl that I'm running here, every print statement works normally; no lines are missing.

You're working in a CGI context, right? At what point is the content-type header being printed? That would be one way for a line of printing to go missing -- if it were seen by the browser as part of the header. That might also be consistent with the other problem you mentioned, of IE displaying a blank page, which it may do because the HTML is incorrectly laid out.
0
 

Author Comment

by:shanky1978
ID: 10807955
Hi,
  Again thanks a lot , as u have mentioned the content type tag was commented(it had an # in front of it) and once I removed thats it started working normally. I think the previous programmer would have missed to see that # in front of the content type tag(infact even I had missed it, only aftet you mentioned  I noticed it). Once it was fixed both the print problem as well as the one in IE was solved.

Thanks .

Shankar


0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question