fork download
  1. #!/usr/bin/perl
  2. # your code goes here
  3. #!/usr/bin/perl
  4. # your code goes here
  5. use warnings;
  6. use strict;
  7. sub palindrome{
  8. my $word = $_[0];
  9. my $length = length $word;
  10. if ($length <= 1)
  11. {
  12. return 1;
  13. }else{
  14. my $top_char = substr($word,0,1);
  15. my $last_char = substr($word,$length-1,1);
  16. if($top_char == $last_char)
  17. {
  18. return palindrome(substr($word,1,$length-2));
  19. }else{
  20. return 0;
  21. }
  22.  
  23. }
  24. }
  25. print $ARGV[0];
  26. print palindrome($ARGV[0]),"\n";
Success #stdin #stdout #stderr 0s 5304KB
stdin
argv asd ddd
stdout
1
stderr
Use of uninitialized value in print at prog.pl line 25.
Use of uninitialized value $length in numeric le (<=) at prog.pl line 10.