in reply to Concatenating strings with tabs between and returning the result

Hi ,

sub concat { map { length($_) < 8 ? {$_=$_."\\t";$_.=$_;return $_;}:{$_.=$_;ret +urn $_;}@_; }
  • Comment on Re: Concatenating strings with tabs between and returning the result
  • Download Code

Replies are listed 'Best First'.
Re^2: Concatenating strings with tabs between and returning the result
by Aristotle (Chancellor) on Jan 18, 2003 at 21:51 UTC

    You can't use naked blocks like that in a ternary operator. You also appear to be using map in void context as a loop to catenate elements to $_. Unfortunately you seem to misunderstand that map returns a list and also that the $_ you are assigning to is aliased to each element of the array in turn, so you are not catenating to the $_ you previously had. Not surprisingly you make no attempt to concatenate the list of elements map returns.

    I tried to reconstruct what you probably meant, but the $_.=$_; return $_ part doesn't make any sense at all, so I don't have any idea what you were thinking.

    Please make at least a token effort to verify your code next time.

    Makeshifts last the longest.

Re: Re: Concatenating strings with tabs between and returning the result
by poj (Abbot) on Jan 18, 2003 at 21:39 UTC
    I can't get your code to compile, is it correct ?
    poj