in reply to Problems with matching?

I'm not sure why you think you need to slurp the file:

use strict; use warnings; use 5.010; my $str =<<'ENDOFSTRING'; unit 53 { description 1234-rwan-1; vci x.yy; } unit 54 { description 45ff-rwan-1; vci x.yz; ENDOFSTRING open(my $INPUT, '<', \$str) or die "Couldn't open string for IO: $!"; while (my $line = <$INPUT>) { if ($line =~ /^ \s+ description \s (\w{4}) (- \w+ - \w+); /xms ){ say "$1 <=> $2"; } } --output:-- 1234 <=> -rwan-1 45ff <=> -rwan-1

Replies are listed 'Best First'.
Re^2: Problems with matching?
by Argel (Prior) on May 19, 2011 at 00:06 UTC
    My apologies. I should have made it clearer, but I thought the comment "# Should only be processing each name once!" would suffice since it implies names can exist more than once. In fact, pretty much all of them exist at least twice. If they only existed once this would have been easy!!

    Elda Taluta; Sarks Sark; Ark Arks