in reply to Array Filter and Lookahead
There is more than one way to do it:
Output:use Modern::Perl; my @test = ( "text text text 1 text", "1 text text text 2 text 3", "text 1 text text 2 text", "text text text 1 text 2 3.0", "1 2 3 4 5 6 7 8 9 10 11", "text text 4.5 text text" ); for (@test) { say "$_: $1" if /(\d+)\.?\d*?\D*?$/; }
text text text 1 text: 1 1 text text text 2 text 3: 3 text 1 text text 2 text: 2 text text text 1 text 2 3.0: 3 1 2 3 4 5 6 7 8 9 10 11: 11 text text 4.5 text text: 4
CountZero
A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James
My blog: Imperial Deltronics
|
---|
In Section
Seekers of Perl Wisdom