Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^5: Perl code for finding shortest path not working on large files (chomp)

by Athanasius (Archbishop)
on Jul 28, 2014 at 13:50 UTC ( [id://1095356]=note: print w/replies, xml ) Need Help??


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:

  • The -a option appends to the file instead of overwriting it.
  • You will also need to add the line:
    $| = 1;
    or its equivalent near the top of the Perl script to force a flush after every print statement (otherwise, you won’t see the Enter file name: prompt).
  • tee is standard on Unix-based operating systems. If you’re on Windows, you can download it as part of the GnuWin CoreUtils package from SourceForge.

Hope that helps,

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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1095356]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (8)
As of 2024-04-19 09:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found