I know, this was asked 1000 times on the mailing list. The thing is I
keep all emails that I find useful for my project, and delete the
others.

And this time I wanna do a little easy thing asked numerous time here,
and I can't find a sample script.

I want to replace every occurence of a word from a file. That word
*cannot* be part of another word (i.e. car, carton, carries).

use strict;

my $fd = "/foo/bar";

open (DIR, $fd) or die "Can't open directory: $!";
readdir(DIR);
close(DIR);
splice(@_,0,2); #remove . and ..
foreach(@_) {
  open(FILE, $fd/$_);
  while (<FILE>) {
    $_ =~ tr/KARMA1N3/N3V3RL4ND/g; # replace all KARMA1N3 with N3V3RL4ND
    print FILE $_;
  }
  close(FILE);
}

This was untested yet, but I'm pretty sure there is an error in my open
things.. I want to read and write the same file. Maybe I can slurp all
the file at once and then print every line

Etienne

Oh and there is a little question for you:

Mr.Foo: What's the age of your children Mr. Bar?

Mr.Bar: I have 3 children, the multiplication of their ages is 36.

Mr.Foo: This doesn't help very much.

Mr.Bar: Well if you add their 3 ages, you get the number fo windows in
my house.

Mr.Foo: I know how many windows there are in your house, but that
doesn't tell me the age of your children.

Mr.Bar: The oldest have blue eyes.

Mr.Bar: Ahhhh, now I know

Determine the ages of the 3 children of Mr.Bar

(Good luck:)

-- 
Etienne Marcotte
Specifications Management - Quality Control
Imperial Tobacco Ltd. - Montreal (Qc) Canada
514.932.6161 x.4001

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to