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:

use diagnostics;
The diagnostics pragma is a developer tool. Remove it from production code. You can always look up the same information in the perldiag manpage.
open(FILE, "$inputname_01") ...
Use lexical filehandles and the 3-argument form of open.
... or die "Could not open file  '$inputname_01' $!" ...
Hand-crafting these messages is tedious and error-prone. Consider using the autodie pragma instead.
... #directs the user to enter the file name to be used
That's not what's happening here. Ensure comments are accurate. Update them every time you change the code to which they refer.
close;
Without an argument, closes the currently selected filehandle. By default, this is STDOUT; as you haven't selected a different filehandle, it's still STDOUT. Closing STDOUT is rarely what you want: it certainly isn't here. See close and select.

— Ken


In reply to Re: Subtracting two arrays by kcott
in thread Subtracting two arrays by HaveANiceDay

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.