in reply to Re: Populating the array, what am I doing wrong.
in thread Populating the array, what am I doing wrong.

What in the world did you mean to be doing there? Well
I was trying to populate the @fields with the selected objects from the ldapsearch

The ldapsearch, if you do it outside of the script, returns with:
cn=t43311,ou=subscribers,ou=users,ou=country,ou=domains,ou=cz,ou=chell +o jrMailBoxId=poohbear@woods.com jrMailboxAliasStore=5485113511 jrPWPUID=poohbear jrPWPUserPrefs=poohbear jrUserFriendlyID=poohbear

but all that seems to get populated in the array is dn jrMailBoxId jrMailboxAliasStore jrPWPUID jrPWPUsersPrefs jrUserFriendlyID

Replies are listed 'Best First'.
Re^3: Populating the array, what am I doing wrong.
by jdporter (Paladin) on Apr 25, 2008 at 14:57 UTC

    Ok, well you're going about that all wrong. To execute an external program and get its output into an array of lines, use qx():

    @fields = qx( /opt/apache/1.3.27/cgi-bin/cspireutils/ldapsearch -h 172 +.30.58.243 -p 389 -D $dirsrv -w 'passwd' -b ou=subscribers,ou=users,o +u=prague,ou=domains,ou=cz,ou=domains,o=chello cn=$sid dn jrMailBoxId +jrMailboxAliasStore jrPWPUID jrPWPUserPrefs jrUserFriendlyID );
    then you can easily iterate over the lines with foreach.

    Alternatively, you could use the while(<>) construct to read from a pipe connected to the output of an external program:

    open P, $command # as above or die "can't run $command - $!"; while (<P>)
    but note specially the use of an explicit filehandle inside the angle brackets. Omit that, and you'd be reading from stdin.

    If you assign to @fields as above, you'll be overwriting the array of values you orginally assigned to it. Is that what you intended?

    A word spoken in Mind will reach its own level, in the objective world, by its own weight