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! ;)
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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |