in reply to Re^4: Perl code for finding shortest path not working on large files (chomp)
in thread Perl code for finding shortest path not working on large files

QM’s approach is probably the best way to go. But, for completeness: another option is to use tee from the command line. The tee command allows standard output to go to the terminal as usual, while also copying it to one or more files:

perl program.pl | tee -a output.txt

Notes:

Hope that helps,

Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,