954,523 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Syntax Error in file, Next two tokens

#!opt/local/bin/perl5

use strict;
use Spreadsheet::ParseExcel;
use XLSX.pm;
my $oExcel = new Spreadsheet::ParseExcel;

die "You must provide a filename to $0 to be parsed as an Excel file" unless @ARGV;

my $oBook = $oExcel->Parse($ARGV[0]);
my($iR, $iC, $oWkS, $oWkC);
print "FILE  :", $oBook->{File} , "\n";
print "COUNT :", $oBook->{SheetCount} , "\n";

print "AUTHOR:", $oBook->{Author} , "\n"
 if defined $oBook->{Author};

for(my $iSheet=0; $iSheet < $oBook->{SheetCount} ; $iSheet++)
{
 $oWkS = $oBook->{Worksheet}[$iSheet];
 print "--------- SHEET:", $oWkS->{Name}, "\n";
 for(my $iR = $oWkS->{MinRow} ;
     defined $oWkS->{MaxRow} && $iR <= $oWkS->{MaxRow} ;
     $iR++)
 {
  for(my $iC = $oWkS->{MinCol} ;
      defined $oWkS->{MaxCol} && $iC <= $oWkS->{MaxCol} ;
      $iC++)
  {
   $oWkC = $oWkS->{Cells}[$iR][$iC];
   print "( $iR , $iC ) =>", $oWkC->Value, "\n" if($oWkC);
  }
 }

[TEX]
I keep getting this error
syntax error in file excel_perl.pl at line 3, next 2 tokens "use strict"
and so on...
any help?
[/TEX]

voidyman
Newbie Poster
17 posts since Sep 2011
Reputation Points: 10
Solved Threads: 1
 

Hi voidyman!

I'm not sure how you got those fonts in here, but it sure makes your post hard to read!

A quick check of your script with 'perl -c' shows that the script (at least what you've pasted here) is missing a curly bracket at the end of the file (for that big "for(my $iSheet..." loop).

Another thing that *might* be an issues is the 'use XLSX.pm;' line. If that's a module you're including locally, try it without the '.pm' extension (use XLSX;)

I hope this helps!

Gromit
Posting Whiz in Training
212 posts since Sep 2008
Reputation Points: 47
Solved Threads: 31
 

It helped . This problem Went away. Figures I do not have all my perl modules installed. Thanks Gromit.Wallace is grateful :)
And sorry abt the font. Copied from vi editor.

voidyman
Newbie Poster
17 posts since Sep 2011
Reputation Points: 10
Solved Threads: 1
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You