Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
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 avoiding work at the Monastery: (14)
As of 2015-07-06 17:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (77 votes), past polls