Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
The desired outcome should be :
abcd 723 abcd 724 abcde 552 abcde 554 abcde 553 abcded 756but instead I get :
abcd 723 abcd -724 abcde 552 abcde -554-553 abcdef 756 abcdefThe code:
while ($line=<DATA>) { my @c=($line=~/^(\w+)\t(\d+)((?:-\d+)*)/); my @d=@c[1..$#c]; foreach $e (@d) { print $c[0]," ", $e,"\n"; } } __DATA__ abcd 723-724 abcde 552-554-553 abcdef 756
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: regex problem
by tybalt89 (Monsignor) on Mar 04, 2018 at 19:55 UTC | |
Re: regex problem
by johngg (Canon) on Mar 05, 2018 at 00:43 UTC | |
Re: regex problem
by AnomalousMonk (Archbishop) on Mar 04, 2018 at 19:58 UTC | |
Re: regex problem
by Marshall (Canon) on Mar 05, 2018 at 19:47 UTC | |
Re: regex problem
by writch (Sexton) on Mar 06, 2018 at 16:06 UTC | |
Re: regex problem
by hippo (Bishop) on Mar 08, 2018 at 12:29 UTC | |
Re: regex problem SHORT SOLUTION
by python_guy (Initiate) on Mar 08, 2018 at 05:34 UTC |
Back to
Seekers of Perl Wisdom