in reply to How to make a variable in hard call.

I have never used Device::BCM2835 but looking at it, it appears to be a complex way of doing something relatively simple. Please do correct me if there is some advantage of using this module that I have overlooked.

The way I set the GPIO pins is:

sub set_gpio { my $pin = shift; if (open my $val, '>', "/sys/class/gpio/gpio$pin/value") { print $val shift; close $val; } else { return "Failed to set pin $pin $!"; } return "SUCCESS"; }
This way I can set any pin by passing the pin number and the state to the sub. Note that the logic is reversed in that 0 switches on the relay and 1 switches it off again when I have a relay unit attached.