On 8/8/07, kapil.V <[EMAIL PROTECTED]> wrote:
> Hi,
>     I tried this to see if the file is an html:
> perl -ne '!<html>.+?</html>!s and print "html\n"' html.htm
> This does not work. What is the problem?
>

The first problem is that it's not valid Perl; it won't compile. You
should be seeing an error like "Substitution pattern not terminated at
-e line 1."

If you want to use delimeters other than '/' with a match, you need to
specify the m':

    m!<html>.*?</html>!s

Also, as others have pointed out, you need to "slurp" the file. The /s
modifier just lets '.' match newlines that may be in the input. It
doesn't force STDIN to read the entire file at once. You need to set
$/, or use the -0 switch on the command line to let Perl know you want
to read in some way other than line-by-line.

HTH,

-- jay
--------------------------------------------------
This email and attachment(s): [  ] blogable; [ x ] ask first; [  ]
private and confidential

daggerquill [at] gmail [dot] com
http://www.tuaw.com  http://www.downloadsquad.com  http://www.engatiki.org

values of β will give rise to dom!

Reply via email to