Emacs Lisp vs Perl: Validate Local File Links

Discussion in 'Perl Misc' started by Xah Lee, Apr 13, 2012.

  1. Xah Lee

    Xah Lee Guest

    〈Emacs Lisp vs Perl: Validate Local File Links〉
    http://xahlee.org/emacs/elisp_vs_perl_validate_links.html

    a comparison of 2 scripts.

    lots code, so i won't paste plain text version here.

    i have some comments at the bottom. Excerpt:

    ------------------

    «One thing interesting is to compare the approaches in perl and emacs
    lisp.»

    «For our case, regex is not powerful enough to deal with the problem
    by itself, due to the nested nature of html. This is why, in my perl
    code, i split the file by < into segments first, then, use regex to
    deal with now the non-nested segment. This will break if you have <a
    title="x < href=z" href="math.html">math</a>. This cannot be worked
    around unless you really start to write a real parser.»

    «The elisp here is more powerful, not because of any lisp features,
    but because emacs's buffer datatype. You can think of it as a
    glorified string datatype, that you can move a cursor back and forth,
    or use regex to search forward or backward, or save cursor positions
    (index) and grab parts of text for further analysis.»

    ------------------

    If you are a perl coder, and disagree, let me know your opinion.
    (showing working code is very welcome) My comment about perl there
    applies to python too. (python code welcome too.)

    Xah
    Xah Lee, Apr 13, 2012
    #1
    1. Advertising

  2. Xah Lee

    Dan Espen Guest

    Xah Lee <> writes:

    > 〈Emacs Lisp vs Perl: Validate Local File Links〉
    > http://xahlee.org/emacs/elisp_vs_perl_validate_links.html
    >
    > a comparison of 2 scripts.
    >
    > lots code, so i won't paste plain text version here.
    >
    > i have some comments at the bottom. Excerpt:
    >
    > ------------------
    >
    > «One thing interesting is to compare the approaches in perl and emacs
    > lisp.»
    >
    > «For our case, regex is not powerful enough to deal with the problem
    > by itself, due to the nested nature of html. This is why, in my perl
    > code, i split the file by < into segments first, then, use regex to
    > deal with now the non-nested segment. This will break if you have <a
    > title="x < href=z" href="math.html">math</a>. This cannot be worked
    > around unless you really start to write a real parser.»
    >
    > «The elisp here is more powerful, not because of any lisp features,
    > but because emacs's buffer datatype. You can think of it as a
    > glorified string datatype, that you can move a cursor back and forth,
    > or use regex to search forward or backward, or save cursor positions
    > (index) and grab parts of text for further analysis.»
    >
    > ------------------
    >
    > If you are a perl coder, and disagree, let me know your opinion.
    > (showing working code is very welcome) My comment about perl there
    > applies to python too. (python code welcome too.)


    Interesting.

    Perl, Python, and Lisp have real HTML parsers available.
    I've used the ones for Perl and Python.

    --
    Dan Espen
    Dan Espen, Apr 13, 2012
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. ekzept
    Replies:
    0
    Views:
    368
    ekzept
    Aug 10, 2007
  2. nanothermite911fbibustards
    Replies:
    0
    Views:
    375
    nanothermite911fbibustards
    Jun 16, 2010
  3. Xah Lee
    Replies:
    6
    Views:
    700
    Steven D'Aprano
    Oct 10, 2010
  4. Adam Funk
    Replies:
    4
    Views:
    232
    Adam Funk
    Jan 29, 2007
  5. Xah Lee
    Replies:
    1
    Views:
    229
    Dan Espen
    Apr 13, 2012
Loading...

Share This Page