I don't see why you need to change anything.
Regex in Perl 5.10 is a superset of 5.8.
I modified your code slightly but it will run under both versions.
I think should also run under Perl 5.6.
I see no need here for fancy new features past what has been done for more than a decade.
There are new things that can be done.
But you may not have understood what could have been done in your prior code.

use strict; use Data::Dumper; my %hash=(); my $str="Test Tester Testing [Feb 18: 28_10_10] Test"; my $reg='(\w+) (\w+) (\w+) \[([\w\W]+)\] (.*?)'; my ($fname, $mname, $lname, $date) = $str =~ /$reg/is; if (defined ($date)) { $hash{fname}=$fname; $hash{mname}=$mname; $hash{lname}=$lname; $hash{date} =$date; } print Dumper \%hash; __END__ $VAR1 = { 'date' => 'Feb 18: 28_10_10', 'lname' => 'Testing', 'mname' => 'Tester', 'fname' => 'Test' };
Update:
If you must, although without spacing the regex out onto multiple lines, it is harder to understand...

use strict; use Data::Dumper; my %hash; my $str="Test Tester Testing [Feb 18: 28_10_10] TestXXX"; my $reg='(?<fname>\w+) (?<mname>\w+) (?<lname>\w+) \[(?<date>[\w\W]+)\ +]'; if ($str =~ /$reg/i) { %hash = %+; } print Dumper \%hash; __END__ $VAR1 = { 'lname' => 'Testing', 'date' => 'Feb 18: 28_10_10', 'fname' => 'Test', 'mname' => 'Tester' };

In reply to Re: Help required on understanding regular expressions by Marshall
in thread Help required on understanding regular expressions by shekarkcb

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.