Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

RegEx- Use of uninitialized value in substitution iterator

Status
Not open for further replies.

drkestrel

MIS
Joined
Sep 25, 2000
Messages
439
Location
GB
I use
Code:
$stripped=~ s#/\*[^*]*\*+([^/*][^*]*\*+)*/|("(\\.|[^"\\])*"|'(\\.|[^'\\])*'|.[^/"'\\]*)#$2#gs;

for stripping JavaScript comments text files. Sometimes, I get the error Use of uninitialized value in substitution iterator at .....

the variable
Code:
$stripped
is read from file and as confirmed by
Code:
print $stripped;
prior to the line in question,
Code:
$stripped
is definitely initialised!

So what is wrong?
 
I don't have time to parse that regex, but, it may be that you are successful in getting and at the same time failing to match the portion in your second set of parens??? If so, you would not have anything in $2 to do your replacement.

' just a thought. 'hope this helps

If you are new to Tek-Tips, please use descriptive titles, check the FAQs, and beware the evil typo.
 
the regex is from O Reilly Cookbook, so presume it would be 'right' :-) ?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top