http://www.perlmonks.org?node_id=1022139


in reply to Re: syntax questions
in thread syntax questions

open my $filelist, '>', $filelist or die "Can't open $filelist: $!";

This is simply an inadvertance, but using a new lexical  my $filelist for the filehandle in the open statement masks the file name in the old lexical of the same name (and also generates a warning if warnings are enabled, which is strongly recommended). I would write something like:

>perl -wMstrict -le "my $filelist = 'xyzzy'; open my $filehandle, '>', $filelist or die qq{opening '$filelist': $! +}; print $filehandle $_ for qw(foo bar baz); close $filehandle or die qq{closing '$filelist': $!}; " >type xyzzy foo bar baz