use strict; use warnings; my $cli = 'file.txt'; open (FILE,"<$cli") or die $!; while (my $cli_str = ) { my @cli_str = ("$cli_str"); &next(@cli_str); } close FILE; sub next { my (@cli_str) = @_; print @cli_str; open (IN, ">data.txt") or die $!; print IN @cli_str; close IN; }