in reply to Code review: function to trim whitespace from all items in a list

I personally don't have a problem with modification of the input; my own trim functions in various incarnations do just that, most of the time in-situ & returning nothing.

If your code expects the input given not to be fiddled with, then the trim function should make a copy of the input to work on. In either case, I would expect a note about input modifications in pod, saving me from a code dive.

Devoid of pod, the function needs to work on a copy of the input & not touch input any further. Thus working with P::C.

  • Comment on Re: Code review: function to trim whitespace from all items in a list

Replies are listed 'Best First'.
Re^2: Code review: function to trim whitespace from all items in a list
by LanX (Saint) on Nov 21, 2014 at 15:14 UTC
    > I personally don't have a problem with modification of the input;

    I also see some applications for this...

    ...but then it would be better to force void context by checking wantarray to avoid confusion.

    Not sure about the best naming convention here.

    Maybe trim(@x) for mutator and @y=trimmed(@x) for non-mutator???

    Cheers Rolf

    (addicted to the Perl Programming Language and ☆☆☆☆ :)