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.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|