[From nobody Mon Aug 2 21:29:00 2004 Return-Path: <fwp-return-3564-pagaltzis=gmx.de@perl.org> X-Flags: 0000 Delivered-To: GMX delivery to pagaltzis@gmx.de Received: from pop.gmx.net [213.165.64.20] by localhost with POP3 (fetchmail-6.2.5) for ap@localhost (single-drop); Tue, 01 Jun 2004 13:55:41 +0200 (CEST) Received: (qmail 508 invoked by uid 65534); 1 Jun 2004 11:55:24 -0000 Received: from onion.develooper.com (HELO onion.perl.org) (63.251.223.166) by mx0.gmx.net (mx027) with SMTP; 01 Jun 2004 13:55:24 +0200 Received: (qmail 37786 invoked by uid 1005); 1 Jun 2004 11:55:18 -0000 Mailing-List: contact fwp-help@perl.org; run by ezmlm Precedence: bulk List-Post: <mailto:fwp@perl.org> List-Help: <mailto:fwp-help@perl.org> List-Unsubscribe: <mailto:fwp-unsubscribe@perl.org> List-Subscribe: <mailto:fwp-subscribe@perl.org> Delivered-To: mailing list fwp@perl.org Received: (qmail 37767 invoked from network); 1 Jun 2004 11:55:18 -0000 Delivered-To: fwp@perl.org X-Spam-Status: No, hits=0.0 required=7.0 tests= X-Spam-Check-By: la.mx.develooper.com X-Authenticated: #163624 Date: Tue, 1 Jun 2004 13:37:42 +0200 From: "A. Pagaltzis" <pagaltzis@gmx.de> To: fwp@perl.org Subject: Re: Regular expression for years after a given one Message-ID: <20040601113742.GA20273@klangraum> Mail-Followup-To: fwp@perl.org References: <1086081445.3883.18.camel@localhost.telbit.pt> Content-Disposition: inline In-Reply-To: <1086081445.3883.18.camel@localhost.telbit.pt> User-Agent: Mutt/1.4.2.1i X-Spam-Rating: onion.develooper.com 1.6.2 0/1000/N X-GMX-Antivirus: -1 (not scanned, may not use virus scanner) X-GMX-Antispam: 0 (Mail was not recognized as spam) Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=iso-8859-15 * Jose Alves de Castro <jcastro@telbit.pt> [2004-06-01 11:59]: > BTW: This was made so it would work with $year consisting of > four digits... any care to make it generic? :-) sub rx_gt { local $_ = shift; return if /\D/; my @alt = ''; for(split //) { $_ .= '\d' for @alt[ 1 .. $#alt ]; if($_ <= 7) { unshift @alt, $alt[0]; $alt[0] .= $_; $alt[1] .= "[@{[ $_+1 ]}-9]"; } elsif($_ == 8) { unshift @alt, $alt[0]; $alt[0] .= 8; $alt[1] .= 9; } else { # == 9 $alt[0] .= 9; } } shift @alt; my $rx = join '|', @alt; return "(?:$rx)"; } $_ = "14987345"; print map "$_\n", "$_:", rx_gt $_; -- Gruss, Aristoteles "Wer nicht über sich selbst lachen kann, nimmt das Leben nicht ernst genug." ]