From owner-freebsd-questions@FreeBSD.ORG Thu Apr 27 07:37:34 2006 Return-Path: X-Original-To: questions@freebsd.org Delivered-To: freebsd-questions@FreeBSD.ORG Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 19A8D16A402 for ; Thu, 27 Apr 2006 07:37:34 +0000 (UTC) (envelope-from ajr9@po.cwru.edu) Received: from beta.eecs.cwru.edu (beta.EECS.CWRU.Edu [129.22.150.110]) by mx1.FreeBSD.org (Postfix) with ESMTP id A1C9643D45 for ; Thu, 27 Apr 2006 07:37:31 +0000 (GMT) (envelope-from ajr9@po.cwru.edu) Received: from [10.0.0.6] ([::ffff:72.25.105.188]) (AUTH: PLAIN reitz, TLS: TLSv1/SSLv3,128bits,RC4-SHA) by beta.eecs.cwru.edu with esmtp; Thu, 27 Apr 2006 03:37:30 -0400 id 000ABE62.445074BA.00001E7D In-Reply-To: References: <20060426030535.GA1540@holestein.holy.cow> Mime-Version: 1.0 (Apple Message framework v746.3) Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: Content-Transfer-Encoding: 7bit From: Andrew Reitz Date: Thu, 27 Apr 2006 00:37:21 -0700 To: Nikolas Britton X-Mailer: Apple Mail (2.746.3) Cc: FreeBSD Questions Subject: Re: Perl: sort string alphabetically, or remove dupe chars? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 27 Apr 2006 07:37:34 -0000 On Apr 26, 2006, at 12:34 AM, Nikolas Britton wrote: > On 4/25/06, Parv wrote: [snip] > Thanks parv... I meant the algorithm was clunky, not the code... I'm > so new at this that I can't read your code, and I have a hard enough > time reading mine own :-). > > I've got another simple problem now. How do I get this code to stop > printing everything on a newline, I'm not using \n in my print > statement so why does it do that and how do I get it to stop? > > @wordlist1 = `sed /^$sedstring1\\\$/\\!d < enable2k_wordlist`; > foreach (@wordlist1) { > $string = $_; > $string =~ s/[$solvedletters1]//g; > my @chars = split("", $string); > $string = ""; @chars = sort (@chars); > foreach (@chars) { > $string .= $_; > } > $string =~ tr///cs; > print "$string"; > } Hi Nikolas, Most likely, your input has '\n' characters at the end of every line, and you aren't doing anything in perl to strip those away. Try adding a 'chomp($string);' line before you print. -Andy Reitz.