in reply to Re^2: Suggestions to make this code more Perlish
in thread Suggestions to make this code more Perlish
Thanks for taking the time to study my code and provide feedback.
"your original solution handles lines like this properly:
Bangladesh,"Claire, Laura, Phillip, Pascale",70016,"5,6,7,8"
whereas s/$re,/$+{field}\037/g will never dequote the last field."
I made reference to the fact that we're dealing with "very specific input" in "Re^4: Suggestions to make this code more Perlish". I also alluded to the fact that different code would be required if the input changed.
You're correct in saying that it "will never dequote the last field"; however, the last field (in this "very specific input") is an unquoted integer, so no dequoting is required.
"One other minor observation: \037 is an atom, ..."
Yes, that's how I used \037 (along with \036 and \012) in:
$ perl -pe 'y/\036\037/\012|/' pm_1080161_output.tff
"... so no brackets are needed in s/[\037]+$//;"
The use of brackets here was a conscious decision to make it more obvious what the '+' quantifier referred to.
You're correct in saying that 's/\037+$//' would have worked as well as 's/[\037]+$//'.
-- Ken
|
---|