If you want to mix decimal,octal,hex numbers in some @a=qw(...),see below. Just ask Perl to evaluate what that string means in terms of an actual "number".
Update: added a binary number to example.#!/usr/bin/perl use strict; use warnings; use Data::Dumper; my @array_of_strings = qw (10 20 0x47 1 30 0b011); # # "qw" is "quote word(s), this is the same as: # my @array_of_strings = ("10","20","0x47","1","30","0b011"); print Dumper \@array_of_strings; # only string context not "numbers" my @array = map{eval $_}@array_of_strings; # or my @array = map{eval $_} qw (10 20 0x47 1 30 0b011); print Dumper \@array; __END__ prints: $VAR1 = [ '10', '20', '0x47', '1', '30', '0b011' ]; $VAR1 = [ 10, 20, 71, 1, 30, 3 ];
In reply to Re: Converting quoted strings to numbers in array
by Marshall
in thread Converting quoted strings to numbers in array
by pritesh_ugrankar
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |