Hi,
I'm a newbie with Perl and I wrote a perl script (see below) whose function is to read a *.html file and checks to insert the following HTML tags i.e <head>, </head>, </body>, <body>, </script>history.forward( ) if these tags are not present. Content of the html test file are as follows:
[snip]
May I know what is the correct method of matching the contents of the <form> tag? I've arbitrarily placed a string i.e. "HI THERE" for display purposes. May I also know how I could match whatever strings within the <form> tag, along with it's string quotations i.e. "HI"? I tried the following, but it yielded the following results:
In general it is considered a bad idea to try and parse HTML with a series of regular expressions, most on this list would suggest you use an HTML parser available from CPAN. Using a parser and a thorough reading of its documentation should make this fairly trivial. I have had good luck with HTML::TokeParser::Simple.
[snip]
I'm expecting that if the tag <body> does not exists, it should then be included into the *.html file immediately below the <form=....> tag i.e. :
<html>
<body>
<form="HI">
HELLO
Test file
</head>
</body>
However, it did not.
Moreover, may I know how I could rewrite the multiple if statements into an equivalent CASE statement? Could anyone kindly help me out on these matters?
perldoc -q 'switch or case'
Thanks
Danny
Good luck,
http://danconia.org
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>