Hi Dave. See my answer in-line below.
[EMAIL PROTECTED] wrote: > > This may be a lame question and I understand what it's doing, but I would > like to know if it is possible to undefine a global EXPR if it's passed > into a subroutine? > > Code here reduced to the basics. After the return from routine > closeFtpConn I want, in this case, $MVSFTP undefined. > > . > my $MVSFTP; > . > > $MVSFTP = Net::FTP->new( $mvsFtpHost, Debug => $myDebugMode ) > or &errout("Cannot connect to $mvsFtpHost;"); > . > . > &closeFtpConn ( $MVSFTP ); Don't use the ampersand notation unless you specifically need it. If you don't know what it does differently then you don't need it! closeFtpConn($MVSFTP); is the syntax to use. > __END__ Perl will stop compilation at this line, so with it placed here closeFtpConn() will be undefined and you'll get a run-time error. > sub closeFtpConn ($) { Like the ampersand notation, don't use prototypes unless you know what they do, and you need that behaviour. In particular they're for writing list operators, and you're not using closeFtpConn() as a list operator. Just sub closeFtpConn { : } Will do fine. > my ( $FTPOBJ ) = @_; At this point the elements of the @_ array are aliases for the actual parameters passed in the call. This line copies the value of the first parameter into the (local) lexical variable $FTPOBJ. > $FTPOBJ->quit; > . > . > undef $FTPOBJ; And this line undefines the lexical variable. It has no effect outside the subroutine. > } However, because the elements of @_ are aliases, you can affect the actual parameters by manipulating those elements, so undef $_[0]; will work for you. Since in this case the parameter is an object reference it should work fine; but note that if you pass a constant as the actual parameter then this statement will throw a run-time error. You should use 'eval' to handle this case if it is a possibility. HTH, Rob _______________________________________________ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs