G'day Konan,
Welcome to the Monastery.
[Disclaimer: I am not a user of Device::BCM2835. The following is based on its source code.]
gpio_fsel() is not exported; however, you can create an alias so that you don't need to use the fully-qualified subroutine name repeatedly (see "perldata: Typeglobs and Filehandles" for details):
*gpio_fsel = \&Device::BCM2835::gpio_fsel;
RPI_V2_GPIO_P1_07 is exported (line 582); it's part of our @EXPORT = qw(...); which starts on line 317.
Your code could end up looking something like this:
#!/usr/bin/env perl use strict; use warnings; use Device::BCM2835; ... *gpio_fsel = \&Device::BCM2835::gpio_fsel; ... my $inputcmd = ...; ... gpio_fsel(RPI_V2_GPIO_P1_07, $inputcmd); ...
To use a variable in place of RPI_V2_GPIO_P1_07, you could do something like the following. Bear in mind, without seeing your code, I'm very much guessing with regards to the context.
my %rpi_v2_gpio_p1 = ( 3 => RPI_V2_GPIO_P1_03, 5 => RPI_V2_GPIO_P1_05, 7 => RPI_V2_GPIO_P1_07, ..., 40 => RPI_V2_GPIO_P1_40, ); ... gpio_fsel($rpi_v2_gpio_p1{$_}, $inputcmd) for 3, 5, 7, ..., 40;
In other posts, I see variations using dispatch tables and eval. These may well be more appropriate for your code.
If none of the suggestions so far are suitable, you'll need to show us more code such that we can see how gpio_fsel() is being used.
— Ken
In reply to Re: How to make a variable in hard call.
by kcott
in thread How to make a variable in hard call.
by Konan
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |