ctowncoug has asked for the wisdom of the Perl Monks concerning the following question:
I am currently trying to format the post correctly, I apologize for the current format.#!/usr/bin/perl use strict; my @palindromes = (); my @names = qw( Aaron Adam Amir Ann Anna Art Axel Brent Brian Ch +arles Chuck Cris Dave Don Dori Doug Eva Fred Gregor Ia +n Ima Ira Jarl Jason Jay Jeff Joe Joel John Kari Kim K +irk Kris Lar Leo Lex Lin Mara Marc Mark Mary Michael + Mike Miki Mott Naim Nils Nora Norm Omar Pete Raj Ralf + Ram Ramon Rik Rod Roger Ron Tom Tony Tran Travis Sar +ah Palin ); for my $word1 (@names) { for my $word2 (@names) { for my $word3 (@names) { #if ($word1 eq $word2) #next; if ( palin( $word1, $word2, $word3 ) ) { push @palindromes, $word1,'',$word2,'', $word3; print "$word1 $word2 $word3\n"; last; } else { if ( palin( $word1, $word2 ) ) { push @palindromes, $word1,'',$word2; print "$word1 $word2\n"; last; } } } } } sub palin { my $names1 = shift; my $names2 = shift; my $names3 = shift; my $string = join( '',$names1,$names2,$names3); my $reversestring = reverse($string); return ( uc($reversestring) eq uc($string)); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Use of uninitialized value in join or string
by dreadpiratepeter (Priest) on Nov 05, 2008 at 16:35 UTC | |
|
Re: Use of uninitialized value in join or string
by ww (Archbishop) on Nov 06, 2008 at 14:39 UTC | |
|
Re: Use of uninitialized value in join or string
by Anonymous Monk on Nov 06, 2008 at 01:30 UTC |