•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Perl section within the Software Development category of DaniWeb, a massive community of 423,562 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,639 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Perl advertiser: Programming Forums
Views: 1585 | Replies: 14
![]() |
•
•
Join Date: Oct 2007
Posts: 41
Reputation:
Rep Power: 1
Solved Threads: 0
thanks
this is what my current code looks like.
But I still cant make it stop once it gets a (">") and then output the result
and then again start concatenating till it finds the next ('>') or stop if end of file is reached
this is what my current code looks like.
But I still cant make it stop once it gets a (">") and then output the result
and then again start concatenating till it finds the next ('>') or stop if end of file is reached
#!/usr/bin/perl -w
use strict;
use warnings;
my ($fileName, $firstSequence, $lastSequence) = @ARGV;
open (IN, "<$fileName") || die "Can't open $fileName";
my $line;
my @line=();
OUTER2: while (my $l = <IN>){
if($l eq ""){last EXIT2;}
if ($l =~ />/) {
print "$l\n";
next;
}
chomp($l);
$line .= $l;
}
@line = split(//, $line);
print @line[$firstSequence-1..$lastSequence-1];
last OUTER2;
EXIT2: close(IN); Hello Mank,
I think you have not understood what
Probably you have to read documentation before you start doing it again. Type this in your command prompt and go through it,
katharnakh.
I think you have not understood what
last LABEL in perl does. Why are you using last in your code? I dont understand this in your code•
•
•
•
...
last OUTER2; # why?
Probably you have to read documentation before you start doing it again. Type this in your command prompt and go through it,
perldoc -f last.katharnakh.
Last edited by katharnakh : Mar 26th, 2008 at 6:17 am.
challenge the limits
•
•
Join Date: Oct 2007
Posts: 41
Reputation:
Rep Power: 1
Solved Threads: 0
yes
I dont want to use that label there, its just going to re-read my file,
I dont want to do that, I just want to make sure @line has all the sequence after line containng ">" to line containing ">"
so its like
>label1
data1.....
data2......
data3......
>label2
data1....
data2...
data3...
so I want
>label1
data1.....data2.....data3.....
>label2
data1.....data2.....data3.....
then @line[$seq1..$seq2] wiill contain all data from data2 to data3 for each sequence
I dont want to use that label there, its just going to re-read my file,
I dont want to do that, I just want to make sure @line has all the sequence after line containng ">" to line containing ">"
so its like
>label1
data1.....
data2......
data3......
>label2
data1....
data2...
data3...
so I want
>label1
data1.....data2.....data3.....
>label2
data1.....data2.....data3.....
then @line[$seq1..$seq2] wiill contain all data from data2 to data3 for each sequence
then you got to do within your while loop itself. Because, within the while loop itself you will read entire file.
So while reading the file itself you will you print whatever you want. If you want to re read the file, then you must either
Hope you understand.
katharnakh.
So while reading the file itself you will you print whatever you want. If you want to re read the file, then you must either
seek() the start of the file or close the file and reopen and read the file.Hope you understand.
katharnakh.
Last edited by katharnakh : Mar 26th, 2008 at 8:00 am.
challenge the limits
![]() |
•
•
•
•
•
•
•
•
DaniWeb Perl Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Similar Threads
- Noob needs help i/o file data (Python)
- Count number of occurrences of a character search it in a file (C++)
- File Processing C++ (C++)
- problem with svchost.exe (Windows NT / 2000 / XP / 2003)
- reading a file into code (Java)
- Text File Input and manipulation (C++)
- I need special stuff in my project like system("cls") (C++)
Other Threads in the Perl Forum
- Previous Thread: merging two files and removing duplicates
- Next Thread: blast crashed


Linear Mode