On Friday 21 April 2006 10:15, Smith, Derek wrote:
> -Original Message-
> From: Smith, Derek
> Sent: Friday, April 21, 2006 10:22 AM
> To: Perl Beginners
> Subject: RE: Extracting a bit of a scalar variable
>
>
> Original Message-
> From: Dr.Ruud [mail
-Original Message-
From: Smith, Derek
Sent: Friday, April 21, 2006 10:22 AM
To: Perl Beginners
Subject: RE: Extracting a bit of a scalar variable
Original Message-
From: Dr.Ruud [mailto:[EMAIL PROTECTED]
Sent: Friday, April 21, 2006 9:19 AM
To: beginners@perl.org
Subject: Re
Original Message-
From: Dr.Ruud [mailto:[EMAIL PROTECTED]
Sent: Friday, April 21, 2006 9:19 AM
To: beginners@perl.org
Subject: Re: Extracting a bit of a scalar variable
Praveena Vittal schreef:
> I am newbie to PERL.
ITYM: Perl.
> I think this is a very simple question to ask.
Praveena Vittal schreef:
> I am newbie to PERL.
ITYM: Perl.
> I think this is a very simple question to ask.
Well, let's see.
> Is there any way to print a particular bit of a digit after converting
> to binary form.
Why convert anything "to binary" first, if you can use
"$var & (1 << $bitp
On Apr 21, 2006, at 20:59, Praveena Vittal wrote:
Is there any way to print a particular bit of a digit after
converting to binary form.
That can be easily done with substr y sprintf, this would take the
second bit of 7 written in base 2:
% perl -wle 'print substr sprintf("%b", 7), -2,
Hello Praveena,
I recommend you to use pack and unpack function.
I believe you can use this to convert the digit to
binary and also extract the digit of your choice from
the result.
perldoc -f pack
type this command at your linux console if any to get
the help on pack.
Regards
Nishanth
--- Prav