Date: Thu, 27 Apr 2006 00:37:21 -0700 From: Andrew Reitz <ajr9@po.cwru.edu> To: Nikolas Britton <nikolas.britton@gmail.com> Cc: FreeBSD Questions <questions@freebsd.org> Subject: Re: Perl: sort string alphabetically, or remove dupe chars? Message-ID: <C9CD63DC-3BEA-41DD-9005-7D02926061F4@po.cwru.edu> In-Reply-To: <ef10de9a0604260034y7c27ca88l417f8fc0f495859a@mail.gmail.com> References: <ef10de9a0604251540p6461bfedgf788d500a81e7190@mail.gmail.com> <ef10de9a0604251754r3292719dqc29d96095a9f0752@mail.gmail.com> <20060426030535.GA1540@holestein.holy.cow> <ef10de9a0604260034y7c27ca88l417f8fc0f495859a@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Apr 26, 2006, at 12:34 AM, Nikolas Britton wrote: > On 4/25/06, Parv <parv@pair.com> 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.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?C9CD63DC-3BEA-41DD-9005-7D02926061F4>