uG has asked for the wisdom of the Perl Monks concerning the following question:
By best, I suppose I really mean transparent. I have a module SomeModule.pm, which exports a function, ed(). It also has some helper methods that call ed(), as it does all the heavy lifting.
Now I have Inline::C code for ed() (added to the end of SomeModule.pm) and i'd like for the Inline::C ed() function to be exported and used by SomeModule.pm's helper methods if Inline::C is installed, otherwise export/use the Perl version of ed().
So I wonder what the best way to handle the situation is. Text::CSV_XS appears to set an env variable, but that doesn't seem ideal. Another solution uses eval { require Inline } and checks $@, but checking $@ doesn't seem ideal either (I see that in rare cases $@ gets modified).
Neither solution seems to be a very modern, elegant approach. What are some better ways to handle this?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Best way to implement Inline::C/Pure Perl function in a module?
by syphilis (Archbishop) on Oct 26, 2012 at 00:06 UTC | |
by uG (Scribe) on Oct 26, 2012 at 03:09 UTC | |
by syphilis (Archbishop) on Oct 26, 2012 at 05:04 UTC |