in reply to how to make first element of an string as a the array name

You probably really want a hash...
#!/usr/bin/perl -w use strict; my %lines; open my $file, "<data.txt" or die "can't open: $!"; while(<$file>) { (my $key, my $stuff) = m/^([^,]*),(.*)/; my @data = split(",", $stuff); $lines{$key} = \@data; } # do something... print @{$lines{"IL12::1::329"}};

Replies are listed 'Best First'.
Re^2: how to make first element of an string as a the array name
by koleti (Novice) on Nov 15, 2007 at 01:11 UTC
    By simple parsing i could make the file look like this
    @IL12::1::287 = qw(6 -17 -9 -21 -24 -15 -2 11 4 4 -15 -26 -16 -9 -18 -25 27 17 6);
    @IL12::1::329 = qw(-25 -18 -28 23 17 1 -3 -23);
    @IL12::1::1108 = qw(-8 -21 17 -25 9 -6 -15 4);
    @IL12::1::1536 = qw(-12 -28 23 -12 17 -25 14 19 20);
    @IL12::1::1591 = qw(-17 -23 -7 -19 25 25 -25 -15 -26 23 29 -12 -25);
    @IL12::1::803 = qw(24 -20 -24 12 8 -22);
    @IL12::1::1483 = qw(-20 -4 24 -17 19 -19 8 11 -5);
    @IL12::1::631 = qw(-6 -22 19 26 -22);
    @IL12::1::817 = qw(-23 -12 -15 -19 18 18 -23 8 -8 -8 8 4);
    now my file contains list of arrays
    i want to call 2 or more arrays from that file and use List::Compare to compare the arrays
    how could i do that
    is there any way to call a particular array from a file