[ Web Proxy ]
URL:
Viewing: https://raw.githubusercontent.com/lqlstudio/netkiller.github.io/master/python/../perl/array.html [Back]  [Original]

3Array, HashHome | | | | Search | ITEYE | OSChina | Facebook | Linkedin | | Email

3Array, Hash

		
my @source = qw( title text1 text2 text3 text4 title text1 text2 text3 );

my $i = 0;
my @records = ();
foreach my $sour (@source)
{
    if ($sour eq 'title')
    {
        $records[$i] = { title => $sour };
        $i++;
    }
    else
    {
        push @{ $records[$i - 1]->{value} }, $sour;
    }
}

use Data::Dumper;
print Dumper \@records;
		
		
comments powered by Disqus

Web Proxy Viewer  |  New URL  |  Original Page