fork download
  1. use warnings;
  2. my @iparray=("return","revert","reveal","rebel","real","relm","reign","response");
  3. my @sortedarray=sort(@iparray);
  4. my @oparray;
  5. my $lowerlimit=0;
  6. my $upperlimit;
  7. my $count=0;
  8. my $inc=1;
  9. my $mat=0;
  10. my $matchedstring;
  11. sub splitter
  12. {
  13. if($mat==0)
  14. {
  15. $lowerlimit=$lowerlimit+1;
  16. $count=$lowerlimit;
  17. func();
  18. }
  19. else
  20. {
  21. $matchedstring=substr($sortedarray[$count-1],0,$mat);
  22. my $temp=$upperlimit;
  23.  
  24. print("\n",$temp);
  25.  
  26. while($temp>=$lowerlimit)
  27. {
  28. $word=substr($sortedarray[$temp],$mat,length($sortedarray[$temp]));
  29. if($word eq "")
  30. {
  31. push @oparray,"\\s";
  32. }
  33. else
  34. {
  35. push @oparray ,$word;
  36. }
  37.  
  38. $temp--;
  39. }
  40. print ("\n",@oparray);
  41. if($upperlimit>=scalar(@sortedarray))
  42. {
  43. print "All the words are parsed";
  44. last;
  45. }
  46. else
  47. {
  48. $lowerlimit=$upperlimit+1;
  49. $count=$lowerlimit;
  50. $inc=1;
  51. func();
  52. }
  53. }
  54. }
  55. sub func
  56. {
  57. $base=substr($sortedarray[$count],0,$inc);
  58. if (defined $sortedarray[$count+1])
  59. {
  60. $match=substr($sortedarray[$count+1],0,$inc) ;
  61. }
  62. else
  63. {
  64. $s=substr($sortedarray[$count-1],0,$inc);
  65. if($s eq $base)
  66. {
  67. $upperlimit=$count;
  68. $count = $lowerlimit;
  69. $inc++;
  70. #print $inc;
  71. func();
  72. }
  73. else
  74. {
  75. last;
  76. }
  77. }
  78. print("\n",$base," ",$match);
  79. $count++;
  80. if($base ne $match)
  81. {
  82. if(($count-1) == $lowerlimit)
  83. {
  84. my $lcount=$count;
  85. my $ucount=$count+1;
  86. if($ucount>=scalar(@sortedarray))
  87. {
  88. $upperlimit=$count;
  89. $mat=$inc-1;
  90. splitter();
  91. }
  92. else
  93. {
  94. my $ulimit=$upperlimit;
  95. print("\n",$lcount,"\n",$ucount,"\n",$ulimit);
  96. while($ulimit>=$count)
  97. {
  98. my $new=substr($sortedarray[$lcount],0,$inc);
  99. print("\n",$new);
  100. my $new1=substr($sortedarray[$ucount],0,$inc);
  101. print(" ",$new1);
  102. if($new eq $new1)
  103. {
  104. $upperlimit=$lcount-1;
  105. print("\n",$upperlimit);
  106. $mat=$inc-1;
  107. print("\n",$mat);
  108. splitter();
  109. }
  110. else
  111. {
  112. $ulimit--;
  113. $lcount++;
  114. $ucount++;
  115. print("\n",$lcount,"\n",$ucount,"\n",$ulimit);
  116. }
  117. }
  118. $mat=$inc-1;
  119. print $mat;
  120. splitter();
  121. }
  122. }
  123. else
  124. {
  125. $inc++;
  126. print $inc;
  127. unless(($count) == $upperlimit)
  128. {
  129. $count=$lowerlimit;
  130. func();
  131. }
  132. }
  133. }
  134. else
  135. {
  136. $upperlimit=$count;
  137. func();
  138. }
  139. }
  140. func();
  141.  
Runtime error #stdin #stdout 0.01s 5364KB
stdin
Standard input is empty
stdout
Standard output is empty