You could change your clean sub so it takes an array and returns an array. Then you can 'pipe' your data through it:
#!/usr/bin/env perl use Modern::Perl; sub clean { for (@_){ s/^\s+//; s/\s+$//; # this includes chomp } return @_; } my $str = 'The | quick | brown | fox | jumped| over | the | lazy | do +g. '; say for clean split /\|/, $str;
Aaron B.
Available for small or large Perl jobs; see my home node.
In reply to Re: How to call a function on each item after a split?
by aaron_baugher
in thread How to call a function on each item after a split?
by MrSnrub
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |