in reply to Re: How to make a variable in hard call.
in thread How to make a variable in hard call.

I note that Device::BCM2835 has many functions with fully-qualifed names that aren't exported. You've shown use of one of these:

Device::BCM2835::gpio_fsel(...);

and I showed how to create an alias:

*gpio_fsel = \&Device::BCM2835::gpio_fsel;

If you're actually using a number of these subroutines, you can make aliases for all in a similar fashion to ++ikegami's "Taken a step further". For example, if you're using Device::BCM2835::gpio_fsel(...), Device::BCM2835::gpio_set(...) and Device::BCM2835::gpio_clr(...), you could write:

for my $sub (qw{gpio_fsel gpio_set gpio_clr}) { no strict 'refs'; *$sub = \&{"Device::BCM2835::$sub"}; }

and subsequently call:

gpio_fsel(...); gpio_set(...); gpio_clr(...);

Update (typo fix): I had written "(...}" instead of "(...)"; then, with the power of copy-paste, propagated that typo two more times. I've fixed all three instances.

— Ken

Replies are listed 'Best First'.
Re^3: How to make a variable in hard call.
by Anonymous Monk on May 09, 2023 at 13:32 UTC
    As a side note: the module claims to export nothing by default, which is contradictory to the source.