Beefy Boxes and Bandwidth Generously Provided by pair Networks Frank
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: read a file and insert closing tags if not present

by gopalr (Priest)
on Mar 29, 2007 at 10:36 UTC ( #607196=note: print w/ replies, xml ) Need Help??


in reply to read a file and insert closing tags if not present

Hi Valavan,

my $sgml = <<SGML; <html> <greeting class="simple">Hello, world!<head>heading</head> </html> SGML while ($sgml=~s#(<)([^/<>\s]+)((?:\s[^/<>]+)?>)([^<>]+)(<[^/<>]+>)#$1$ +2$3$4$1\/$2>$5#){} print "\n\n"; print "\nOutput:\n$sgml\n"; print "\n\n";

Input:

<html> <greeting class="simple">Hello, world!<head>heading</head> </html>

Output:

<html> <greeting class="simple">Hello, world!</greeting><head>heading</head> </html>
~ ~ ~ ~ ~


Comment on Re: read a file and insert closing tags if not present
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://607196]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (5)
As of 2014-04-21 08:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (492 votes), past polls