Hello,
this script does what is expected :

#!/usr/bin/perl
use warnings;
# use strict;

&matrix_read_file;

print "@$_\n" foreach @MAT1;
print "@$_\n" foreach @$matrix_name;

sub matrix_read_file
{
        while (my $line = <DATA>) {
        chomp $line;
        next if $line =~ /^\s*$/;
        if ($line =~ /^([A-Za-z]\w*)/) {
                 $matrix_name = $1;
        } else {
                my @row = split /\s+/, $line;
                push @{$matrix_name}, [EMAIL PROTECTED];
                }
                }
}
__DATA__
MAT1
1  2 4
10 30 0
MAT2
5  6
1 10

but how can I saved the values of $matrix_name in two variables $matrix1
and $matrix2 to be reuse in the lines:

print "@$_\n" foreach @MAT1;
print "@$_\n" foreach @$matrix_name;


tia
--
Gérard


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to