#!/usr/bin/perl -w print "Your binary input please =>"; $bin = ; #read in user input chomp $bin; # use of array to store $bin and split it @digits = reverse(split('',$bin)); #reverse and split $bin, then assign to an array $result = 0; foreach $pos (0..$#digits) { $result += $digits[$pos] * 2 ** $pos; } print $result;