Re: bitwise and help plz

2011-08-14 Thread Rob Dixon
On 14/08/2011 23:19, Rajeev Prasad wrote: in this simple example. i am not able to figure what is the bitwise funtion doing: my @subArray = grep { $_& 1 } @array; The & operator requires the types of its operands to be identical - either string or numeric. In either case the values are ANDed

bitwise and help plz

2011-08-14 Thread Rajeev Prasad
in this simple example. i am not able to figure what is the bitwise funtion doing: my @subArray = grep { $_ & 1 } @array; what is the significance of 1 here? is this equivalent? { 1 & $_ } does the EXPR inside grep's curly braces have to produce the grepped text or just a true false value? i

Re: How to grab last element of array from split with no temporary variables?

2011-08-14 Thread Peter Scott
On Thu, 11 Aug 2011 23:30:32 -0700, John W. Krahn wrote: > Peter Scott wrote: >> On Thu, 11 Aug 2011 16:17:51 -0700, siegfried wrote: >>> Is there a way to do it with less typing? How can I do it without >>> creating a temporary variable "@p"? Thanks, siegfried >>> >>> find /xyz -exec perl -e 'fore

Re: Using unpack for bits

2011-08-14 Thread timothy adigun
Hi th0ma5_anders0n, if you must use unpack try these: >>on Win32: perl -e "printf('%04g',unpack("B8",pack('c',6)))" # Ans: 0110 >>on Ubuntu perl -e 'printf("%04g\n",unpack("B8",pack("c",6)))' # Ans: 0110 regards. Timothy

Re: Using unpack for bits

2011-08-14 Thread John W. Krahn
th0ma5_ander...@yahoo.com wrote: Hi all, Hello, When converting a single number (eg 6) to its binary format using unpack as in: unpack 'B8', '6'; # output = 00110110 You are not converting the number 6, you are converting the string '6'. I get the 8 character output 00110110. Does unpac

Using unpack for bits

2011-08-14 Thread th0ma5_anders0n
Hi all, When converting a single number (eg 6) to its binary format using unpack as in: unpack 'B8', '6'; # output = 00110110 I get the 8 character output 00110110. Does unpack have options for it to only return the last 4 characters of this output (ie 0110)? Or is the only option to use substr?