Which version of Perl are you using?
IWFM
#!/usr/bin/perl -w use strict; printf "Perl %vd\n",$^V; while(<DATA>){ print $_; for my $letter ('a' .. 'z') { my $index = index($_,$letter); next if $index < 0; print "The first occurence of '$letter' is: ", $index, "\n"; } print "\n\n"; } __DATA__ ATGGACTGCACCTGGAGGATCCTCTTCTTGGTGGCAGCAGCTACAGgcaagagaatcctgagttccaggg +ctgatgaggg
Output:
Perl 5.6.1 ATGGACTGCACCTGGAGGATCCTCTTCTTGGTGGCAGCAGCTACAGgcaagagaatcctgagttccagggctgatgaggg The first occurence of 'a' is: 48 The first occurence of 'c' is: 47 The first occurence of 'g' is: 46 The first occurence of 't' is: 55 Perl 5.8.4 ATGGACTGCACCTGGAGGATCCTCTTCTTGGTGGCAGCAGCTACAGgcaagagaatcctgagttccagggctgatgaggg The first occurence of 'a' is: 48 The first occurence of 'c' is: 47 The first occurence of 'g' is: 46 The first occurence of 't' is: 55
In reply to Re: Funny results of "index"
by Anonymous Monk
in thread Funny results of "index"
by jkmiller
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |