Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
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


Comment on Re: Replacing a substring from a string in a file
Download Code

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 examining the Monastery: (7)
As of 2014-12-22 11:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (116 votes), past polls