Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

Re: How to call a function on each item after a split?

by kcott (Chancellor)
on Oct 09, 2012 at 09:02 UTC ( #997957=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download

  1. or download this
  2. or download this
    say for map { (/\A\s*(.*?)\s*\z/) } split /\|/, $str;
  3. or download this
    say for map { clean($_) } split /\|/, $str;
    sub clean { ($_[0] =~ /\A\s*(.*?)\s*\z/)[0] }
  4. or download this
    $ perl -Mstrict -Mwarnings -E '
    my $str = " \t item0 with leading whitespace |item1  | item2| item3 
    <itemN with trailing whitespace>

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://997957]
[Lady_Aleena]: shmem, that is understandable! The two examples in File::Find don't make sense to me on a quick glance.
[marioroy]: LA if the find worked from Unix command line, or does it not. Likely a quoting issue inside Perl qx.
[Lady_Aleena]: marioroy, the find worked fine at the command line.
[marioroy]: LA, yeah. than there's no reason why it cannot work inside qx. But chatting is hard in PM. I cannot see the code now.
[shmem]: Lady_Aleena: sometimes a quick glance isn't enough.

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (10)
As of 2017-04-23 20:56 GMT
Find Nodes?
    Voting Booth?
    I'm a fool:

    Results (432 votes). Check out past polls.