in reply to Re^2: what is difference between chr and oct?
in thread what is difference between chr and oct?
No, it's plain stupid. oct("0b".$1) is what you want. eval with a string argument starts the huge perl parser, whereas oct uses much more efficient code that can only convert strings to numbers.
Using a string eval is not needed most of the times, and very often, it opens a security hole. JavaFans code does not open a security hole, because it allows only digits to be passed to eval. But it is still wrong, it should allow only 0 and 1, not all digits. And it does not remove the whitespace.
$string=~s/\s*([01]+)/chr oct "0b$1"/eg;Alexander
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: what is difference between chr and oct?
by xiaoyafeng (Deacon) on Jul 13, 2010 at 15:04 UTC | |
|
Re^4: what is difference between chr and oct?
by JavaFan (Canon) on Jul 13, 2010 at 15:29 UTC |