Redirect output to a file in Perl

Home > Search
  by

This script is an example of redirecting "Hello World" to example.txt.

#!/usr/bin/perl
use strict;
use warnings;

open STDOUT, '>', "example.txt";
select STDOUT;
print "Hello World";
close (STDOUT);

 



Add a Comment




We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.




Please enter in the box below so that we can be sure you are a human.




Comments