http://www.perlmonks.org?node_id=1009637


in reply to Re^4: Problem with ampersand and regex
in thread Problem with ampersand and regex

What if you use backticks (`ldapsearch`) instead of system("ldapsearch"). When I put mail: asdf@123.com in a file and called @array = `cat file`, your script worked, but not when using @array = system("cat file").

Take a look at What's the difference between Perl's backticks, system, and exec?. The system() call returns the exit status, not the actual result (STDOUT) of the command like the backtick operator does.