Yeah, the parameters keep changing because my buddy and I had incorrectly remembered the format it was supposd to be (several times). Sorry about that. Anyway, what you provided did work with some changes. the code you sent didn't do anything other than give me the command promt again - but I managed to get it to work anyway. However, I can't seem to figure out why I cannot use this line:
my @char = ( split( // ), ( '-' ) x ( $len - length ) ); instead of this line: my @char = ( /[a-z]/ig, ( '-' ) x $len )[ 0 .. $len - 1 ]; in the script - I get errors ( I mean there are other changes that need to be made but these lines are my major focus). I just like the way the first line of code calculates the amount of dashes to add. It's just an aesthetic thing. :-) Note I changed it to a-z because we use many other characters than "atcg", for example "n" means "unkown base". Also, just do not understand as clearly the second line of code above as I do the first. From what I can gather you are making, say, 50 dashes and then "filling in" the dashes that match the charatcers within [a-z] from left to right as long as there are characters to "fill in" the dashes. Does that make sense? Anyway, when I add "$/ = '>';" to the original script below I get a contatination error (why?). Basically, I am trying to understand why certain bits of code "break" the script and others don't. I find I learn things better by trying alternate forms of code to figure out relationships. However, I have been looking through my perl books like crazy and can't seem to understand some of these relationships. I know it will take time and experience... I guess I'll pick up another perl book that provides another perspective. Sorry about taking so long with this, I am trying to make an honest effort to learn. :-) -Thanks -Mike In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] (John W. Krahn) wrote: > Mike wrote: > > > > Well this is the final code I put together with everyones help from this > > group: > > > > #!/usr/bin/perl > > use warnings; > > use strict; > > > > print "Enter the path of the INFILE to be processed:\n"; > > chomp (my $infile = <STDIN>); > > open(INFILE, $infile) > > or die "Can't open INFILE for input: $!"; > > print "Enter in the path of the OUTFILE:\n"; > > chomp (my $outfile = <STDIN>); > > open(OUTFILE, ">$outfile") > > or die "Can't open OUTFILE for input: $!"; > > print "Enter in the LENGTH you want the sequence to be:\n"; > > chomp (my $len = <STDIN>); > > > > my ($name, @seq); > > while ( <INFILE> ) { > > chomp; > > unless ( /^\s*$/ or s/^\s*>(.+)// ) { > > $name = $1; > > my @char = ( split( // ), ( '-' ) x ( $len - length ) ); > > push @seq, ' '."@char $name"; > > } > > } > > > > { > > local $" ="\n"; > > print OUTFILE "R 1 [EMAIL PROTECTED]"; # The top of the file is > > supposed > > > > } > > > > close INFILE; > > close OUTFILE; > > > > [snip] > > > > However, I forgot that sometime the imput data is like this: > > > > >dog > > agatgtagt > > agtggttga > > agggagc > > >cat > > gcatcgatg > > agcatatgc > > >mouse > > actagcatc > > acgtacgat > > > > That is the sequence of letters can span multiple lines. I would like > > the above script to handle input data that can possibly span several > > lines as well as those that do not. and output as mentioned above. > > You keep changing the specs Mike. :-) Based on your code and data above, > this will work: > > #!/usr/bin/perl > use warnings; > use strict; > > print "Enter the path of the INFILE to be processed: "; > chomp( my $infile = <STDIN> ); > open INFILE, $infile or die "Can't open $infile for input: $!"; > > print "Enter in the path of the OUTFILE: "; > chomp( my $outfile = <STDIN> ); > open OUTFILE, ">$outfile" or die "Can't open $outfile for output: $!"; > > print "Enter in the LENGTH you want the sequence to be: "; > my ( $len ) = <STDIN> =~ /(\d+)/ or die "Invalid length parameter"; > > print OUTFILE "R 1 $len\n\n"; # The top of the file is supposed > > $/ = '>'; # Set input record separator > > while ( <INFILE> ) { > chomp; > next unless s/^\s*(\S+)//; > my $name = $1; > my @char = ( /[acgt]/g, ( '-' ) x $len )[ 0 .. $len - 1 ]; > print OUTFILE " @char $name\n"; > } > > close INFILE; > close OUTFILE; > > __END__ > > > > John -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]