Extracting a bit of a scalar variable

2006-04-21 Thread Praveena Vittal
Hi All, I am newbie to PERL.I think this is a very simple question to ask. Is there any way to print a particular bit of a digit after converting to binary form. Thanks in Advance, Praveena -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: Extracting a bit of a scalar variable

2006-04-21 Thread nishanth ev
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 ---

Re: Extracting a bit of a scalar variable

2006-04-21 Thread Xavier Noria
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,

Re: Extracting a bit of a scalar variable

2006-04-21 Thread Dr.Ruud
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 $bitpos)? $

RE: Extracting a bit of a scalar variable

2006-04-21 Thread Smith, Derek
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. Well

RE: Extracting a bit of a scalar variable

2006-04-21 Thread Smith, Derek
-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

Re: Extracting a bit of a scalar variable

2006-04-21 Thread Jaime Murillo
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 [mailto:[EMAIL PROTECTED] Sent: Friday