Hi punit, see below for my response.
On Thu, 19 Jul 2012 16:07:49 +0530 punit jain <contactpunitj...@gmail.com> 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"; > > } 1. "use strict;", "use warnings;" - fix all the problems that they report. 2. Don't use map instead of foreach for side-effects: http://perl-begin.org/tutorials/bad-elements/#map_instead_of_foreach > > @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"; > } > I would suggest doing something like (untested): my $query = join(' and ', (map { "not in:$_" } @folders)); Regards, Shlomi Fish > but still same result and this time extra "and" in beginning. > > Any idea how to do this ? > > > Best Regards. -- ----------------------------------------------------------------- Shlomi Fish http://www.shlomifish.org/ Best Introductory Programming Language - http://shlom.in/intro-lang <mst> I find it’s usually safe to assume that whatever shlomif’s doing, there isn’t a good reason for it. Please reply to list if it's a mailing list post - http://shlom.in/reply . -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/