#!/usr/bin/perl -w use strict; my $x= '1 2 3 4 5 6 7 8 9 10 11 12 13 14 15'; print "$x\n"; $x =~ m/^(?\d+)\s*$/g; #my $weight = $1; print "$+{weight}\n"; print "Weight:\n" unless $x=~/Gkg\./g; #### $metric = 1; # use metric units $x = ; # read in measurement $x =~ /^([+-]?\d+)\s*/g; # get magnitude $weight = $1; if ($metric) { # error checking print "Units error!" unless $x =~ /\Gkg\./g; } else { print "Units error!" unless $x =~ /\Glbs\./g; }