$units =~ s/KB/kB/g; for my $i ( @num ) { my $temp = $i; $temp =~ s/$units//g; $temp =~ s/ $//g; chomp $temp; push @dig, $temp; }