fork(3) download
  1. use v5.10;
  2.  
  3. sub longest_rep{
  4. $_[0] =~ /(?=(.+)\1)(?!(??{ '.+?(..{' . length($^N) . ',})\1' }))/;
  5. }
  6.  
  7. say longest_rep '01011010';
  8. say longest_rep '010110101000110001';
  9. say longest_rep '2323191919191919';
  10. say longest_rep '22010110100';
Success #stdin #stdout 0s 4728KB
stdin
Standard input is empty
stdout
101
10001
191919
101