in reply to %INC and eval use

You could
unless (exists $INC{'Spreadsheet/WriteExcel.pm'}) { require Spreadsheet::WriteExcel; import Spreadsheet::WriteExcel; }
When I first had the problem to use a module only if it exists, I tried to just put use after the if clause. I was quite surprised that use is always used by the compiler. But for what reason anyway?

Replies are listed 'Best First'.
Re: Re: %INC and eval use
by ysth (Canon) on Mar 11, 2004 at 01:11 UTC
    Because perl likes to know about functions at compile time, so the import really should be done then if possible. In this case, looks to me as if this is a pure OO module that doesn't export anything, so the import can be skipped.