crusty_collins has asked for the wisdom of the Perl Monks concerning the following question:

How to i get a value in the \*Symbol::GEN1

I would like to get this variable 'net_cmd_resp' => '"/test" directory created.' ,

use strict; use warnings; use Data::Dumper; use Net::FTP; $Data::Dumper::Terse = 0; $Data::Dumper::Sortkeys = 1; $Data::Dumper::Purity = 1; foreach (<DATA>){ chomp; my ($user, $passwd) = split(/,/,$_); next if (length $user <= 0); print $user . " " . $passwd . "\n"; chomp $user; chomp $passwd; my $ftp = Net::FTP->new('xxxxxxx', Debug => 0, Passive => 1); my $r = $ftp->login($user,$passwd); print Dumper $ftp; if ( $r ne 1){ print "Could not login\n\n"; sleep(5); }else{ my $r = $ftp->mkdir('test'); print Dumper $ftp; if ( $r ne 1){ print "Could not make dir\n"; }else{ $ftp->rmdir('test'); } } } __DATA__ a,1fpcq b,sVzqD c,KN6Vi d,AcT_2
Gives this output of
a 1fpcq $VAR1 = bless( \*Symbol::GEN1, 'Net::FTP' ); *Symbol::GEN1 = { 'io_sock_nonblocking' => 0, 'io_socket_domain' => 2, 'io_socket_proto' => 6, 'io_socket_timeout' => 120, 'io_socket_type' => 1, 'net_cmd_code' => '550', 'net_cmd_debug' => 0, 'net_cmd_lines' => [], 'net_cmd_partial' => '', 'net_cmd_resp' => [ '"/test" directory created.' + ], 'net_ftp_blksize' => 10240, 'net_ftp_host' => 'xxxxxxxxxx', 'net_ftp_localaddr' => undef, 'net_ftp_passive' => 1, 'net_ftp_type' => 'A' }; ETC....

Replies are listed 'Best First'.
Re: Net::Ftp question
by crusty_collins (Friar) on May 01, 2014 at 17:37 UTC
    I answered my own question.... $ftp->message That fixed it.
    foreach (<DATA>){ chomp; my ($user, $passwd) = split(/,/,$_); next if (length $user <= 0); print $user . " " . $passwd . "\n"; chomp $user; chomp $passwd; my $ftp = Net::FTP->new('xxxxxxx', Debug => 0, Passive => 1); $ftp->login($user,$passwd), $ftp->message; if ( $ftp->message =~ /Not\slogged\sin/){ print "Could not login\n\n"; }else{ $ftp->mkdir('test'), $ftp->message; if ( $ftp->message =~ /failed\sto\screate/){ print "Could not make dir\n"; }else{ $ftp->rmdir('test'); } } }