#! /usr/bin/perl -wnp
##
## Akin to dh_subst_env, this one will try to expand variables within
## its input, but only certain ones, and will fall back to querying
## dpkg-architecture first, before finally giving up.

BEGIN {
        sub qarch {
                my $arch = `dpkg-architecture -q$_[0] 2>/dev/null`;
                chomp ($arch);
                return $arch;
        }
}

s#(\$\{(DEB_(HOST|BUILD)_[^\}]+)\})#qarch($2) || $1#eg;
