From: sree on 19 Jul 2010 16:13 Hey, can someone tell me the next step: I wanna compare if one of this string is the reverse of the next, using the functions- shift and pop. I could manage to print the strings using 'while' loop. \$str1=<>; chomp \$str1; @str1= split("", \$str1); while(@str1) { @pop= pop(@str1); } print "\n"; \$str2=<>; chomp \$str2; @str2= split("", \$str2); while(@str2){ @shift= shift(@str2); } Now, how to compare these two arrays, to check if one of the array is the reverse of the other. From: Dr.Ruud on 19 Jul 2010 16:55 sree wrote: > I wanna compare if one of this string is the reverse of the next, perldoc -f reverse -- Ruud From: sln on 19 Jul 2010 17:08 On Mon, 19 Jul 2010 13:13:02 -0700 (PDT), sree wrote: >Hey, can someone tell me the next step: > >I wanna compare if one of this string is the reverse of the next, >using the functions- shift and pop. I could manage to print the >strings using 'while' loop. > >\$str1=<>; >chomp \$str1; >@str1= split("", \$str1); > >while(@str1) { >@pop= pop(@str1); >} > >print "\n"; > >\$str2=<>; >chomp \$str2; >@str2= split("", \$str2); > >while(@str2){ >@shift= shift(@str2); >} > >Now, how to compare these two arrays, to check if one of the array is >the reverse of the other. Try this: \$reverse='\$print'; \$print='tnirp\$'; if((reverse\$reverse)eq\$print) { print "\$reverse equals reverse \$print\n"; } -sln  |