Simply use the 3 argument open method.
use strict;
use warnings;
my $line = "Hello Again!";
open (my $fh, ">", "/home/vibes/text") || die "Failed to open /home/vibes/text $!";
print $fh "$line\n";
close($fh); # Always close opened files.
More Related Contents:
- How can I convert my shell script to Perl? [closed]
- search using perl one liner within a file [closed]
- What’s the easiest way to install a missing Perl module?
- How do I use boolean variables in Perl?
- Doesn’t Perl include current directory in @INC by default?
- Why does my file content/user input not match? (missing chomp canonical) [duplicate]
- What is the best way to slurp a file into a string in Perl?
- Scalar vs List Assignment Operator
- How can I check if a Perl array contains a particular value?
- How do you capture stderr, stdout, and the exit code all at once, in Perl?
- How to fix a locale setting warning from Perl
- How can I fire and forget a process in Perl?
- What’s the best way to make a deep copy of a data structure in Perl?
- Getting STDOUT, STDERR, and response code from external *nix command in perl
- What is the difference between new Some::Class and Some::Class->new() in Perl?
- Why can’t I match my string from standard input in Perl?
- How do I choose a package name for a custom Perl module that does not collide with builtin or CPAN packages names?
- Delete ClearCase Views Script
- How to pass a variable from a child process (fork by Parallel::ForkManager)?
- What’s the difference between single and double quotes in Perl?
- How do I get the full path to a Perl script that is executing?
- Perl subroutine arguments
- What does the function declaration “sub function($$)” mean?
- How to create recursive hash of hash ? (With unlimited deep)
- How can I call a shell command in my Perl script?
- Which cpan installer is the right one? (CPAN.pm/CPANPLUS/cpanminus)
- How do I lock a file in Perl?
- Why is the Switch module deprecated in Perl?
- How can I extract text from a PDF file in Perl?
- How do I retrieve the terminal width in Perl?