in reply to Replacing a substring from a string in a file
Hi, try this,
use strict; my $arg = $ARGV[0]; open(IN,"$arg")||die("Can't open the input file for reading"); undef $/; my $str = <IN>; close(IN); $str=~s#\$[^\$]+\$#&LimitReplace($&)#gei; open(OUT,">$arg")||die("Can't open the output file for writing"); print OUT $str; close(OUT); sub LimitReplace{ my ($line)=@_; $line=~s#\\limits##gi; return($line); }
Vivid
|
|---|