Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Changing string in specific line/position in a file

by tybalt89 (Monsignor)
on Jun 10, 2024 at 15:20 UTC ( [id://11159882]=note: print w/replies, xml ) Need Help??


in reply to Changing string in specific line/position in a file

Here's one way to go to the specified location in each chunk. (NOTE: fetching and replacement are done to end-of-line, since one field is short.)

#!/usr/bin/perl use strict; # https://perlmonks.org/?node_id=11147864 use warnings; @ARGV = 'd.11147864'; # FIXME for testing only, comment out for real l +ife local $/ = "\f"; while( <> ) { if( /^ (?:.*\n){13} .{24} (.+)/x ) # line 14 col 25 grab rest of tex +t { my $replacement = $1; # maybe more calculations here s/^ (?:.*\n){9} .{24} \K .+/$replacement/x; # line 10 col 25 repla +ce rest } print; }

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (4)
As of 2026-04-15 00:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.