Q:

Perl Net::FTP get error Bad remote filename 'ex.pl

I have file called ftp which has filename e.g ex.pl as its only content and am i trying to read it via file handle and store it in scalar variable and trying to get it through $ftp->get but it gives error: Bad remote filename 'ex.pl
' 
where ex.pl is an actual file stored in my directory.
Here is my code:
sub restore () {
    #open (IN,"ftpfile") or die "failed to open: $!";
    open( INN, "ftp" ) or die "fail to open: $!";
    my $array = <INN>;
    print $array;
    my $ftp = Net::FTP->new("$ARGV[0]") or die "host error: $@";
    $ftp->login( "$ARGV[1]", "$ARGV[2]" )
        or die "login error: ", $ftp->message;
    $ftp->cwd("/home/qwerty/perl");
    $ftp->get("$array") or die "error:", $ftp->message;
}

restore;

A:

The problem here is - you need to chomp $array; because otherwise you get a newline embedded. 
I would note - you're doing something a little messy with that open call - INN will be a global file handle, and you don't close it. It would be better to:
open ( my $input, "<", "ftp" ) or die $!;
my $filename = <$input>; #read one line;
chomp $filename;

I would also suggest assigning name/login etc. earlier on in your program:
my ( $hostname, $login, $password ) = @ARGV; 

Because then you can error check these things (e.g. if they exist, and are valid etc.). 

