Perform regular expression on a PERL PDL variable -


is possible perform regular expression on n-dimension pdl variable?

for example can add 100 elements doing

$a1 = pdl [1,2];  print $a1 + 100; 

however if array bunch of strings perform task on. example fails:

$a = pdl ['suze','david']; $a =~ s/suze/female/; print $a; 

not sure if possible, in advance.

the point is, pdl perl extension designed scientific , bulk numeric data processing , display. not made string manipulating. when try iterate through piddle:

use strict; use warnings; use pdl;  $a = pdl ['suze','david']; print $_ . "\n" foreach ($a->list); 

you get:

argument "suze" isn't numeric in subroutine entry @ basic/core/core.pm.pl (i.e. pdl::core.pm) line 1296, <data> line 207. 0 0 argument "david" isn't numeric in subroutine entry @ basic/core/core.pm.pl (i.e. pdl::core.pm) line 1296, <data> line 207. 

when take deeper pod, find:

$a = pdl(scalar|array reference|array|string); 

for constructor , followed text string

the string version of pdl allows use strings bad, inf, , nan, , insert values mean (and set bad flag if use bad). can mix , match case, though shouldn't.

back main problem, why use pdl strings? - why not using simple array?

use strict; use warnings; use data::dumper;  $a = ['suze','david']; s/suze/female/ @{$a}; print dumper $a; 

output:

$var1 = [           'female',           'david'         ]; 

Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -