sub devices_for { my ( $thing ) = @_; my @subs = query( $thing ); return map { /^DEVICE\d+/ ? $_ : devices_for( $_ ) } @subs; }