in reply to simple regexp problem

what about just using perldoc -f split?
($part1, $part2) = split(/_/, $str); ($part1, $part2) = split(/_/, $str1); # or possibly better depending on context: @parts = split(/_/, $str);

Replies are listed 'Best First'.
Re^2: simple regexp problem
by pKai (Priest) on Dec 05, 2005 at 18:04 UTC
    I think you have to add a limit parameter to split here, to not lose additional "underscore delimited fields"

    D:\temp>perl -e "$x='a_b_c'; ($j, $k) = split /_/, $x; print $k" b D:\temp>perl -e "$x='a_b_c'; ($j, $k) = split /_/, $x, 2; print $k" b_c
      true, but is totally dependent upon OP's requirements .. should "a_b_c" result in part1=a, part2=b and c getting lost, or should "a_b_c" result in part1=a and part2=b_c ?