On Thu, Jul 19, 2012 at 04:07:49PM +0530, punit jain wrote:
> Hi ,
> 
> I am doing a concat operation in Perl  for a string like below : -
> 
> if( @folders ) {
> 
>     map {$query .= "not in:$_ and"; } @folders;
>     print "\n $query \n";
> 
>     }
> 
> @folders contain - Inbox, Sent
> 
> Output from above is - *not in:Inbox and not in:Sent and*
> Expected is = *not in:Inbox and not in:Sent* ----> ie without extra and
> after Sent
> 
> I tried this with join as well as :-
> 
> my $query="";
> foreach my $folder ( @folders )
> {
> $query = join "and" "not in:$folder" "$query";
> }
> 
> but still same result and this time extra "and" in beginning.
> 
>  Any idea how to do this ?

You need a mixture of the two approaches: map to prepend "not in:" and
join to join them.

  my $query = join " and ", map "not in:$_", @folders;

-- 
Paul Johnson - p...@pjcj.net
http://www.pjcj.net

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to