title: How to read the password from the text file in perl
body: <p>I am new to perl script, The below code is downloading the files from sftp server.</p>
  
  <pre><code>#!/usr/bin/perl
  
  use strict;
  use warnings;
  use Net::SFTP::Foreign;
  
  my $sftp = Net::SFTP::Foreign-&gt;new(
      'auser@sftp.rent.com',
      password =&gt; 'auser123',
      more     =&gt; ['-v']
  );
  
  $sftp-&gt;get('outgoing/DATA.ZIP', '/home/sar/')
    or die "unable to retrieve copy: ".$sftp-&gt;error;
  
  $sftp-&gt;disconnect;
  </code></pre>
  
  <p>Here i have hard codded the password, I want to avoid password in the script, Is there any other method to read the password from the file or any method is there?</p>
  
  <p>I searched in the stackoverflow and google, i don't know how to use this. I tried below one.  </p>
  
  <pre><code>PASSWORD=`cat /home/sar/passwd_file.txt`
  
  my $password = $ENV{'PASSWORD'}
  </code></pre>
  
  <p>Could you please help me to resolve this code.</p>