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

Re: Replace and substitur in same file

by thanos1983 (Parson)
on Jun 21, 2017 at 12:00 UTC ( [id://1193207]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    #!usr/bin/perl
    use strict;
    ...
    # write your new data on empty file
    # close file
    # done :D
    
  2. or download this
    An older style is to use a bareword as the filehandle, as
    
    ...
           or die "Can't open < input.txt: $!";
    
    Then you can use FH as the filehandle, in close FH and <FH> and so on.
    + Note that it's a global variable, so this form is not recommended in
    + new code.
    
  3. or download this
    It is global to all the script you write so if anyone uses the same na
    +me (IN or OUT in our example) those will clash with yours.
    
    It is also harder to pass these variables to functions, than to do the
    + same with regular scalar variables.
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (3)
As of 2024-06-24 16:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.