#!/usr/bin/perl
use strict;
use warnings;
my $nargs = @ARGV;
my ($mod, $arg1, $arg2) = @ARGV;
my $sol=0;
my $anum=(6.022*(10**23));

if (!$nargs) {
	die "stoich: null args\n";
}

if ($mod eq "g2m") {
	$sol = $arg1 / $arg2;
	# grams, molar mass
} elsif ($mod eq "m2g") {
	$sol = $arg1 * $arg2;
	# mols, molar mass
} elsif ($mod eq "a2m") {
	$sol = (($arg1) * (10 ** $arg2)) / $anum;
} elsif ($mod eq "m2a") {
	$sol = $arg1 * $anum;
} else {
	die "stoich: invalid arguments\n";
}

print "$sol\n";
exit 0;
