shekarkcb has asked for the wisdom of the Perl Monks concerning the following question:
I was using Perl 5.8, and recently switched to perl 5.12 ( which comes default on suse 11.3). While browsing for regular expressions, i got some issues while converting regular expression from 5.8 to equivalent in 5.10, below is my working code.
use strict; use Data::Dumper; my %hash=(); my $str="Test Tester Testing [Feb 18: 28_10_10] Test"; #my $reg='(?<fname>\w+\b)\s(?<mname>\w+)\s(?<lname>\w+\s).*\]\k<fname> +'; #my $reg='(\w+)\s(\w+)\s(\w+).*?\[(.*?)\]$1'; my $reg='(\w+) (\w+) (\w+) \[([\w\W]+)\] (.*?)'; { # use re 'debug'; if($str =~ /$reg/is) { # %hash=%+; $hash{fname}=$1; $hash{mname}=$2; $hash{lname}=$3; $hash{date}=$4; # %hash=%+; } } print Dumper \%hash;
|
|---|