tags:

views:

108

answers:

1

I have a dozen or so Perl files with this line:

my $version = "<span class=\"foottext\"><em>version 0.11</em></span>";

This is line 7 of each perl file. The element I need to batch-modify is "X.XX" -- the version number.

What is the most elegant script I can run from the shell (in Perl) to open each file, change the version number on line 7, and then write the file?

+1  A: 

A quick Google search reveals that the following one-liner should help:

perl -pi -w -e 's/version 0\.11/version 0.12/g;' *.pl

On a more general note, you should avoid code duplication and move that line into one (single) library file that is called by your dozen other files.

Heinzi
Thanks, I've just started learning -- I'll start reading up on calling library files now.
scraft3613
You might also consider not mixing presentation with code. Move all of that HTML to some sort of templating system.
brian d foy