  Charged-particle spectra at midrapidity are measured in Pb-Pb collisions at
the centre-of-mass energy per nucleon-nucleon pair $\sqrt{s_{\rm NN}}$ = 5.02
TeV and presented in centrality classes ranging from most central (0-5%) to
most peripheral (95-100%) collisions. Possible medium effects are quantified
using the nuclear modification factor ($R_{\rm AA}$) by comparing the measured
spectra with those from proton-proton collisions, scaled by the number of
independent nucleon-nucleon collisions obtained from a Glauber model. At large
transverse momenta ($8<p_{\rm T}<20$ GeV/$c$), the average $R_{\rm AA}$ is
found to increase from about $0.15$ in 0-5% central to a maximum value of about
$0.8$ in 75-85% peripheral collisions, beyond which it falls off strongly to
below $0.2$ for the most peripheral collisions. Furthermore, $R_{\rm AA}$
initially exhibits a positive slope as a function of $p_{\rm T}$ in the
$8$-$20$ GeV/$c$ interval, while for collisions beyond the 80% class the slope
is negative. To reduce uncertainties related to event selection and
normalization, we also provide the ratio of $R_{\rm AA}$ in adjacent centrality
intervals. Our results in peripheral collisions are consistent with a
PYTHIA-based model without nuclear modification, demonstrating that biases
caused by the event selection and collision geometry can lead to the apparent
suppression in peripheral collisions. This explains the unintuitive observation
that $R_{\rm AA}$ is below unity in peripheral Pb-Pb, but equal to unity in
minimum-bias p-Pb collisions despite similar charged-particle multiplicities.
