Jabir Ahmed am Dienstag, 4. Oktober 2005 07.48:

        ...
        use strict; # forces declaration of variables
        use warnings; # big help :-)
        ...

> $file=$ARGV[0] || die "File not found $!";
>
> my %uni=();
        # %uni never used below
        my @record;

> open (FH,"sort $file|");

        open (FH,"sort $file|") or die $!; # instead

> $reccnt=0;

        my $reccnt=0; # instead

> while (<FH>)
> {
>         $line=$_;

        my $line=$_; # instead

>         my @details=split('\t',$line);
>         [EMAIL PROTECTED];
>         $reccnt+=1;
> }
[double snipped]
>
> How do i read the values of @details trought the
> $record array;
> i want something like this
> print $record[1][1] ==> this would refer to the first
> element in the @details. (this doesnt work)


After 

        [EMAIL PROTECTED];
        # my [EMAIL PROTECTED]; # compare with this

$record[$reccnt] contains a reference to an array (@details),
see perldoc perlreftut and perldoc perlref.

You get it back by dereferencing:

        my @[EMAIL PROTECTED];
        # my @[EMAIL PROTECTED]; #  compare with this

===

But your while code is "C style", not "perl style", which would be shorter, 
and you don't need the $reccnt and $line variables:

while (<FH>) {
         my @details=split('\t',$_);
         push @record, [EMAIL PROTECTED];
}


or even shorter:

while (<FH>) {
         push @record, [ split('\t',$_) ];
}

which results in one line:

push @record, [ split('\t',$_) ] while (<FH>);


[Disclaimer: this is all NOT tested]


joe

-- 
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