#!/usr/bin/perl use warnings; use strict; my $f = 'chapter 1,2,3'; $f =~ s/ ([0-9,]+)/\\ {$1}/; print "$_\n" for glob $f;