use strict my my sub is_palindromic my return if length my lchunk leng

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
use strict;
my $i;
my $p;
sub is_palindromic
{ my ($n) = @_;
return 0 if length($n) % 2 != 0;
my $lchunk = length($n) / 2;
my $chunk1 = substr($n, 0, $lchunk);
my $chunk2 = substr($n, $lchunk, $lchunk);
return 1 if $chunk1 eq reverse $chunk2;
return 0;
}
$| = 1;
while ( my $row = <STDIN> ){
my $n = (split /s+|\//, $row)[0];
print ">>>> $n\n";
#for $i (999..100){
for ( $i = 999; $i >= 100; $i-- ){
$p = $n * $i;
print "$n * $i = $p";
print " xxx" if is_palindromic($p);
print "\n";
}
}