Cleaned up the code some, I know many people learn by example so here is how you might improve the code. Declare all variables you want to use with "my", especialy inside of the sub. Grab arguments to the sub with shift (this is iffy and probably good arguments both ways. The important thing it to be consistent.) Indent code inside a sub so that you can tell the scope of that sub (where variables declared inside it with my will retain there uniqness for lack of a better workd.)

sub argComplex { my $value1 = shift; # shift along acts on @_ so its the same as @ +_[0]; my @construct = &constructComplex($value1); my $real1 = @construct[0]; my $complex1 = @construct[2]; return atan2($complex1, $real1); } my $real1; my $z; $real1 = 1; $z = 1 + i; print $real1 * argComplex($z);

P.S. It is easier to help when you provide a working example. In this case people spoted the error but if you break the problem down into a working example to show peopl, 90% of the time you will find your error before posting! ;)


___________
Eric Hodges

In reply to Re: Weird Perl Rule I'm Probably Not Following by eric256
in thread Weird Perl Rule I'm Probably Not Following by moltar512

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.