Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

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

by Lotus1 (Chaplain)
on Oct 08, 2012 at 18:54 UTC ( #997863=note: print w/ replies, xml ) Need Help??


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

Actually your code assigns the return values from clean() which are either 1 or the empty string. The function uses the side effect of changing $_ but could be modified to return the trimmed string instead.


Comment on Re^2: How to call a function on each item after a split?
Download Code
Re^3: How to call a function on each item after a split?
by CountZero (Bishop) on Oct 09, 2012 at 06:36 UTC
    Oops, my bad. I am so used to writing subs that return a meaningful result rather than do an in-place action-at-a-distance. MrSnrub has the right solution: just return $_ in the map.

    CountZero

    A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

    My blog: Imperial Deltronics

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://997863]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (14)
As of 2014-12-19 16:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (89 votes), past polls