I have a big data file `dump.all.lammpstrj` which I need to split/categorize into a series of files, such as `Z_1_filename`, `Z_2_filename`, `Z_3_filename` etc. based on the coordinates in each record.

The coordinates are saved in a disordered way, so my program reads each line and determines which file this record should be sent to.

I use a variable, `$filehandle = "Z_$i_DUMP"`

and I hope to open all of the possible files like this

```
for ( my $i = 1; $i <= 100; $i++ ) {
  $filehandle = "Z_$i_DUMP";
  open $filehandle,'>', "Z_$i_dump.all.lammpstrj.dat";
  ...
}

```

But when running my program, I get a message

> 
> Can't use string ("Z\_90\_DUMP") as a symbol ref while "strict refs" in use at ...
> 
> 
> 

I don't want to scan all the data for each output file, because `dump.all.lammpstrj` is so big that a scan would take a long time.

Is there any way to use a defined variable as a file handle?