Well, it is normally a binary number already, but not if it's embedded in something that Perl will treat as a string. For example an IP address expressed with 3 dot delimiters between four numbers and you want to convert the whole thing to one binary number. But yes, lookup pack in perldoc as choroba suggests.