Uzma Shaikh has asked for the wisdom of the Perl Monks concerning the following question:
Hello everyone, I am writing a script where I have to take multi fasta file as input if I am using open() then its giveing me correct result, but if file name is not given in open() function then ask for user input. Can anyone please help me with user input. I am attaching my code
#!/usr/bin/perl use strict; use warnings; my $FILE; open (my $out, ">output.txt"); if (open $FILE, "<", 'chr.fa') { } else { print "Enter file name:\t"; $FILE=<STDIN>; } local $/ = ">"; my $count = 0; while (<$FILE>) { chomp; if ( $_ =~ /^(.*?)$(.*)$/ms) { my $header = $1; my $seq = $2; $seq =~ s/\s//g; while ( $seq =~ /([AAGC)/g) { print $out $1, "\n"; $count = $count +1; } } } print $out "$count sequences were found\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: if user provide input file use that in open() function instead
by hippo (Archbishop) on Nov 01, 2018 at 11:16 UTC | |
|
Re: if user provide input file use that in open() function istead
by BillKSmith (Monsignor) on Nov 01, 2018 at 14:55 UTC |