in reply to perl do's and don'ts

You can simplify the check on the binary number:

unless( $binary=~/^[01]*$/) die "A binary number contains 1's and 0's! only";

^ is the beginning of the string
[01] is a character class matching 0 and 1 only
$is the end of the string

Replies are listed 'Best First'.
Re: Re: perl do's and don'ts
by Sifmole (Chaplain) on Jun 28, 2001 at 20:47 UTC
    $binary=~/^[01]*$/
    should probably use a + instead of a *
    $binary=~/^[01]+$/