<?xml version="1.0" encoding="windows-1252"?>
<node id="997914" title="Re: How to call a function on each item after a split?" created="2012-10-08 23:41:23" updated="2012-10-08 23:41:23">
<type id="11">
note</type>
<author id="597736">
aaron_baugher</author>
<data>
<field name="doctext">
&lt;p&gt;
You could change your &lt;c&gt;clean&lt;/c&gt; sub so it takes an array and returns an array.  Then you can 'pipe' your data through it:
&lt;/p&gt;
&lt;c&gt;
#!/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 | dog. ';
say for clean split /\|/, $str;
&lt;/c&gt;




&lt;div class="pmsig"&gt;&lt;div class="pmsig-597736"&gt;
&lt;p&gt;Aaron B.&lt;br /&gt;
Available for small or large Perl jobs; see my home node.
&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;</field>
<field name="root_node">
997827</field>
<field name="parent_node">
997827</field>
</data>
</node>
