diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 0b23e25..bb28b11 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -16,7 +16,7 @@ The following steps below outline how to make contributions to the existing proj ## Step 1 : Go through README file -- There are some coding challanges questions to solve in readme.md +- There are some coding challenges and questions to solve in readme.md - You can go through it and choose the questions you love to solve ## Step 2: Choose your language diff --git a/Perl/.gitattributes b/Perl/.gitattributes new file mode 100644 index 0000000..bde7582 --- /dev/null +++ b/Perl/.gitattributes @@ -0,0 +1 @@ +*.pl linguist-language=Perl \ No newline at end of file diff --git a/Perl/palindrome.pl b/Perl/palindrome.pl new file mode 100644 index 0000000..48d84ee --- /dev/null +++ b/Perl/palindrome.pl @@ -0,0 +1,33 @@ + +$true = 1; +$false = 0; +$ignore_case = $true; + +$string = "abbA"; + +if ( palindrome_string_test( $string ) == $true ) +{ + print "\"$string\" is a palindrome\n"; +} +else { print "\"$string\" is NOT a palindrome\n" } + +sub palindrome_string_test +{ + $string =~ s/^\s+//g; #Strip leading / trailing whitespace if any + $string =~ s/\s+$//g; + $teststring = reverse( $string ); + + if ( $ignore_case == 1 ) + { + print "Testing case insensitive:"; + if ( lc $teststring eq lc $string ) { return $true; } + } + else + { + print "Testing case sensitive:"; + + if ( $teststring eq $string ) { return $true; } + } + +} +