Hi all, I have to populate an array from an ldapsearch query but I'm doing something wrong and I can't work out what it is, if anyone can help out, I'd be grateful. The data for the ldapsearch is populated from a cgi.

#!/usr/bin/perl -w use CGI; $upload_dir = "/opt/apache/1.3.27/htdocs/cspireutils/files-ch"; $query = new CGI; $tstamp = `date '+%Y%d%m'`; #$username = $query->param("username"); #$password = $query->param("password"); $sid = $query->param("sid"); $email = $query->param("primaryemailradius"); $maildomain = $email; $altemail = $query->param("aliasemailradius"); $proftp = $query->param("proftp"); $dirsrv = "cn=directory manager"; chomp($email); $email =~ s/\@.*//g; my @fields = ("dn", "jrMailBoxId", "jrMailboxAliasStore", "jrPWPUID", +"jrPWPUserPrefs", "jrUserFriendlyID"); my @mailfields = ("jrMailId", "jrFullMailAliasList", "jrPrimaryMailId" +); open (MODLDIF, ">$upload_dir/$email-$tstamp") or die "Can't open $emai +l-$date for output"; open (MODDN, ">$upload_dir/$proftp-$tstamp") or die "Can't open $proft +p-$date for output"; print MODLDIF "$email\n"; @fields=~'/opt/apache/1.3.27/cgi-bin/cspireutils/ldapsearch -h 172.30. +58.243 -p 389 -D $dirsrv -w 'passwd' -b ou=subscribers,ou=u sers,ou=prague,ou=domains,ou=cz,ou=domains,o=chello cn=$sid dn jrMailB +oxId jrMailboxAliasStore jrPWPUID jrPWPUserPrefs jrUserFriendl yID'; print MODLDIF "@fields\n"; while (<>) { my %thisrecord = (); foreach my $field(@fields) { $thisrecord{$field} = ""; } s/\n^ //msg; chomp (); while (m/^([^:]*:?): (.*)/mg) { my ($field, $data) = ($1, $2); if (grep (/$field/, @fields)) { $thisrecord{$field} = $data; } } } print "$thisrecord{'jrUserFriendlyID'}"; if ($thisrecord{'jrUserFriendlyID'} = $email) { die " Error duplicate entry detected, please resolve manually" +; } else { print MODLDIF "$thisrecord{'dn'},ou=subscribers,ou=users,ou=pr +ague,ou=domains,ou=cz,ou=domains,o=chello \n"; print MODLDIF "changetype: modify\n"; print MODLDIF "replace : jrMailboxId\n"; print MODLDIF "jrMailbox: $maildomain\n"; print MODLDIF "-\n"; print MODLDIF "replace: jrPWPUID\n"; print MODLDIF "jrPWPUID: $proftp\n"; print MODLDIF "dn: $thisrecord{'jrMailboxAliasStore'},ou=OpenW +aveSupplement,ou=mail,ou=USCOs,ou=prague,ou=domains,ou=cz,ou=d omains,o=chello\n"; print MODLDIF "changetype: modify\n"; print MODLDIF "replace: jrPrimaryMailId\n"; print MODLDIF "jrPrimaryMailId: $email\n"; print MODLDIF "-\n"; print MODLDIF "replace: jrFullMailAliasList\n"; print MODLDIF "jrFullMailAliasList: $altemail\n"; print MODDN "%thisrecord{'jrPWPUID'},ouProFTPSupplement,ou=ftp +,ou=USCOs,ou=prague,ou=domains,ou=cz,ou=domains,o=chello\n"; print MODDN "jrPWPUID=$proftp\n"; } system ("ldapmodify -h 172.30.58.243 -p 389 -D $dirsrv -w 'passwd' -f +/opt/apache/1.3.27/htdocs/cspireutils/files-ch/$email-$tsta mp > /opt/apache/1.3.27/htdocs/cspireutils/files-ch/modify-$email-$tst +amp"); system ("ldapmodrdn -h 172.30.58.243 -p 389 -D $dirsrv -w 'passwd' -f +/opt/apache/1.3.27/htdocs/cspireutils/files-ch/$proftp-$tst amp >> /opt/apache/1.3.27/htdocs/cspireutils/files-ch/modify-$email-$t +stamp"); print <<ENDHTMLb; <HTML> <HEAD> <TITLE>Modifications submitted</TITLE> </HEAD> <BODY> <P></P> <P>The modification has been submitted for the Billing ID $sid</P> <P>Please take a look at</P> <A HREF="/cspireutils/files-ch/modify-$email-$tstamp">modification lo +g</A> </BODY> </HTML> ENDHTMLb exit;

The output from the array is:
dn jrMailBoxId jrMailboxAliasStore jrPWPUID jrPWPUserPrefs jrUserFrien +dlyID
I was expecting object fields of course :) And the output from the script in the apache logs is:
Applying pattern match (m//) to @array will act on scalar(@array) at / +opt/apache/1.3.27/cgi-bin/cspireutils/upload-ch.pl line 25. Applying pattern match (m//) to @array will act on scalar(@array) at / +opt/apache/1.3.27/cgi-bin/cspireutils/upload-ch.pl line 25. Use of uninitialized value in string at /opt/apache/1.3.27/cgi-bin/csp +ireutils/upload-ch.pl line 44.

In reply to Populating the array, what am I doing wrong. by trelane

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.