Your $rec variable is actually a reference to an array. You should dereference it, for example by writing my @rray = @$rec;, or, TIMTOWTDI:
#!/usr/bin/perl
use strict;
use warnings;
my @accounts = ("A x1 B y1 C z1 D v1 E w1 F",
"A x2 B y2 C zzz2 D v2 E w2 F",
"A x3 B y3 C z3 D v3 E w3 F",
"A x4 B y4 C z4 D v4 E wwww4 F",
"A x5 B y5 C z5 D v5 E w5 F",
"A x6 B y6 C z6 D v6 E F");
my @fields = ("A", "B", "C", "D", "E");
sub tweezers_sub {
my @accounts_2 = map { [@{{/([A-Z])\s+([a-z]+\d|\s)/g}}{@fields} ]
+} @accounts;
for my $rec (@accounts_2) {
print "'" . join("' - '", @$rec) . "'\n";
}
}
tweezers_sub;
This uses a RegEx instead of a split, but you can still see how $rec is dereferenced by writing @$rec.
Hope this helped.
CombatSquirrel.
Update: Mixed up referencing and dereferencing. Fixed.
Entropy is the tendency of everything going to hell.
|