Hi, Am fairly new to Perl, so would like some pointers on the correct (elegant) way of doing the following:
(It's working, so that is not a problem). I am using Net::LDAP to search and update our Novell Edirectory. One of the attributes returned is an array of "associations". Under certain circumstances I am removing one of these associations. My code snippet reads: ----------------------------------------------- use strict; ... ... if ( ... various conditions ... ) { my @assocs2 = ""; foreach (@assocs) { if (!/cn=DudDriver/) { if (!$assocs2[0]) { $assocs2[0] = $_; } else { $assocs2 [@assocs2] = $_; } } } $person->replace("DirXML-associations" => [@assocs2]); $person->update( $eDir); die "\nModify failed (" . ldap_error_name($mesg->code) . ")\n" if $mesg->code; } ... ----------------------------------------------- Now I would like to code that as my @assocs2 = ""; foreach (@assocs) { if (!/cn=DudDriver/) { $assocs2 [@assocs2] = $_; } } but that doesn't populate the first entry correctly because $ASSOCS2[0] = "" (as shown by 'x' in debug) prior to entering the loop. So far as I am aware, I need to define the array outside the 'foreach' loop so that I can use it in the 'replace' statement. So what is the accepted method of populating that first element of the array? Regards, Paul This is perl, v5.6.1 built for alpha-dec_osf-ld _______________________________________________ Perl-Unix-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs