in reply to Take the input from command line and have output redirected to a file?
It doesn't appear that you need to redirect STDOUT in this case. You can open a file handle, and then print directly to it:
use warnings; use strict; open my $wfh, ">>", "output_cal_date.txt" or die "$0: open : $!"; my $currenttime = localtime(); print $wfh "Current Time : $currenttime\n\n"; # prints to file print "this prints to STDOUT"; print ("Enter the FROM date in dd/mm/yyyy format : \n"); my $from_date_1 = <STDIN>; chomp($from_date_1); print $wfh $from_date_1; close $wfh;
|
|---|