Q:

Open Excel file in perl and print row count

I am using Win32::OLE module to open an excel file and get row count. The problem is when i hard code excel file path it works fine but when i dynamically pass path it throw an error saying that "cant call method workbooks on unblessed reference". Please find the below sample code.
use OLE;
use Win32::OLE::Const 'Microsoft Excel';

my $xapp= Win32::OLE->GetActiveObject('Excel.Application')
            or do { Win32::OLE->new('Excel.Application', 'Quit')};
    $xapp->{'Visible'} = 0;
    my $file='excel.xlsx';
    my $fileName="c:/users/mujeeb/desktop/".$file;
    print $fileName;
    my $wkb = $xapp->Workbooks->Open($fileName); //here i am getting error coz i am passing dynamic fileName;
    my $wks = $wkb->Worksheets('Sheet1');
    my $Tot_Rows=$wks->UsedRange->Rows->{'Count'}; 
    print $Tot_Rows."\n";
    $xapp->close;

A:

Use backslashes in the filename. 
The filename is given to excel and excel won't understand forward slashes. Perl does not convert them because Perl doesn't know the string is a file.

