If you want quick and easy solution (why else would you want to use Perl?), then just use
my $find = qr|<book name=""\s+author="">|s;
my $replace = '<magazine>';
And as you want to replace something across multiple lines, you cannot read line by line, instead you should slurp file in scalar (if your file is small enough to fit into memory)
local $/; # undefines input lines separator
# open your file with open(FILE, '<', $filename);
my $text = <FILE>;
$text =~ s/$find/$replace/g;
# do with $text what you want now, print it or anything
# don't forget to close your FILE
This is quick and dirty, but works well. If your file does not fit into memory, or you want to be sure that everything works ok, use XML parsers, but remember
- do not use XML::Simple, it is broken, really
- for large files you need stream XML parsers, like XML::Parser