Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Replacing a substring from a string in a file

by vivid (Beadle)
on Dec 11, 2007 at 04:52 UTC ( #656312=note: print w/ replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://656312]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (13)
As of 2016-06-29 08:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My preferred method of making French fries (chips) is in a ...











    Results (372 votes). Check out past polls.