We study the Dirichlet problem in a domain with a small hole close to the boundary. To do so, for each pair ε = (ε 1 , ε 2 ) of positive parameters, we consider a perforated domain Ω ε obtained by making a small hole of size ε 1 ε 2 in an open regular subset Ω of R n at distance ε 1 from the boundary ∂Ω. As ε 1 → 0, the perforation shrinks to a point and, at the same time, approaches the boundary. When ε → (0, 0), the size of the hole shrinks at a faster rate than its approach to the boundary. We denote by u ε the solution of a Dirichlet problem for the Laplace equation in Ω ε . For a space dimension n ≥ 3, we show that the function mapping ε to u ε has a real analytic continuation in a neighborhood of (0, 0). By contrast, for n = 2 we consider two different regimes: ε tends to (0, 0), and ε 1 tends to 0 with ε 2 fixed. When ε → (0, 0), the solution u ε has a logarithmic behavior; when only ε 1 → 0 and ε 2 is fixed, the asymptotic behavior of the solution can be described in terms of real analytic functions of ε 1 . We also show that for n = 2, the energy integral and the total flux on the exterior boundary have different limiting values in the two regimes. We prove these results by using functional analysis methods in conjunction with certain special layer potentials.