# Perl newbie help

**URL:** https://forum.kirupa.com/t/perl-newbie-help/288048
**Category:** programming
**Created:** [May 10, 2009, 2:39am UTC](https://forum.kirupa.com/t/perl-newbie-help/288048 "2009-05-10T02:39:35Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![turnquist](https://avatars.discourse-cdn.com/v4/letter/t/dfb087/32.png) [@turnquist](https://forum.kirupa.com/u/turnquist)
#### Post date: [May 10, 2009, 2:39am UTC](https://forum.kirupa.com/t/perl-newbie-help/288048/1 "2009-05-10T02:39:35Z")

</div>

Trying to get this perl script to work… its meant to read a directory of excel files and extract a certain row from all files…however when trying to run it on my linux box i get

“Global symbol “@data” requires explicit package name at rowextract.pl line 56.”

can anyone help? im totally new to perl. thanks -

```php
my $excel_directory = 'Invoices';
my $out_directory = 'out';
opendir(EXCELDIR, $excel_directory) || die ("no excel directory");
my @excelfiles = readdir(EXCELDIR);
closedir(EXCELDIR);

chdir($excel_directory);
       my $LPHname; # String to hold Local Public Health Name.
       my @sheetarray; # Array to hold the row.
       my $sheetcount; # Array element in the row.
       my $sheetname; # Name of the Excel spreadsheet.
       my $sheettemp; # Temporary string to hold row for join.
       my $cellnumber; # Cell number in the row.
       my $cellwanted; # Cell number in the row.
       my $rowwanted; # Row number wanted.
       my $county_namecell; # Cell for county name.
       my $county_namerow; # Row for county name.
foreach my $exxfilename (@excelfiles){
    if ($exxfilename =~ /^\.+.*/) { next; }
    my $xls = Spreadsheet::ParseExcel::Simple->read($exxfilename);
    foreach my $sheet ($xls->sheets) {
       $sheetname= $sheet->{sheet}->{Name}; # Sheet Name

       if ($sheetname !~ 'Simple Invoice') { next; }
       $sheetcount=0;
       $county_namecell=3;
       $county_namerow=18;
# $cellwanted=1;
       $rowwanted=18;

       while ($sheet->has_data) {
            my @data = $sheet->next_row;
            $sheetcount++;
         if ($sheetcount==$county_namerow){
            $cellnumber=0;
            foreach my $ttcell (@data) {
                $cellnumber++;
                if ($cellnumber != $county_namecell ){next;};
                 $sheettemp=$sheetarray[$sheetcount];
# $sheetarray[$sheetcount]=join("	",$sheettemp,$ttcell);
                 $LPHname=$ttcell;
            }
          } # Get the name of the Local Health

# if (($sheetcount < ($rowwanted-1)) || ($sheetcount > ($rowwanted+7))){next
;}
            if ($sheetcount != $rowwanted){next;};
            $cellnumber=0;
     $sheetarray[$sheetcount]=join("	",$sheettemp,$LPHname);
            foreach my $ttcell (@data) {
                $cellnumber++;
# if ($cellnumber != $cellwanted ){next;};
                 $sheettemp=$sheetarray[$sheetcount];
                 $sheetarray[$sheetcount]=join("	",$sheettemp,$ttcell);
            }
       }
    }
    foreach my $sheetline (@sheetarray){
        print $sheetline,"
";
    }

# foreach my $sheetline (@sheetarray){
# print $sheetline,"
";
# }
exit

```
