in reply to Re: How to clean an array of strings after a split
in thread How to clean an array of strings after a split

Thanks. I think I like this approach best because I don't need to concern myself with ensuring there are enough pipe symbols to suffice.
  • Comment on Re^2: How to clean an array of strings after a split

Replies are listed 'Best First'.
Re^3: How to clean an array of strings after a split
by AnomalousMonk (Archbishop) on Aug 29, 2013 at 20:26 UTC

    Actually, if you used kcott's suggestion here and split into a named array, e.g.
        my @fields = map { ... } split ..., $str;
    you wouldn't have to worry about how many pipes there are and 'uninitialized' variables: you get what you get, it's all defined, and it's easy to test how much you've gotten by taking the size of the array and to iterate over the array. Rather than writing  $varn you write  $fields[n] instead, but 0-based.
    But I assume you have your reasons for preferring individual named variables...