I want to replace word \"blue\" to \"red\" in all text files named as 1_classification.dat, 2_classification.dat and so on. I want to edit the same file so I tried this code
$_='~s/blue/red/g';
Uh, what??
Just
s/blue/red/g;
or, if you insist on using a variable (which is not necessary when using $_, but I just want to show the right syntax):
$_ =~ s/blue/red/g;