my @input_pin; for ( @Device::BCM2835::EXPORT_OK ) { next if !/^RPI_V2_GPIO_P1_(\d+)\z/; my $pin = 0 + $1; my $val = do { no strict "refs"; "Device::BCM2835::$_"->() }; $input_pin[ $pin ] = $val; }