G'day HaveANiceDay,
Welcome to the Monastery.
It's good that you've used strict and warnings; however, from the code you've posted, I suspect you've missed an important, underlying issue. You probably got a message like:
Global symbol "@Molecule_01" requires explicit package name (did you f +orget to declare "my @Molecule_01"?)
which you fixed (or, at least, thought you'd fixed) by adding
my @Molecule_01 = ();
The fact that you didn't get an equivalent message about "@Molecule_02", should have been a hint to the underlying problem, which is related to how you've used qw. The starting delimiter you used was an open (left-hand) parenthesis; this means that everything up to a right-hand parenthesis are the qw operands. In other words, you've actually created a list like this:
@Molecule_01 = ( '[C', '0.2565522', ... ';', '@Molecule_02', '=', 'qw(', ... 'my', +'@Delta', '=', '(' );
See "perlop: Quote and Quote-like Operators" for general information about this quoting mechanism, and "perlop: Quote-Like Operators" for more specific information about qw.
You then have an additional problem in that you should have been creating individual lists for each arrayref:
my @Molecule_01 = ( [qw{C 0.2565522 -1.5308230 0.0000000}], [qw{C -0.8038556 -0.7047550 0.0000000}], ... ); my @Molecule_02 = ( [qw{C 0.3916152 -1.5774692 0.0000000}], ... );
"I am able to print to screen ..."
As first posts go, this is pretty good; however, the code you posted would not have produced the output you claim. Do not do this! Show us the real output you got and ask questions about what you don't understand or don't know how to fix. Just from inspection, I can see two instances that would have aborted compilation and another that would have generated a warning. All this, and more, is explained in "How do I post a question effectively?".
"... trying to read as much as I can ... experience with perl ... absolutely zero ..."
Bookmark the online perl manpage: read perlintro in the Overview section; refer to the Tutorials section as needed - this also contains a series of FAQs; familiarise yourself with what's available in the Reference section; the other sections are typically too advanced for, or tangential to the needs of, the Perl beginner.
Here's some additional information on the code you posted:
— Ken
In reply to Re: Subtracting two arrays
by kcott
in thread Subtracting two arrays
by HaveANiceDay
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |