473,395 Members | 1,701 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,395 software developers and data experts.

range operator problems

Hi All
I am trying to extract a range of columns from a tab separated file.

The range which i want to extract is between 99.00 to 100.00 but when I tried to run the program its returning 0 results.

Expand|Select|Wrap|Line Numbers
  1. #!/usr/bin/perl
  2. use strict;
  3. use warnings;
  4.  
  5. open(FH,"tabular_comment");
  6. my $cnt=0;
  7. while(<FH>)
  8. {
  9.     if($_=~/^#/)
  10.     {
  11.         next;
  12.     }
  13.     my @temp = split(/\t/,$_);
  14.     if($temp[2]=~/99.00 .. 100.00/)
  15.     {
  16.         $cnt +=1;
  17.     }
  18. }
  19. print $cnt;
  20.  
Thanks for help
Nov 20 '07 #1
4 1115
KevinADC
4,059 Expert 2GB
can we see some sample data please.
Nov 21 '07 #2
numberwhun
3,509 Expert Mod 2GB
can we see some sample data please.

Agreed, please share a sample of your data.

Regards,

Jeff
Nov 21 '07 #3
Hi all,
sorry for the late reply.....sample data is posted and i am trying to extract the 3rd column values in the range 99.00 to 100.00....
Expand|Select|Wrap|Line Numbers
  1. EGFR_HUMAN_P00533    gi|58177366|pdb|1XKK|A    100.00    268    0    0    1    268    42    309    7e-162     564
  2. EGFR_HUMAN_P00533    gi|23200417|pdb|1M14|A    100.00    268    0    0    1    268    23    290    8e-162     564
  3. EGFR_HUMAN_P00533    gi|110590401|pdb|2GS2|A    100.00    268    0    0    1    268    20    287    1e-161     563
  4. EGFR_HUMAN_P00533    gi|134104655|pdb|2J5F|A    100.00    268    0    0    1    268    17    284    2e-161     563
  5. EGFR_HUMAN_P00533    gi|110590405|pdb|2GS7|A    99.63    268    1    0    1    268    20    287    7e-161     561
  6. EGFR_HUMAN_P00533    gi|145579717|pdb|2ITT|A    99.63    268    1    0    1    268    17    284    8e-161     561
  7. EGFR_HUMAN_P00533    gi|145579713|pdb|2ITN|A    99.63    268    1    0    1    268    17    284    1e-160     560
  8. EGFR_HUMAN_P00533    gi|134104654|pdb|2J5E|A    99.63    268    1    0    1    268    17    284    4e-160     558
  9. EGFR_HUMAN_P00533    gi|52695995|pdb|1U46|A    39.69    262    152    4    1    256    20    281    1e-53     205
  10. EGFR_HUMAN_P00533    gi|52696004|pdb|1U54|A    39.31    262    153    4    1    256    20    281    6e-53     202
  11. EGFR_HUMAN_P00533    gi|151567671|pdb|2J0J|A    37.93    261    160    2    5    265    396    654    9e-53     202
  12. EGFR_HUMAN_P00533    gi|37926803|pdb|1MP8|A    37.93    261    160    2    5    265    21    279    9e-53     202
  13. EGFR_HUMAN_P00533    gi|151567672|pdb|2J0K|A    37.93    261    160    2    5    265    396    654    1e-52     202
  14. EGFR_HUMAN_P00533    gi|118137641|pdb|2ETM|A    37.93    261    160    2    5    265    18    276    1e-52     202
  15. EGFR_HUMAN_P00533    gi|151567676|pdb|2J0M|B    37.93    261    160    2    5    265    16    274    1e-52     201
  16. EGFR_HUMAN_P00533    gi|110590407|pdb|2GSF|A    38.78    263    156    4    5    264    51    311    2e-52     201
  17.  
  18.  
thanks for your help.
Nov 26 '07 #4
numberwhun
3,509 Expert Mod 2GB
Ok, I took your data and plugged it into a file called data.txt and wrote the following quick Perl script. This matches either 99. or 100. in the third column and prints it out.

Hope this was what you wanted.

Expand|Select|Wrap|Line Numbers
  1. use strict;
  2. use warnings;
  3.  
  4. open(FILE, "data.txt");
  5.  
  6. my @line;
  7.  
  8. while(<FILE>)
  9. {
  10.     @line = split(/\t/, $_);
  11.  
  12.     if($line[2] =~ m/99\.|100\./)
  13.     {
  14.         print "$line[2]\n";
  15.     }
  16. }
  17.  
Regards,

Jeff
Nov 26 '07 #5

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

Similar topics

1
by: Paul Porcelli | last post by:
I have the following code(excerpt) which grabs some lines from a syslog file and adds any found in the range to an array. @lines=();@vvlines=(); $t = new Net::Telnet (Timeout => 30, Prompt =>...
11
by: Jason Heyes | last post by:
I would like to be able to extract an integer from a stream without having to write a test when I want the integer within some range. Unfortunately there is no range-checked integer type in the...
3
by: mk | last post by:
I will have 2 build types of my program: debug and release. In debug build I want std::vector indexing operation (operator or at()) to do a range-check. In release build I don't want it. What is...
67
by: carlos | last post by:
Curious: Why wasnt a primitive exponentiation operator not added to C99? And, are there requests to do so in the next std revision? Justification for doing so: C and C++ are increasingly used...
5
by: Chris | last post by:
Hey all. Anyone who is familiar with Python programming knows that you can have code like this: list = This code puts all the items processed by the for loop in a list plus 1. Is there a way...
7
by: Joe Van Dyk | last post by:
Hi, Say I have: class Latitude { friend bool operator==(const Latitude& lhs, const Latitude& rhs); friend bool operator<(const Latitude& lhs, const Latitude& rhs); friend std::ostream&...
0
by: toton | last post by:
Hi, I have a view class for a vector, which stores different range for a few vectors, and provides a way to iterate over the range. The range class takes a pair of iterator, as given in post...
2
by: toton | last post by:
Hi, I am trying to use boost::range with one of my own container class, and having some problem. I am missing some usage of range. Can anyone suggest a proper way for it ? To show the problem...
3
by: erik gartz | last post by:
Hello, I'm new to python and I'm having difficulty understanding the following code. Why doesn't the variable a contain , ] instead. Doesn't {} allocate new memory for the dictionary each time?...
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...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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...
0
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...

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.