1 use strict;
2 use warnings;
3
4 open FH,'<myfile.txt';
5 my $filecontent;
6 {
7 undef $/;
8 $filecontent=<FH>;
9 }
10
11 $filecontent =~ s/[\s\n]+//g;
12 # print $filecontent,"\n";
13
14 my $filesize=length($filecontent);
15
16 my $hash;
17
18 for (my $i=0; $i<=$filesize; $i++) {
19 my $mainline=substr($filecontent,$i);
20 for (my $j=2; $j <= $filesize-$i; $j++) {
21 my $subline=substr($filecontent,$i,$j);
22 my $count=0;
23 while($mainline =~ m/$subline/g) {
24 push(@{$hash->{$subline}},$-[0]) if $-[0] > 0 ;
25 }
26 }
27 }
28
29 foreach (keys %$hash) {
30 print "[$_]:@{$hash->{$_}}\n"
31 } |
|