SoFunction
Updated on 2025-04-07

Perl uses variables as handle introduction


#!/usr/bin/perl -w
use strict;
use warnings;
use FileHandle;
my %fh;
my @array = (1..10);
for(1..5){
        open $fh{$_},">$_.txt" or die;
}
for(1..5){
#print $fh{$_} "$_\n"; Error here
        $fh{$_}->print( "$_\n" );
# is a function in FileHandle or use (my $h = $fh{$_};  print $h "$_\n";)
 }