Question : Perl, Using Text::CSV_XS / Count number of references

I am reading a CSV File with a huge amount of columns. Unfortunately the Header just starts at Line 8 therefore I use the getline Command. Once Line 8 has reached I would like to count the number of columns the file contains. That's exactely where I am stuck.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
# Open Account Number Files
    my $pos = Text::CSV_XS->new ({  binary => 1,
                                    sep_char => ';' });

    open my $fp, "<", $file or die "$file: $!";
    
    #Counter
    my $lcnt = 0;
    
    #Go trough each line
    while (my $row = $pos->getline($fp))
    {
    
        $lcnt++;
        # Next line if not Header line
        next if ($lcnt < 8);
    
        # Handle Header
        if ($lcnt == 8)
        {
            
            # Now here I would like to check how many references $row has ($row->[???])
            
        }
        
    }

    $pos->eof or $pos->error_diag;
    close $fp or die "$file: $!";

Answer : Perl, Using Text::CSV_XS / Count number of references

Unless you need those extra variables later, you don't need to create them:
print scalar(@$row), "\n";

If the $size variable is needed later, you could do this:
my $size = @$row;
print $size, "\n";
Random Solutions  
 
programming4us programming4us