Forum     

Go Back   Digit Technology Discussion Forum > Software > Programming
Register FAQ Calendar Mark Forums Read

Programming The destination for developers - C, C++, Java, Python and the lot


Closed Thread
 
LinkBack Thread Tools Display Modes
Old 17-10-2009, 12:22 PM   #1 (permalink)
nix
Senior Member
 
nix's Avatar
 
Join Date: Oct 2004
Location: Bangalore
Posts: 648
Default perl:regarding commas and semicolons


i have inserted a program below.
as seen below, some statements use semicolons and some use commas, there seems to be no definite rule to follow, can anyone enlighten me on this? thanks...
Code:
 1 #!/usr/bin/perl
  2 use strict;
  3 use CGI':standard';
  4 if(param)
  5 {
  6         my $entry=param('entry');
  7         print header(),
  8         start_html("Program 7b"),
  9         #ignorecomment1
 10        #ignorecomment2
 11         h3("result is "),
 12         `$entry`,
 13         end_html();
 14 }
 15 else
 16 {
 17         print header(),
 18         start_html("Program 7b"),
 19         start_form(),
 20         print ("Enter a valid unix command");
 21         hr(),
 22         textfield(-name=>'entry'),
 23         submit(-value=>'submit now'),
 24         end_form(),
 25         end_html();
 26 }
Code:
 1 #! /usr/bin/perl
  2 use strict;
  3 use CGI':standard';
  4 if(param)
  5 {
  6         my $cmd=param('command');
  7         if(`$cmd`)
  8         {
  9                 print header(),
 10                 start_html();
 11                 print("Result is");
 12                 `$cmd`;
 13                 end_html();
 14         }
 15         else
 16         {
 17                 print("nothing entered");
 18         }
 19 }
 20 else
 21 {
 22         print header(),
 23         start_html(),
 24         start_form(),
 25         h4("enter valid UNIX command"),
 26         hr(),textfield(-name=>'command'),
 27         submit(-value=>'submit'),
 28         end_form(),
 29         end_html();
 30 }
 31
__________________
nikhilspoliticalblog.wordpress.com- Common man bows to amitabh
nix is offline  
Advertisements. Register and be a member of the community to get rid of them.
Advertisement

Old 18-10-2009, 04:00 PM   #2 (permalink)
Broken In
 
Join Date: Oct 2008
Posts: 133
Default Re: perl:regarding commas and semicolons

if i remember it rite then , is used to separate the arguments and ; is used for statement termination
lucifer_is_back is offline  
Old 18-10-2009, 05:32 PM   #3 (permalink)
nix
Senior Member
 
nix's Avatar
 
Join Date: Oct 2004
Location: Bangalore
Posts: 648
Default Re: perl:regarding commas and semicolons

thanks, but i still have not got it clearly. i guess its because i use the vi editor to type my perl programs. teacher doesnt know either. looked all over the net, but no answers. thanks anyway.
__________________
nikhilspoliticalblog.wordpress.com- Common man bows to amitabh
nix is offline  
Old 18-10-2009, 09:06 PM   #4 (permalink)
Broken In
 
Join Date: Oct 2008
Posts: 133
Default Re: perl:regarding commas and semicolons

Quote:
Originally Posted by nix View Post
thanks, but i still have not got it clearly. i guess its because i use the vi editor to type my perl programs. teacher doesnt know either. looked all over the net, but no answers. thanks anyway.
lol
its simple what dont u understand
lucifer_is_back is offline  
Old 18-10-2009, 11:17 PM   #5 (permalink)
nix
Senior Member
 
nix's Avatar
 
Join Date: Oct 2004
Location: Bangalore
Posts: 648
Default Re: perl:regarding commas and semicolons

^ well, The behavior of commas and semicolons does not seem to be consistent in my programs. As you see in the programs that I attached in the first post, "start_html" in the first program ends with a comma, but the same thing ends with a semicolon in the second program. If I edit the "start_html" in the first program to end with a semicolon, I get errors. I don't understand why. Why can't both the "start_html" statements end with a semicolon?
__________________
nikhilspoliticalblog.wordpress.com- Common man bows to amitabh
nix is offline  
Old 18-10-2009, 11:38 PM   #6 (permalink)
Broken In
 
Join Date: Oct 2008
Posts: 133
Default Re: perl:regarding commas and semicolons

because in first code snippet start_html function is passed as one of the parameters to print statement
Quote:
print header(), start_html("Program 7b"),h3("result is "),`$entry`,end_html();


but in second snippet start_html function it is the last parameter
Quote:
print header(),start_html();
lucifer_is_back is offline  
Old 19-10-2009, 10:20 PM   #7 (permalink)
nix
Senior Member
 
nix's Avatar
 
Join Date: Oct 2004
Location: Bangalore
Posts: 648
Default Re: perl:regarding commas and semicolons

^ got it, cleared. thanks for your time, i appreciate it.
__________________
nikhilspoliticalblog.wordpress.com- Common man bows to amitabh
nix is offline  
Closed Thread

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


 
Latest Threads
- by Charan
- by Charan
- by clmlbx

Advertisement




All times are GMT +5.5. The time now is 03:11 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.

Search Engine Optimization by vBSEO 3.3.2