Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
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>
~ ~ ~ ~ ~

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 drinking their drinks and smoking their pipes about the Monastery: (4)
As of 2016-10-01 22:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?






    Results (9 votes). Check out past polls.