in reply to Re: Can we do without auxiliary variable here?
in thread Can we do without auxiliary variable here?

print map { "$prefix$_" } split /\n/, join '', @_

Fixed:

print map { "$prefix$_" } split /^/m, join('', @_), -1;

Note: split implies the "m" for that pattern, but it's clearer to specify it.

Update: As Eliya kinda points out, there won't ever be null trailing fields with that pattern, so the above can be simplified to

print map { "$prefix$_" } split /^/m, join '', @_;

Replies are listed 'Best First'.
Re^3: Can we do without auxiliary variable here?
by rovf (Priest) on Feb 28, 2011 at 17:12 UTC
    Great solution! I completely forgot about the "negativ LIMIT" parameter of split.

    -- 
    Ronald Fischer <ynnor@mm.st>
      I completely forgot about the "negativ LIMIT" parameter

      I think the crucial idea here is to split on ^, not the negative limit. The latter isn't even needed, because there are no null fields in this case.