I am looking to convert a comma delimited list into an array, and the list may or may not also have white space around the delimiters for readability, so I want to Trim post Split. Also, I am just dipping my toes into PowerShell, and trying to learn all the good habits, and my sense is that this is where the pipeline is powerful.
So, I have the Split part
$CSVData = @("One , Two , Three ") #extranious spaces just to make the point
$Data = $CSVData -Split (",")
However, I can't seem to pipe this to -Trim. Also, I have found a number of references to this idiom:
%{$Data = $_.Split(",")} which I understand to be shorthand for ForEach, which seems to have potential, perhaps to handle the Trim after $Data is a populated array. But $_ is the pipeline content I think, not the elements of the array
I think. And I am sure I don't understand the nuances of dot notation, and when that is preferable over other approaches and why. And it seems like there should be an elegant way to combine the Split and the Trim as a one liner.
Any good resources that will get me headed in the right direction?
Thanks!
Gordon