in reply to Re^2: Error coming while using Use Strict
in thread Error coming while using Use Strict

You don't need a different filehandle when you access files sequentially. Also the previous contents of the filehandle variable is quite meaningless to its use as a filehandle. So just use something like this:

for(my $i=0;$i<$#key;$i++) { my $val; #No need to put anything in it $output_file=$key[$i].$output_file; open($val,'>:utf8',"$output_file");

Replies are listed 'Best First'.
Re^4: Error coming while using Use Strict
by Anonymous Monk on Oct 13, 2011 at 10:12 UTC

    hi,

    I am creating five file .So i expect unique file handler for each file.That program is running without using strict

      No, you are creating one file, so you need one file handle. Then, you are creating one file, so you again need one file handle. Then, you are creating one file, so you again need one file handle. Then, you are creating one file, so you again need one file handle. Then, you are creating one file, so you again need one file handle.
      Which makes it one file handle in total.

      Your are creating five files, but one after another. So you can reuse one filehandle for all five files. Only if you had more than one file open at the same time(!) would you need more than one filehandle. In that case use this:

      my @key; for(my $i=0;$i<5;$i++) { $output_file=$key[$i].$output_file; open($key[$i],'>:utf8',"$output_file"); my $f= $key[$i]; print $f $start."\n"; ...