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

I was looking through the code for Net::FTP and I noticed something that looks like a typeglob reference inside the first key to a multi-dimensional hash:
my $ftp = $pkg->SUPER::new(PeerAddr => $peer, PeerPort => $arg{Port} || 'ftp(21)', Proto => 'tcp', Timeout => defined $arg{Timeout} ? $arg{Timeout} : 120 ) or return undef; ${*$ftp}{'net_ftp_host'} = $host; # Remote hostname ${*$ftp}{'net_ftp_type'} = 'A'; # ASCII/binary/etc mode ${*$ftp}{'net_ftp_blksize'} = abs($arg{'BlockSize'} || 10240);
Would someone mind explaining to me the semantics of this? Thanks in advance.
  • Comment on Please explain ${*$ftp}{'net_ftp_host'} = $host; # Remote hostname
  • Download Code

Replies are listed 'Best First'.
Re: Please explain ${*$ftp}{'net_ftp_host'} = $host; # Remote hostname
by btrott (Parson) on Sep 13, 2000 at 23:02 UTC
    A Net::FTP object is a blessed typeglob. So that $ftp object is a blessed glob; when you see something like this:
    ${*$ftp}{'net_ftp_host'}
    that dereferences the typeglob, then accesses the hash portion of the glob.

    There's a (better :) discussion of this in Advanced Perl Programming.

      Thanks. By the way, I am the "Anonymous Monk" who posted this question. I did not realize I was using a new browser and had not previously logged in.