for (my $i = 0; $i < $in; $i++ ) { my $temp = $num[$i]; if ($units =~ m{KB}) { $units =~ s{KB}{kB}g } $temp =~ s{$units}{}g; $temp =~ s{ $}{}g; chomp $temp; push @dig, $temp }