develooper Front page | perl.fwp | Postings from July 2003

Re: Fun - Each character at most once

From:
Eugene van der Pijll
Date:
July 17, 2003 14:58
Subject:
Re: Fun - Each character at most once
Message ID:
20030717215750.GB467@alva.zevenwouden.nl
Alistair.McGlinchy@marks-and-spencer.com schreef:
> Can anyone improve the above so that it checks the whole of <>, not just one
> line? Bonus points for an explicit multi-character message rather than undef
> on failure. 

#!perl -0234
<>=~m{(.)[^$/]*\1}sand&two

contains no characters twice (except for the final \n), checks the whole
of <>, and prints a not-very-appropriate message on failure.

Eugene



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About