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


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 }