Scalar Data

Program protocol.pl


#!/usr/bin/perl

# Instruct user how to prepare a 3 ml solution of
# 10 mM NaCl and 0.5 mM MgCl2, given stock solutions
# of 1 M NaCl and 0.1 M MgCl2.

$final_vol = 3;     #use ml volumes throughout the program

# NaCl

$NaCl_stock = 1000; #use mM concentrations throughout the program
$NaCl_final = 10;

$step1 = "Add " .                             #concatenation
         $final_vol * ($NaCl_final / $NaCl_stock) .
         " ml NaCl.\n";

# MgCl2

$Mg_stock = 100;
$Mg_final = 0.5;

$step2 = "Add " .
         $final_vol * ($Mg_final / $Mg_stock) .
         " ml MgCl2.\n";

# Water

$step3 = "Add water to a final volume of $final_vol ml and mix.\n"; 
                                         #variable interpolation

# Protocol

$protocol = $step1 . $step2 . $step3;

print "$protocol";

  1. Run the program and see the result.

  2. Change the values of $final_vol, $NaCl_stock, $Mg_stock and see what you get when you run the program now.


Table of Contents.
Next | Next.