473,663 Members | 2,854 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 1477
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
2461
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 the amount of records for a particular date is positive, i want the form to stop running, if there are no records that contain the date in question, then it should continue to run the form. The problem i'm having is referencing the date that is...
8
1639
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. Actually, the first release of this 'port' is be a simple rebuild of the unmanaged C++ SDK in VS.NET. I have done this part already, using VS.NET 2003.
31
1796
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
16058
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 application has to pick up a .m3u playlist, create any needed directories on the memory card and copy across the .AAC files. It also needs to delete the files and empty directories from the memory card when I want to remove a playlist.
7
1761
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 thankyou message). I get the following results: 1-if an error,action is set to same page(page1) 2-if no error,action is still set to same page(page1) 3-if no error,and I submit from page1 that is displaying an error,action is then set to...
41
18162
by: Miroslaw Makowiecki | last post by:
Where can I download Comeau compiler as a trial version? Thanks in advice.
2
1298
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 it, if no mail "No messages found" and if there not logged in the { else } stament.. <? if (logincheck($uid, $upwd)) { echo ("<p align=\"left\"><br /><font color=\"#666666\" size=\"1\" face=\"Arial\"><a href=\"{$_SERVER}\">Check...
7
5047
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 Range("I5:I9").NumberFormat = "0.00%" Then Range("H5:I9").SelectSelection.NumberFormat = ";;;" Else: If Range("H5:I9").NumberFormat = ";;;" Then Range("H5:I9").Select Selection.NumberFormat = "General" Range("I5:I9").Select Selection.NumberFormat = "0.00%"
3
2102
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 = Top bar M = Main menu bar N = No menu
0
8436
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8345
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8771
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8634
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7371
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6186
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5657
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4182
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
1757
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.