From: sree on
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
sree wrote:


> I wanna compare if one of this string is the reverse of the next,

perldoc -f reverse

--
Ruud
From: sln on
On Mon, 19 Jul 2010 13:13:02 -0700 (PDT), sree <sreeram91(a)gmail.com> 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