diff options
author | Jesse Luehrs <doy@tozt.net> | 2012-10-20 05:23:43 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2012-10-20 05:23:43 -0500 |
commit | e40fd1529a0f1a6bff445ec9d157c1f1b8109c4f (patch) | |
tree | 30522dae0076a884111345ce7e9cee6bc28c844d /SUBS.pl | |
parent | edf85ef9684fa9845ae792700b48b52fe12bb476 (diff) | |
download | rosalind-e40fd1529a0f1a6bff445ec9d157c1f1b8109c4f.tar.gz rosalind-e40fd1529a0f1a6bff445ec9d157c1f1b8109c4f.zip |
another solution
Diffstat (limited to 'SUBS.pl')
-rw-r--r-- | SUBS.pl | 16 |
1 files changed, 16 insertions, 0 deletions
@@ -0,0 +1,16 @@ +#!/usr/bin/env perl +use strict; +use warnings; +use 5.016; + +chomp(my $string = <>); +chomp(my $substr = <>); +my @positions; + +my $start = 0; +while((my $pos = index($string, $substr, $start)) != -1) { + push @positions, $pos + 1; + $start = $pos + 1; +} + +say join(' ', @positions); |