hara said:
Suppose
$a=11
I want to make it 0011
If i will do like
$res="0000" | "$a" ;
this will come as 1100
But i want to make it 0011
How can i do this?
You have already asked a very similar question in another thread here.
Please don't start multiple threads for your question.
Please read the posting guidelines for this group, which are posted here
regularly. In particular, use a small, complete script to illustrate
your questions/problems.
What you say above again illustrates your failure to address the point I
raised earlier in response to your earlier post: you need to decided
whether you are dealing with numbers or strings. You seem to want
numbers, but are using strings.
Here's how to do it with numbers:
----
#!/usr/bin/perl
use strict;
use warnings;
my $a = 0b11;
my $res = 0b0000 | $a;
printf "%b\n", $res;
----
Output:
11
DS