..
> --- snip ---
> my $masklen = <some value>;
> my $mask = 0;
> while ($masklen > 0) {
>       $mask += (1 << $masklen);
>       $masklen--;
> }
> --- snip ---

Here's another way:

my $mask = (2^($masklen + 1)) - 1;

unfortunately there doesn't seem to be an exponentiation operator in
Perl..


-- 
Orlando Andico <[EMAIL PROTECTED]>
Mosaic Communications, Inc.

_
Philippine Linux Users Group. Web site and archives at http://plug.linux.org.ph
To leave: send "unsubscribe" in the body to [EMAIL PROTECTED]

To subscribe to the Linux Newbies' List: send "subscribe" in the body to 
[EMAIL PROTECTED]

Reply via email to