[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] New user's first question on replacing html code



At 12:27 PM -0500 3/5/00, tech support wrote:
>I want to replace some html code in a whole bunch of files that are 
>located in nested folders (all within a root folder). The 
>replacement of the HTML code in the files is actually three 
>different replacement (where I replace the header, footer, and some 
>more code inside the file).

First, a word of caution: make a copy and edit that, in case something
goes wrong.

>As someone who is about to start using Perl. How difficult is this 
>to do? I want to compare this to Python which I will be evaluating 
>VS Perl. I will doing the replacement for about some 10,000 files, 
>so should efficiency be a consideration?

It should be pretty easy under Perl, depending on the complexity of the
edits you're trying to do.  Perl's regular expressions help quite a bit
in this sort of thing.

Before you begin, look at whether you want to read the whole file in as
a single scalar or do the editing line-by-line.  Some data files respond
better to one technique; some to the other...

-r
--
Rich Morin:          rdm@cfcl.com, +1 650-873-7841, http://www.ptf.com/~rdm
Prime Time Freeware: info@ptf.com, +1 408-433-9662, http://www.ptf.com
MacPerl: http://www.macperl.com,       http://www.ptf.com/ptf/products/MPPE
MkLinux: http://www.mklinux.apple.com, http://www.ptf.com/ptf/products/MKLP

# ===== Want to unsubscribe from this list?
# ===== Send mail with body "unsubscribe" to macperl-request@macperl.org