Quote:
Originally Posted by ravi_nandula
yah I understood about "USE"...Can u please explain about the rest of the program....
Is This the only way we write or any other way??....which will be bit easy than this .....
|
Perl is full of 'dialects' (those are just ways of do things), but this is not the case as is quite standart. The script you bring on topic before, "uses" a library which is on itself an object, thats why we find something like:
Code:
my $oBook = $oExcel->Parse($ARGV[0]);
The '->' calls a method from an object. The '$ARGV[0]' is a Perl default array that stores the arguments passed to the script file on run time, in this case is a filename as the script is written to be used like this way:
Code:
scriptName.pl somefile.xlsx
.
The 'perlvar' man page will give you a better panorama of that part. Also check 'perlobj' for object programming on Perl.
To any doubt about built-in functions, you can use:
Code:
perldoc -f functionName
perldoc -f defined # for example
I assume you missed 3 final closing brackets '}' (maybe a header with the hashbang for perl and a 'use strict' perhaps?), if so, the script is quite simple: it iterates over all columns and rows of all sheets on the file, print the coordenate of location and the value of it on the line:
Code:
print "( $iR , $iC ) =>", $oWkC->Value, "\n" if($oWkC)
which is the same of ask 'if this cell has something, print it'.
So, a lot to said on your previous question as is very vague, btw, but will be brief:
-If you have an error on this code, and assuming is well written, check if you do have that library you're calling, first line you quoted 'use Spreadsheet::ParseExcel;'. Check if is on your system, there are lots of ways of do it, my way is just by calling the doc of it:
Code:
perldoc Spreadsheet::ParseExcel
If you see something that looks like a man page, you have it there, if an error you don't, go install it.
-The only trick to learn from the code you bring on topic is recursion, "for each sheet, walk by each column, for each column, walk by each row and print the content". The rest of it, is just a definition of where it will happen, what we will need... no mistery, just a workaround to get an excel file opened.
Perl has plenty ways of do recusion and those are very flexible, check on perldoc for
for, foreach, do, while, until...
-You want to write something like that? Ok, install the library if not there, make some coffee and read the docs of the library; ther is not much way around it so far, just study... and cheat this way:
Hope this helps you.