# read the whole file at once # XXX: updated (thanks, jmcnamara and VSarkiss) { local $/; $file = ; } @titles = $file =~ /_\[\d]([^_]*)/g;