in reply to Re^2: Removing Newline Characters from File Data (chomp not working)
in thread Removing Newline Characters from File Data (chomp not working)
The purpose of the parentheses is to put the regular expression in list context, and then the [0] index takes the first and only element, which is the expression in the parentheses. Without that, the regular expression would be in scalar context because of the split function, and would return only the true/false. Perl's ability to modify functional behavior's based upon context is one of its great strengths, though it can also cause significant confusion to new acolytes.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Removing Newline Characters from File Data (chomp not working)
by mlux (Initiate) on Aug 27, 2009 at 17:20 UTC |