#!/usr/bin/perl use strict; use warnings; use 5.012; # #930268 my $OUTFILE; my @outfile=("F:/_Perl_/pl_test/abcd.out", "dev/nul/xyz.out"); for my $outfile(@outfile) { # $OUTFILE is a glob; dereference using $$OUTFILE. Otherwise warning is ambiguous:'not open GLOB(0x1628c24) using' open ($OUTFILE,">", $outfile) or warn "\t Could not open $$OUTFILE using \$outfile ($outfile), $!"; say "\t \$outfile is now $outfile"; print $OUTFILE "I wuz here in vers 1\n" or warn "\t Problem is with \$outfile: $outfile\n"; close ($OUTFILE); } say "\n\n" . "-" x10 . " 2nd vers using lc \$outfile in the 'die'\n"; my $OUTFILE2; my @outfile2 = ("F:/_Perl_/pl_test/abcd2.out", "dev/nul/pqrst.out"); for my $outfile2(@outfile2) { say "\t \$outfile2 is currently $outfile2"; open ($OUTFILE2,">", $outfile2) or warn "\t Could not open $outfile2 using \$outfile2, $!"; print $OUTFILE2 "vers 2 produced this line\n" or warn "\t Problem is with \$outfile2: $outfile2\n"; close ($OUTFILE2); }