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