in reply to Converting quoted strings to numbers in array
'string' "another string" q(yet another) qq<or like this>
etc. Numbers can be specified in different ways, too:
12 1_2 0b1100 0x0c
All of them are just different ways how to represent the number 12. The problem is that 0x0c as a string , i.e. in quotes, is not interpreted as a number, but as a string. To convert it to a number, you need to use the oct function:
#!/usr/bin/perl use warnings; use strict; use feature qw{ say }; my @arr = qw( 10 10 20 0x47 1 30 45 45 ); my @converted = map /^0x/ && oct || $_, @arr; say for @converted;
($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Converting quoted strings to numbers in array
by pritesh_ugrankar (Monk) on Apr 23, 2017 at 20:59 UTC | |
by kcott (Archbishop) on Apr 24, 2017 at 05:53 UTC | |
by choroba (Cardinal) on Apr 23, 2017 at 21:15 UTC |