473,402 Members | 2,064 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,402 software developers and data experts.

filehandle

Hello people..I just wanted to know that can we store number of files in a filehandle ..if yes how could we do that???I did write a program but its just parsing result from the file which I'm giving at first position.
Thanx in advance !!
Sep 21 '08 #1
7 1662
KevinADC
4,059 Expert 2GB
Post some code, your question is confusing.
Sep 21 '08 #2
I have written this code.The output of this code should be total number of individual bases in both the files.
But the output is showing only total number of bases in first file i.e, pdb.txt.
I hope I made my question clear this time??Let me knw if u want some other information.Thanx in advance!!
Expand|Select|Wrap|Line Numbers
  1. #!usr/bin/perl
  2. $/=undef;
  3.     $file1='C:\Users\documents\pdb.txt';
  4.     $file2='C:\Users\documents\pdb1.txt';
  5.     @files=($file1,$file2);
  6.     foreach $file(@files)
  7.     {
  8.     open(IN,$file) or "die error opening $file";
  9.     $data=<IN>;
  10.     $data1=reverse $data;
  11.     $data2=length $data1;
  12.     print"\nlength of sequence is $data2\n"; 
  13.     print"\nlength of sequence is $data1\n";
  14.     $a=($data=~tr/a/A/);
  15.     $t=($data=~tr/t/T/);
  16.     $g=($data=~tr/g/G/);
  17.     $c=($data=~tr/c/C/);
  18.  
  19.     $total=($a+$t+$g+$c);
  20.     }
  21.  
  22. print"The total number of adenine   are : $a\n";
  23. print"The total number of Thymine  are : $t\n";
  24. print"The total number of Guanine  are : $g\n";
  25. print"The total number of Cytosine are : $c\n";
  26. print"The total bases are $total";
  27.  
Sep 26 '08 #3
KevinADC
4,059 Expert 2GB
probably you need to change this line:

Expand|Select|Wrap|Line Numbers
  1. $total=($a+$t+$g+$c);
that overwrites the value of $total instead of summing all the values across all files:

try using "+=" instead of "=":

Expand|Select|Wrap|Line Numbers
  1. $total += ($a+$t+$g+$c);
Same for all of these if you want a sum across all files:

Expand|Select|Wrap|Line Numbers
  1. $a += ($data=~tr/a/A/);
  2. $t += ($data=~tr/t/T/);
  3. $g += ($data=~tr/g/G/);
  4. $c += ($data=~tr/c/C/);
  5.  
Sep 26 '08 #4
yah...now its working...but not giving correct result... coz if I have 10 letters /bases in one of the file its showing 16...why??And how do I remove it??
Sep 26 '08 #5
KevinADC
4,059 Expert 2GB
Without seeing your data how do you expect me or anyone to know?
Sep 26 '08 #6
I have two files having just lines of bases...like this
AGTGCCGTA and no other lines....
Sep 27 '08 #7
KevinADC
4,059 Expert 2GB
I have two files having just lines of bases...like this
AGTGCCGTA and no other lines....
There is no way to debug the problem when you post one line of data. Post the real data you say gives incorrect results.
Sep 27 '08 #8

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

Similar topics

2
by: Jorge Godoy | last post by:
Hi! I'm trying to get a specific information from inside an image and it works correctly on unices. What I do is: 1. associate a filehandle with the image file 2. get the desired line 3....
1
by: Eduard W. Lohmann | last post by:
Hello. I write this little thing to help me log from several instances of the same class in apache, mod_perl. But I can't figure one thing out. package Logger; require Carp; # Write the...
2
by: Bill | last post by:
I'm trying to use a hash key as a filehandle like so. #!/usr/local/bin/perl use strict; my %buf = ( 'F00' => 'foo.dat' ); &open_files();
1
by: Christopher Reeve | last post by:
Hi, I wonder if anyone could help me. I am moving accross from C to C++ and am writing a program that reads and writes data into a file. I am aware of the old C ways of doing it but am trying to...
1
by: Wijaya Edward | last post by:
Hi all, I have the following code: import sys import re ham_count = 0 spam_count = 0
5
by: Cliff Martin | last post by:
Hi, I am writing a simple filter type program that can take input from file or stdin, and output to a file or stdout. It would make life much easier if I could assign cin to a ifstream object...
1
by: Zairay | last post by:
Hi All, I'm having a problem with the Shell32.dll when I try to open a program from my Access db. When I try to open a program called FalconViewLite from my access database I get an error in...
1
by: Jeff Williams | last post by:
I have a picture (jpg) displaying in a picture box but I find that the file handle is still open to the image on disk. I think I need the following to happen 1. Load image from file on disk...
3
by: onlineviewer | last post by:
Hello All, Can someone help me out with how to go about printing to a variable rather than to a file using filehandles. Below i have it in perl, how do i get this going in php. Thanks in...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: 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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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...
0
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,...

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.