I need to parse a string containing a repeating group. There is a count 
that holds the repeat count. Only when I extract the count will I know how 
many repeats there are.

For example:

isbn,title,copies,{author list}
is coded as (this is coming from the mainframe. I have no control over the 
format)

All are fixed length fields

1234567890The Mining of the Cosmos     0502Arthur C. Clarke    Sir Isaac 
Asimov 

The fourth field (the 02 after the  05) is the count of authors.

I think the (??{code}) could be used. But I am not sure how. I tried a 
couple of permutations with no result. Like this for example:

my $x = "04abcdefghijklmnopqur";
$x =~ /^(.{2})(.{??{3*\1}})(.*)/;  # get the count and extract that many 
groups of 3 chars. I am using the \1 as a multiplier.
print "1 = $1\n 2 = $2 \n 3 = $3\n"; 

When (?) it works, it should give me 

1 = 04 
2 = abcdefghijkl
3 = mnopqur




__________________________________________
Ranga Nathan / CSG
Systems Programmer - Specialist; Technical Services; 
BAX Global Inc. Irvine-California
Tel: 714-442-7591   Fax: 714-442-2840
 
_______________________________________________
Boston-pm mailing list
[email protected]
http://mail.pm.org/mailman/listinfo/boston-pm

Reply via email to