#!/usr/bin/perl # # Name : Matthew Reeves # # Tests if a 7 character string is a palindrome # #use diagnostics; use warnings; use strict; use feature ":5.10"; #prompt user for 7 character string, chomp newline print("\nPlease enter a seven-character string: "); chomp (my $input = <>); #store original input value in scalar $tmp to preserve original value my $tmp = $input; #shave off each character of input string, store in separate scalars my $char7 = chop $tmp; my $char6 = chop $tmp; my $char5 = chop $tmp; my $char4 = chop $tmp; my $char3 = chop $tmp; my $char2 = chop $tmp; my $char1 = chop $tmp; #create reverse of original string by concatenating the characters chopped off #the initial string in reverse order, storing reversed string in $tmp $tmp = $char7.$char6.$char5.$char4.$char3.$char2.$char1; if ($tmp ~~ $input) { print "PALINDROME\n\n"; } else { print "NOT\n\n"; }