My Input file is:#!/usr/bin/perl use strict; use warnings; use diagnostics; use Math::Vector::Real; my $source = "./IN"; my $out = "./OUT"; open(IN, '<', $source) or die "Couldn't open $source: $!\n"; open(OUT, '>', $out) or die "Couldn't open $out: $!\n"; sub vector { my ($aa) = @_; $aa->[0] = my $one; $aa->[1] = my $two; $aa->[2] = my $three; my $vector = V($one, $two, $three); } my @data = map [ split ], grep /\S/, <IN>; foreach my $d1 (@data) { print OUT " The vector of Atom ($d1->[0], $d1 +->[1], $d1->[2])is : %f\n", vector($d1); } close IN; close OUT;
And this is the error I get when I run it,0 5 5 1 2 3 3 5 6 2 5 2 5 5 5 5 5 6
The line that the error directs me to is:mac95406:perl a7c$ ./perl Use of uninitialized value in join or string at /Library/Perl/5.16/Math/Vector/Real.pm line 219, <IN> line 6 (#1) (W uninitialized) An undefined value was used as if it were alread +y defined. It was interpreted as a "" or a 0, but maybe it was a mi +stake. To suppress this warning assign a defined value to your variables. To help you figure out what was undefined, perl will try to tell y +ou the name of the variable (if any) that was undefined. In some cas +es it cannot do this, so it also tells you what operation you used th +e undefined value in. Note, however, that perl optimizes your progr +am anid the operation displayed in the warning may not necessarily ap +pear literally in your program. For example, "that $foo" is usually optimized into "that " . $foo, and the warning will refer to the concatenation (.) operator, even though there is no . in your program.
Even knowing what that error means would be great for starters. Everything I see is declared and should have a value. I'm probably just blind though. Any help is appreciated.sub as_string { "{" . join(", ", @{$_[0]}). "}" }
In reply to How to vector by jcklasseter
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |