Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

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


In reply to Re: sed command with variable in perl by samira_saber
in thread sed command with variable in perl by samira_saber

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • 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.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (4)
As of 2022-05-17 18:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (68 votes). Check out past polls.

    Notices?