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 |