This may be a wasted node when OP or the Janitors provide code tags, but (from the xml view) this appears to be what OP was trying:

#!/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)); }

My take is that OP seeks to generate all possible permutations of the elements of @names two OR three at a time; to test for palindromes in the sub; and (at lines 19 and 25), print those which pass the test.

That may even be correct - :-) - but OP fails to tell us and it seems to me obvious (YMMV) that this code does not accomplish that for reasons well beyond the scope of the warning cited as an "error."

For example, running withOUT -w or use warnings, this produces such non-palindromic strings as:

Ann Ann Anna
Ann Anna

as well as valid output (once spaces are stripped):

...Kirk Rik
Leo Joel
Lex Ann Axel
Lex Axel
Mara Ram...

but skips such apparently acceptable permutations as

Anna Anna Anna

despite the fact that lines 14 and 15, skipping over dups in $words1 and $words2, are commented out.)

All the above leads me to two questions:
Does this interpretation make sense?
and...
Will OP, please, explain the original intent?

It is much easier to offer help -- even if beyond the scope of the question about the "error" -- when we know what you are trying to do. To paraphrase a former US Veep, A node is a terrible thing to waste.


In reply to Re: Use of uninitialized value in join or string by ww
in thread Use of uninitialized value in join or string by ctowncoug

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.