Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Re: Re: Array in Array

by CombatSquirrel (Hermit)
on Oct 06, 2003 at 14:40 UTC ( #296958=note: print w/ replies, xml ) Need Help??


in reply to Re: Re: Array in Array
in thread Array in Array

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.


Comment on Re: Re: Re: Array in Array
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://296958]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (9)
As of 2014-10-02 12:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    What is your favourite meta-syntactic variable name?














    Results (56 votes), past polls