I
I.M. Postor
Hello,
I have some xml which is formatted bij a xsl processor:
<c02 level="group">
<did>
<unitid>13-16</unitid>
<unittitle>several weeklies</unittitle>
<unitdate normal="1928/1931">1928-1931</unitdate>
<unitid>13-16</unitid>
</did>
<c03 level="file">
<unitid>13</unitid>
<unittitle>
<unitdate>1928</unitdate>
</unittitle>
</c03>
<c03 level="file">
<unitid>14</unitid>
<unittitle>
<unitdate>1929</unitdate>
</unittitle>
</c03>
<c03 level="file">
<unitid>15</unitid>
<unittitle>
<unitdate>1930</unitdate>
</unittitle>
</c03>
</c02>
but whenever there is a <c0X level="file"> element, for working
purposese i'd rather have flattened components:
<c02 level="group">
<did>
<unitid>13-16</unitid>
<unittitle>several weeklies</unittitle>
<unitdate normal="1928/1931">1928-1931</unitdate>
<unitid>13-16</unitid>
</did>
<c03 level="file"><unitid>13</unitid><unittitle><unitdate>1928</unitdate></unittitle></c03>
<c03 level="file"><unitid>14</unitid><unittitle><unitdate>1929</unitdate></unittitle></c03>
<c03 level="file"><unitid>15</unitid><unittitle><unitdate>1930</unitdate></unittitle></c03>
</c02>
<XXX level="file"> could be from <c01 level="file"> to <c12 level="file">, therefore:
while ($slurped_text =~ /(<(c0[1-9]|c1[012]) level="file">.*?<\/\2>)/sg)
{ print "hello"; } #OK
while ($slurped_text =~ /(<(c0[1-9]|c1[012]) level="file">.*?<\/\2>)/sg)
{$1 =~ s/\n *//g; }
ERROR: Modification of a read-only value attempted
How can I get the secondary substitution to work only on a found regex?
Or should I try another approach?
Cheers
I have some xml which is formatted bij a xsl processor:
<c02 level="group">
<did>
<unitid>13-16</unitid>
<unittitle>several weeklies</unittitle>
<unitdate normal="1928/1931">1928-1931</unitdate>
<unitid>13-16</unitid>
</did>
<c03 level="file">
<unitid>13</unitid>
<unittitle>
<unitdate>1928</unitdate>
</unittitle>
</c03>
<c03 level="file">
<unitid>14</unitid>
<unittitle>
<unitdate>1929</unitdate>
</unittitle>
</c03>
<c03 level="file">
<unitid>15</unitid>
<unittitle>
<unitdate>1930</unitdate>
</unittitle>
</c03>
</c02>
but whenever there is a <c0X level="file"> element, for working
purposese i'd rather have flattened components:
<c02 level="group">
<did>
<unitid>13-16</unitid>
<unittitle>several weeklies</unittitle>
<unitdate normal="1928/1931">1928-1931</unitdate>
<unitid>13-16</unitid>
</did>
<c03 level="file"><unitid>13</unitid><unittitle><unitdate>1928</unitdate></unittitle></c03>
<c03 level="file"><unitid>14</unitid><unittitle><unitdate>1929</unitdate></unittitle></c03>
<c03 level="file"><unitid>15</unitid><unittitle><unitdate>1930</unitdate></unittitle></c03>
</c02>
<XXX level="file"> could be from <c01 level="file"> to <c12 level="file">, therefore:
while ($slurped_text =~ /(<(c0[1-9]|c1[012]) level="file">.*?<\/\2>)/sg)
{ print "hello"; } #OK
while ($slurped_text =~ /(<(c0[1-9]|c1[012]) level="file">.*?<\/\2>)/sg)
{$1 =~ s/\n *//g; }
ERROR: Modification of a read-only value attempted
How can I get the secondary substitution to work only on a found regex?
Or should I try another approach?
Cheers