fork download
  1. #use warnings;
  2. my @iparray=("the","the");
  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. while($temp>=$lowerlimit)
  24. {
  25. $word=substr($sortedarray[$temp],$mat,length($sortedarray[$temp]));
  26. if($word eq "")
  27. {
  28. push @oparray,"\\s";
  29. }
  30. else
  31. {
  32. push @oparray ,$word;
  33. }
  34. $temp--;
  35. }
  36. print @oparray;
  37. if($upperlimit==scalar(@sortedarray))
  38. {
  39. print "All the words are parsed";
  40. last;
  41. }
  42. else
  43. {
  44. $lowerlimit=$upperlimit+1;
  45. $count=$lowerlimit;
  46. $inc=1;
  47. func();
  48. }
  49. }
  50. }
  51. sub func
  52. {
  53. if(($sortedarray[$count+1]) eq "\s")
  54. {
  55. last;
  56. }
  57. $base=substr($sortedarray[$count],0,$inc);
  58. $match=substr($sortedarray[$count+1],0,$inc);
  59. print("\n",$base," ",$match);
  60. $count++;
  61. if($base ne $match)
  62. {
  63. if($sortedarray[$count-1] eq $sortedarray[$lowerlimit])
  64. {
  65. $mat=$inc-1;
  66. print $mat;
  67. splitter();
  68. }
  69. else
  70. {
  71. $inc++;
  72. $count=$lowerlimit;
  73. func();
  74. }
  75. }
  76. else
  77. {
  78. $upperlimit=$count;
  79. func();
  80. }
  81. }
  82. func();
  83.  
Runtime error #stdin #stdout 0.11s 24752KB
stdin
Standard input is empty
stdout
t t
t 0
t 0