>>>>> "k" == kenTk <k...@shail.co.uk> writes:
k> How can I conditionally use a module? you normally can't but you don't need to call use here. k> I haven't found an xl module for Linux so I will simple omit that k> function and produce only the CSV. k> The problem is to stop Linux complaining about: k> use Spreadsheet::WriteExcel; require the module instead. use happens at compile time but require works at runtime. if the module is OO then how you load it doesn't matter. use is needed if the module exports symbols into your namespace as that has to happen at compile time. k> I have tried using eval but cant hide it on Linux. k> E.G. k> BEGIN { k> $LINUX = ($^O eq "MSWin32") ? 0: 1; k> unless ($LINUX) k> { k> my $string='use Spreadsheet::WriteExcel;'; k> eval { $string}; besides what i said above (which is the best solution) you have conflated the two eval operations and chose the wrong one. the above is called eval BLOCK and all it does is verify the code inside is valid, runs it and returns its value. it will trap dies and fatal errors. in your case it checked that $string was ok (NOT its value!) and ran it and it did nothing. if you had warnings enabled you would have been told about a useless expression in a void context. again, i say to all newbies here ENABLE WARNINGS. it is your friend. the proper way to do what you tried is called eval STRING and it actually compiles and runs the string when the eval is called. but don't do it here as eval string can be very dangerous and it is not needed here anyway as i have shown. uri -- Uri Guttman ------ u...@stemsystems.com -------- http://www.sysarch.com -- ----- Perl Code Review , Architecture, Development, Training, Support ------ --------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com --------- -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/