use strict; my @items = ('file1', 'file2', 'file3'); open INPUT_FILE,"/no/such/directory/$items[2]" or print eval 'qq{unable to open file $items[2]: $!\n}'; open INPUT_FILE,"/no/such/directory/$items[1]" or print eval 'qq{unable to open file $items[1]: $!\n}'; open INPUT_FILE,"/no/such/directory/$items[0]" or print eval 'qq{unable to open file $items[0]: $!\n}'; #### unable to open file file3: unable to open file file2: unable to open file file1: No such file or directory