#!/usr/bin/perl -W

use strict;
# no strict 'refs';

# my @names = "A".."Z";        # there are single letters that can't be used with strict 
# my $files = scalar(@names);

my $data = 0;

my @array;

open IN, '<', $0 or die $!;
while (<IN>){
    if (/__DATA(\d+)__/) { 
	$data = $1;
 	next;
    }
    if (/__END__/) { $data = 0; }
    push @{ $array[$data] }, $_ if $data > 0;     
#    push @{ ${ "$names[$data]" } }, $_ if $data > 0; 
#    push @{ "$names[$data]" }, $_ if $data > 0; 
}
close IN;

USE:
  
my $fd = 1; # file descriptor number
my $fc ;    # file content

$fc = $array[$fd];
for (@$fc) {
    # Here you have your first file, line by line
    print $_;
}
print "Done $fd\n";
$fc = $array[++$fd];
for (@$fc){
    # Second file
    print $_;
}
print "Done $fd\n";
$fc = $array[++$fd];
for (@$fc){
    print $_;
}
print "Done $fd\n";


exit 1;

__END__
  
__DATA1__
1 , 2
3 , 4
__DATA2__
2 , 4
6 , 8
__DATA3__
3 , 5
7 , 9  
__END__
  
Highly experimental
  
