Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: How can I reduce this with a REGEX?

by hdb (Prior)
on Mar 14, 2014 at 17:48 UTC ( #1078370=note: print w/replies, xml ) Need Help??


in reply to How can I reduce this with a REGEX?

Also using a hash but in a different way:

use strict; use warnings; my @strings = qw( 12-12 12-12-12 12-13-12-13 12-12-13-13 12-13-13-14 ) +; for (@strings) { my %hash; s/(\-?)(\d\d)/ $hash{$2}++ ? '' : $1.$2 /ge; print "$_\n"; }

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1078370]
help
Chatterbox?
[karlgoethebier]: hippo: Study the sources ; -) http://www.asterix .com/die-buecher/ die-asterix- mundart-reihe/
[choroba]: Perl to the rescue!
[Corion]: hippo: At least for the German translation, the wordplay is translated as well
[Discipulus]: always! but if i can ask choroba why you always use the inverted (to me) form 1 == $.?

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (13)
As of 2017-05-24 08:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?