http://www.perlmonks.org?node_id=997914


in reply to How to call a function on each item after a split?

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.