Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

Re^2: Suggestion on rewriting small code

by Anonymous Monk
on Aug 21, 2019 at 12:30 UTC ( #11104809=note: print w/replies, xml ) Need Help??

in reply to Re: Suggestion on rewriting small code
in thread Suggestion on rewriting small code

No you're making it too complicated! :-)

The first problem is initializing the string with that quote.

That causes the next, of concat in a loop, leaving crud at the end of the string.

The dominoes continue to fall as ya chop chop chop away the first two mistakes.

Finally, having to add a quote to the end of a sting is a bad sign that something went wrong earlier, which is now being hacked into compliance.

Also you should know that printing from inside subs is a bad habit, but don't ask me how I know. It just quickly leads to layers of confusion. May I suggest:

say run(); sub run { my @arr = (12341,1245125,1525125,125125125); my $str = join '', '"', (join ' || ', map {"job==$_"} @arr), '"'; return $str }

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (5)
As of 2020-11-30 18:10 GMT
Find Nodes?
    Voting Booth?

    No recent polls found