I'm working a program to convert a pixel based map(in a two dimintinal array) to a vector format(actuly it's goingto be POVray file)

The problem I'm haveing is that the expressions are geting extramly long and I don't know of any styles to use that keeps the expressions easy to work with and fit in with the rest of the code.

Long messy example code hidden behind a read more tag.

my @map = ( ["#","#","#","#"," "," "," ",], ["#"," "," ","#"," "," ","#",], ["#"," "," ","#"," "," ","#",], ["#","#","#","#"," "," ","#",], [" "," "," "," "," "," ","#",], ["#","#","#","#","#","#","#",], ["#"," "," ","#"," "," ","#",], ["#"," "," ","#"," "," ","#",], ["#","#","#","#","#","#","#",], ["#"," "," ","#"," "," "," ",], ["#"," "," ","#"," "," "," ",], ); ####----------------------------------------------- sub test1{ my($xCur, $yCur, $wall)= @_; return "" if $yCur-1 < 0 || $xCur-1 < 0 || !defined($map[$yCur-1]) +; return "" if !defined($map[$yCur-1][$xCur-1]); return $map[$yCur-1][$xCur-1] eq $wall; }; #-------------------------------------------------- sub test2{ my($xCur, $yCur, $wall)= @_; return "" if $yCur-1 < 0 || $xCur < 0 || !defined($map[$yCur-1]); return "" if !defined($map[$yCur-1][$xCur]); return $map[$yCur-1][$xCur] eq $wall; }; #-------------------------------------------------- sub test3{ my($xCur, $yCur, $wall)= @_; return "" if $yCur-1 < 0 || $xCur+1 < 0 || !defined($map[$yCur-1]) +; return "" if !defined($map[$yCur-1][$xCur+1]); return $map[$yCur-1][$xCur+1] eq $wall; }; ####----------------------------------------------- sub test4{ my($xCur, $yCur, $wall)= @_; return "" if $yCur < 0 || $xCur-1 < 0 || !defined($map[$yCur]); return "" if !defined($map[$yCur][$xCur-1]); return $map[$yCur][$xCur-1] eq $wall; }; #-------------------------------------------------- sub test5{ my($xCur, $yCur, $wall)= @_; return "" if $yCur < 0 || $xCur < 0 || !defined($map[$yCur]); return "" if !defined($map[$yCur][$xCur]); return $map[$yCur][$xCur] eq $wall; }; #-------------------------------------------------- sub test6{ my($xCur, $yCur, $wall)= @_; return "" if $yCur < 0 || $xCur+1 < 0 || !defined($map[$yCur]); return "" if !defined($map[$yCur][$xCur+1]); return $map[$yCur][$xCur+1] eq $wall; }; ####----------------------------------------------- sub test7{ my($xCur, $yCur, $wall)= @_; return "" if $yCur+1 < 0 || $xCur-1 < 0 || !defined($map[$yCur+1]) +; return "" if !defined($map[$yCur+1][$xCur-1]); return $map[$yCur+1][$xCur-1] eq $wall; }; #-------------------------------------------------- sub test8{ my($xCur, $yCur, $wall)= @_; return "" if $yCur+1 < 0 || $xCur < 0 || !defined($map[$yCur+1]); return "" if !defined($map[$yCur+1][$xCur]); return $map[$yCur+1][$xCur] eq $wall; }; #-------------------------------------------------- sub test9{ my($xCur, $yCur, $wall)= @_; return "" if $yCur+1 < 0 || $xCur+1 < 0 || !defined($map[$yCur+1]) +; return "" if !defined($map[$yCur+1][$xCur+1]); return $map[$yCur+1][$xCur+1] eq $wall; }; # x > ,y V # &horiwalls() Goes throght @map and print out a list of horizontal(x/ +1st axis) walls sub horiwalls { my $wall = " "; # my $xCur = 0; # my $yCur = 0; my $mmy = scalar(@map); for (my $yCur =0; $yCur < $mmy; $yCur++) { my $mmx = scalar(@{$map[$yCur]}); for (my $xCur =0; $xCur < $mmx; $xCur++) { my $tempwall = '.';#temp for testing $wall = $map[$yCur ][$xCur ]; $wall = undef if ($wall eq " "); ######################## if ((!&test2($xCur, $yCur, $wall) +&& !&test3($xCur, $yCur, $wall) && &test5($xCur, $yCur, $wall) && &te +st6($xCur, $yCur, $wall) && !&test9($xCur, $yCur, $wall))&& (!&test1( +$xCur, $yCur, $wall) && !&test7($xCur, $yCur, $wall) ) || (&test1($x +Cur, $yCur, $wall) && &test4($xCur, $yCur, $wall) && &test7($xCur, $y +Cur, $wall) && !&test8($xCur, $yCur, $wall))) {#end iftest if ( ( !&test3($xCur, $yCur, $wall) && &test5($xCur, $yCur, $wall) && &test +6($xCur, $yCur, $wall) && !&test9($xCur, $yCur, $wall))&& ( (!&test2($xCur, $yCur, $wall) && ((!&test1($xCur, $yCur, $wall) && !& +test7($xCur, $yCur, $wall) ) || (&test1($xCur, $yCur, $wall) && &test +4($xCur, $yCur, $wall) && &test7($xCur, $yCur, $wall) && !&test8($xCu +r, $yCur, $wall))))|| !&test1($xCur, $yCur, $wall) && &test2($xCur, $yCur, $wall) && !&test4($xCur, $yCur, $wall) && !&test7($xCur, $yCur, $wall) && !&test8($xCur, $yCur, $wall)) ) {#end iftest $tempwall = "[";#X:$xCur Y:$yCur\n"; };#end if for wall begian if ( #+++++++++++ (!&test1($xCur, $yCur, $wall)&& &test4($xCur, $yCur, $wall)&& &test5($xCur, $yCur, $wall)&& !&test7($xCur, $yCur, $wall)&& !&test8($xCur, $yCur, $wall) )&& ( ( &test2($xCur, $yCur, $wall)&& !&test3($xCur, $yCur, $wall)&& !&test9($xCur, $yCur, $wall) )|| (!&test2($xCur, $yCur, $wall)&& &test6($xCur, $yCur, $wall)&& &test9($xCur, $yCur, $wall) )) #+++++++++++ ){ $tempwall = ']'; };# end if for end of wall print $tempwall; ########################### =pod if (&test1($xCur, $yCur, $wall)) {print "1"}else{ print " " }; if (&test2($xCur, $yCur, $wall)) {print "2"}else{ print " " }; if (&test3($xCur, $yCur, $wall)) {print "3\n"}else{ print " \n" }; if (&test4($xCur, $yCur, $wall)) {print "4"}else{ print " " }; if (&test5($xCur, $yCur, $wall)) {print "5"}else{ print " " }; if (&test6($xCur, $yCur, $wall)) {print "6\n"}else{ print " \n"}; if (&test7($xCur, $yCur, $wall)) {print "7"}else{ print " " }; if (&test8($xCur, $yCur, $wall)) {print "8"}else{ print " " }; if (&test9($xCur, $yCur, $wall)) {print "9-\n"}else{ print " -\n" }; =cut ########################### };print "\n" }; };#end &horiwalls #--------------------------------------------------- # &horiwall() Goes throght @map and print out a list of horizontal(x/1 +st axis) walls sub horiwall { my $wall = " "; # my $xCur = 0; # my $yCur = 0; my $mmy = scalar(@map); # can use this becouse of Autovivification for (my $xCur =0; $xCur + < scalar(@map); $xCur++) { for (my $yCur =0; $yCur < $mmy; $yCur++) { # can use this becouse of Autovivification for (my $yCur =0; $y +Cur < scalar(@{$map[$yCur]}); $yCur++) { my $mmx = scalar(@{$map[$yCur]}); for (my $xCur =0; $xCur < $mmx; $xCur++) { print $map[$yCur ][$xCur ]; }; print "\n"; }; };#end &horiwall #--------------------------------------------------- # &vertwalls() Goes throght @map and print out a list of vertical wall +s sub vertwalls { };#end &vertwalls &horiwalls();
|\_/|
/o o\
(>_<)
 `-'

In reply to large expression formating by Dr.Altaica

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.