I just started coding in Perl, and just want to know if it is possible to make the code below more efficient or to do it in fewer lines.
I did a little research on the Win32::OLE and Text::CSV modules, but it was like what I read so far.
This question is basically a beginner asking a senior: "Hey, how do I become a better Perl progambler?"
The purpose of the code is to obtain data from the specified ranges in the specified sheets of the Excel workbook and write the contents of these ranges to CSV files.
In addition, I know that I need to perform general checks, for example, to make sure my $cellValue defined before adding it to the array, etc., but I look more at the general structure. How is there a way to smooth out a loop by putting the whole whole string in an array at once, or the whole range in an array or reference, or something like that?
thanks
use strict; use warnings; use Spreadsheet::XLSX; my $excel = Spreadsheet::XLSX -> new ('C:\scott.xlsm',); my @sheets = qw(Fund_Data GL_Data); foreach my $sheet (@sheets) { my $worksheet = $excel->Worksheet($sheet); my $cell = $worksheet->get_cell(25,0); if ($cell) {
Scott Holtzman
source share