Thanks in advance for reading this, and commenting.
The example below is from p.144 in the latest Lama book edition (O'Reilly 2008), and I can't get it to behave as the book states. It states that the diamond (<>) operator will take user input (which should be a file name), and run the search-n-replace against it. If a match is found, the [$^I] variable will create a new file with ".bak" appended to the file name, which will hold the output of the find-n-replace.
When I run the script, enter a file name (file is a text file in same directory containing the word "Author:" on a new line), nothing happens, and no file is created.
I'm beginning to think I'm missing something more fundamental than syntax. My question is, does this code work, and is it stated correctly?
I've tried running this on XP and Ubuntu, with the same effect.
[ use strict;
chomp(my $date = localtime); $^I = ".bak";
while (<>) { s/^Author:.*/Author: [I]new author name[/I]; } ][code = perl 5.010]
[
use strict;
chomp(my $date = localtime);
$^I = ".bak";
while (<>)
{
s/^Author:.*/Author: new author name;
}
]