Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Perl : How to print to console while writing to file

Tags:

perl

Apologies for what I'm sure is a very simple question, but here goes.

How can I print a message to the console if I have a command line parameter to write to file? Here's what I have on the command line:

script.pl > outputFile.txt

And then, in the script

do_something(); # Prints output to file
print ("Done something."); # How can I make this print to the console?

I have a feeling I should be using a different method of printing the output of do_something(); to the file, but if possible I'd like to leave the file specified as a parameter on the command line.

like image 741
Emma Avatar asked Oct 29 '25 14:10

Emma


1 Answers

Print to STDERR

print STDERR "message\n";
like image 194
Jim Garrison Avatar answered Oct 31 '25 15:10

Jim Garrison