agustina_s has asked for the wisdom of the Perl Monks concerning the following question:
I'm going to read the input, make some changes and then write it back to the output files. I am a little bit confused with the input separator since at first I have set it to //\n and then for each records I want to examine it line by line.COMMERCIAL SUPPLIERS SEQUENCE /toxin_start="19-94" /translation="MKFFLMCLIIFPIMGVLGKKNGYPL + CWGACYCFGLEDDKPIGPMKDITKKYCDVQIIPS" AA ALIGNMENT full-length{%scorpProtein}, sodium-family{%scorpNA}, putative-group1{% +Nag01}, putative-group1c{%Nag01c} ORIGIN 1 acaaaataaa gtgaacttct gaaatcagca cgataaaaag aaacgaaaat gaaatttttc // COMMERCIAL SUPPLIERS SEQUENCE /toxin_start="19-94" /fragment_start="?" CWGACYCFGLEDDKPIGPMKDITKKYCDVQIIPS" AA ALIGNMENT full-length{%scorpProtein}, sodium-family{%scorpNA}, putative-group1{% +Nag01}, putative-group1c{%Nag01c} ORIGIN 1 aaaataaagt gaacttctga aatcagcacg ataaaaagaa acgaaaatga aattt +ttctt 61 aatgtgtctt atcatcttcc caattatggg agtgcttggc aaaaagaacg gatat +cctct //
I have tried to put a counter in my code but there the program never stop running.
I have tried to doI compile the prog using: perl prog.pl input.db result #!/usr/bin/perl my $input = $ARGV[0]; my $output = ">" . $ARGV[1]; my $counter=1; open(INPUT, $input) or die "Can't open $input."; open(OUTPUT, $output) or die "Can't open $output."; $/="\/\/\n"; # Use shorthand for reading file. while (<>) { print OUTPUT $_; print $counter; $counter++; } print "Success\n"; close (INPUT); close (OUTPUT);
instead of just while(<>) but it only print the counter once. Is there something wrong with the code? And if I want to read/modify each line in the record where should I set the $\ back to \n? Thank you in advanced.> while(<INPUT>)
Sincerely
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: about separator
by tachyon (Chancellor) on Jan 31, 2002 at 13:00 UTC | |
|
Re: about separator
by Hofmator (Curate) on Jan 31, 2002 at 13:46 UTC | |
|
Re: about separator
by talexb (Chancellor) on Jan 31, 2002 at 13:24 UTC |