473,508 Members | 2,088 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Why won't the compiler read the else statement?

3 New Member
When I was running the above program it gave the result of "if" statement every time. It didn't matter if the "if Statement" was true or false.

Expand|Select|Wrap|Line Numbers
  1. #!/usr/bin/perl-w
  2. use Tk;
  3. $mw= MainWindow->new;
  4. $mw-> title ("comparison of sequence");
  5. $seq="ATATATA";
  6. $seq1="ATATCCA";
  7. $label1= $mw ->Label (-textvariable=>\$seq)->pack();
  8. $label2= $mw ->Label (-textvariable=>\$seq1)->pack();
  9. if($seq eq $seq1)
  10. {
  11. $label3=$mw->Label(-text=>"match")->pack();
  12. }
  13. else($seq ne $seq1)
  14. {
  15. $label4=$mw->Label(-text=>"mismatch")->pack();
  16. }
  17.  
  18. $button=$mw->Button(-text=>"exit",-command=>sub{exit})->pack();
  19.  
  20. MainLoop;


.
Mar 2 '11 #1
3 1467
RonB
589 Recognized Expert Moderator Contributor
Your script won't compile due to the syntax error on line 13.
Expand|Select|Wrap|Line Numbers
  1. else($seq ne $seq1)
should be:
Expand|Select|Wrap|Line Numbers
  1. elsif($seq ne $seq1)
Mar 2 '11 #2
miller
1,089 Recognized Expert Top Contributor
Or since you're just doing the opposite of your first if condition, just rely on else itself.

Expand|Select|Wrap|Line Numbers
  1. if ($seq eq $seq1) {
  2.     $label3 = $mw->Label(-text=>"match")->pack();
  3. } else {
  4.     $label4 = $mw->Label(-text=>"mismatch")->pack();
  5. }
  6.  
- Miller
Mar 3 '11 #3
merrygreat
3 New Member
thanks a lot Miller my program is now executed.
Mar 5 '11 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

6
2442
by: jstaggs39 | last post by:
I want to create a Dcount and an If...Then...Else statement to count the number of records in a table based on the date that is entered to run the form. The If....Else statment comes in because if...
8
1622
by: STG | last post by:
Greetings, My group has an SDK that was developed 5 years ago with VC++ 6. Over the last years, the requests for a VS.NET SDK has reached critical mass and I am now in the process of doing that....
31
1754
by: arun | last post by:
I know it is a free compiler. But does it follow any standard? If so which standard is it? (Ansi, Ecma, etc?)
43
16023
by: Jeremy Thomson | last post by:
I want to do some simple programming at home on my new Vista PC. Its to automate moving .AAC files to my phone's mercury card. (Nokia's application only works with USB cable or bluetooth). So the...
7
1754
by: Jankie | last post by:
I have an application with 2 pages form . If there is an error,I set the action to the same page to display the errors .If no errors,I set the action to page2.php(that both processes and echoes a...
41
18064
by: Miroslaw Makowiecki | last post by:
Where can I download Comeau compiler as a trial version? Thanks in advice.
2
1290
by: Breana | last post by:
Ok, i am making a mail system so i can mail users, and i have the table all set up no errors as of yet. But my question is how do i make an else statment 2 times. So if there is mail it will show...
7
5043
by: Stu120 | last post by:
Hi, I'm trying to code a button to hide and show data in cells H5:I9 (MS Excel 2002) Here's the code: Sub Button21_Click() If Range("H5:H9").NumberFormat = "General" And...
3
2094
by: entangled | last post by:
What do they call something like this ... <?=(($data->link_place == "T") ? "Top bar":"Main menu bar")?> ... it's sort of a if /else statement. But what if there are three possiblities T =...
0
7225
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7124
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7326
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
5629
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5053
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4707
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
1558
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
766
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
418
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.