dear AnomalousMonk ;
thank you for your time. But it is not working in perl. I down know why? Shoudl i jusy replace my file name and i omitted the line for the $sol.because before that i read the variable from the text file and print it and it worked.any other point?
use strict;
use warnings;
die "usage: perl $0 file.name \n" unless @ARGV;;
my $filename_in = "topol1.top";
print "processing '$filename_in' \n";
my $filename_out = "$filename_in.new";
open my $fh_in, '<', $filename_in or die "opening '$filename_in': $!
+";
open my $fh_out, '>', $filename_out or die "opening '$filename_out': $
+!";
while (<$fh_in>) {
s{ (SOL) [^\n]* }{$1 $sol1}xmsg;
print $fh_out $_ or die "writing '$filename_out': $!";
}
close $fh_in or die "closing '$filename_in': $!";
close $fh_out or die "closing '$filename_out': $!";
rename $filename_in, "$filename_in.bak" or die "renaming '$filename_in
+': $!";
rename $filename_out, $filename_in or die "renaming '$filename_ou
+t': $!";
2017-08-16 Athanasius added code tags
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link or
or How to display code and escape characters
are good places to start.
|