summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--SUBS.pl16
1 files changed, 16 insertions, 0 deletions
diff --git a/SUBS.pl b/SUBS.pl
new file mode 100644
index 0000000..1084877
--- /dev/null
+++ b/SUBS.pl
@@ -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);