in reply to combine arrays, duh!
I think you were looking for map not grep.
This
#!/usr/bin/perl -w use strict; use warnings; use Data::Dumper; my @e1 = ( ' bob', ' sue', ' joe_1', ); my @e2 = ( 'bob', 'sue', 'joe1', ); my @f = map { s/\W|_//g; $_ } @e1; print Dumper(\@f); print Dumper(\@e2);
Gives this output:
$VAR1 = [ 'bob', 'sue', 'joe1' ]; $VAR1 = [ 'bob', 'sue', 'joe1' ];
Also, it might be better to put more thought into your subject line next time. That helps other monks with a similar problem find this thread easier. For example, "remove spaces from array elements" might be good
|
|---|