in reply to Replacing XML Tag name with another
Developing Ratazong's comment:
Cheers, j#!/usr/bin/perl use strict; use warnings; # file given as command line argument my $file = shift @ARGV; die "Usage: $0 <file.xml>\n" unless $file; # step 1: open the file open FH, "<", $file or die "Can't open '$file': $!\n"; # step 2: read the file line-by-line while (<FH>) { # step 3: do the replacements s/<(\/?)H([12])>/<$1Heading $2>/g; # step 4: write the results the STDOUT print; } close FH;
|
---|
In Section
Seekers of Perl Wisdom