473,387 Members | 1,687 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Conditional only seeing last condition?

I have a perl script that goes to write to a file based on whether a string contains A, B, C, or D.
The string are populated from a read in file and all letters are absolutely contained in the file and being read.
Such as this:

Expand|Select|Wrap|Line Numbers
  1. if (($myString eq "A") ||  ($myString eq "B") || ($myString eq "C") || ($myString eq "D"))
  2. {
  3. print OUTFILE "print some stuff";
  4. }
  5.  
My problem is that whichever condition is last will be written to the file. (In this case D) If I changed the last condition to A then I would only see A's in the output.

Is there something wrong with my conditional statement?
Nov 12 '12 #1
1 1435
RonB
589 Expert Mod 512MB
Can you show us the contents of the file and how you're assigning $myString?

You conditional could be cleaned up. Try this:
Expand|Select|Wrap|Line Numbers
  1. if ( $myString =~ /^[ABCD]$/ ) {
  2.     print OUTFILE "print some stuff";
  3. }
Nov 12 '12 #2

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

Similar topics

36
by: Remi Villatel | last post by:
Hi there, There is always a "nice" way to do things in Python but this time I can't find one. What I'm trying to achieve is a conditionnal loop of which the condition test would be done at...
10
by: Québec | last post by:
Hi every body, What does that mean? The following script raises the subject alarm. <p><a href="javascript:void();" onClick="mailto:sgagnon@cyberus.ca?Subject=BRITTANY&nbsp;WORKSHOP"> <img...
8
by: Dimitri Furman | last post by:
Given: Access 2002/2003 A subform in datasheet or continuous view, placed on a tab page (this last may or may not matter) Conditional formatting applied to some controls on the subform - format...
6
by: Chris Dunaway | last post by:
Consider this code (.Net 2.0) which uses a nullable type: private void button1_Click(object sender, System.EventArgs e) { DateTime? nullableDate; nullableDate = (condition) ? null :...
3
by: John | last post by:
Hi I have an app to deal with two companies A & B within a group of companies depending on which database is selected. Is it possible for setup to ask the user at install time which company they...
8
by: Typehigh | last post by:
I have many text fields with conditional formatting applied, specifically when the condition is "Field Has Focus". Without any events associated with the fields the conditional formatting works...
3
by: Martijn | last post by:
Hi, I hope I am in the right place on preprocessor help, 'cause the GNU preprocessor documentation is somewhat minimal on this topic. Assume I have two #define'd constants: #define STRING1 ...
37
by: at | last post by:
I would like to spark the discussion about the following syntax problem I encounter. THE PROBLEM I have a lot times the following code: for x in : if x 0: ... more code...
4
by: digz | last post by:
Hi, I am having a lot of trouble setting conditional breakpoints in gdb, here is a simple example... #include<string> #include<iostream> using namespace std; void func(string& s){ cout <<...
3
gnawoncents
by: gnawoncents | last post by:
Greetings, I am having some trouble with setting up conditional formatting from VBA for a datasheet. The pertinent part of my code is listed below. I'm running a loop and each field will get one...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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,...

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.