Hi all, I've been lurking around trying to read as much as I can trying to get my perl knowledge from zero to at least functional. My background experience with perl, and any other language, was absolutely zero up until a month ago.
I've read the tutorials on perlmonk, perl.org and litterally anywhere else that I thought was even remotely relevant to my current project.

I am trying to subtract two arrays that have mixed scalars.

I am able to print to screen but it won't fill the empty array I created.

Please save me!

This has been an "interesting" problem that I have been stuck on for a week

#!/usr/bin/perl use strict; use warnings; use feature qw/ say /; use diagnostics; use Data::Dumper; # This is how the script gets the input to generate the arrays. my @Molecule_01 = (); open(FILE, "$inputname_01") or die "Could not open file '$inputna +me_01' $!"; #directs the user to enter the file name to be used while (<FILE>) { push @struct_01, [ split ]; } @Molecule_01 = qw( [C 0.2565522 -1.5308230 0.0000000], [C -0.8038556 -0.7047550 0.0000000], [C -0.8519687 0.7637319 0.0000000], [C 0.3236482 1.5968480 0.0000000], ; @Molecule_02 = qw( [C 0.3916152 -1.5774692 0.0000000], [C -0.8180007 -0.7937790 0.0000000], [C -0.8314989 0.6754852 0.0000000], [C 0.1934963 1.5451038 0.0000000], ; my @Delta = (); for my $i (0..$#Molecule_01) { my $row = $Molecule_01[$i]; for my $j (1..$#{$row}) { my $Delta = ($Molecule_01[$i][$j] - $Molecule_02[$i][$j]); print "\n Data Dumper on array:\n"; print Dumper(\@Delta); print Dumper($Delta); } } say "Done"; close;
Data Dumper on array: $VAR1 = [ [] ]; $VAR1 = '-0.135063'; Data Dumper on array: $VAR1 = [ [] ]; $VAR1 = '0.0466461999999999'; Data Dumper on array: $VAR1 = [ [] ]; $VAR1 = '0'; Data Dumper on array: $VAR1 = [ [] ]; $VAR1 = '0.0141451'; Data Dumper on array: $VAR1 = [ [] ]; $VAR1 = '0.089024';

In reply to 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.