my $file = "Test_12354a-bc.doc";
my $search_value = "12354a";
my $replace_value = "replaced";
if($search_value =~ /\b$file\b/){
#True, replace $search_value found in $file with the $replace_value
$file = ?????;
#$file should now be equal to "Test_replaced-bc.doc"
}else{
#False, do nothing
}
Perl is a high-level, general-purpose, interpreted, dynamic programming languages with over 25 years of development. Perl 5 runs on over 100 platforms from portables to mainframes and is suitable for both rapid prototyping and large-scale development projects. Perl gained widespread popularity as a Common Gateway Interface (CGI) scripting language, in part due to its regular expression and string parsing abilities. In addition to CGI, Perl is used for graphics programming, system administration, network programming, finance, bioinformatics, and other applications.
TRUSTED BY
my $file = "Test_12354a-bc.doc";
my $search_value = "12354a";
my $replace_value = "replaced";
open INFILE, $file or die "$!";
my @lines = <INFILE>;
close INFILE;
foreach my $line (@lines)
{
$line =~ s/\b$search_value\b/$repla
}