Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Substitution replacement not terminated

by johngg (Canon)
on Sep 24, 2013 at 13:50 UTC ( [id://1055499]=note: print w/replies, xml ) Need Help??


in reply to Substitution replacement not terminated

You can supply the -p and -i flags within the script itself. Given that your offsets are fixed, you might find that substr is better suited. It is important to insert at your offsets working from the right.

$ cat > spw1055482.txt aaaaaGGGGGG55555 fffffJJJJJJ11111 kkkkkUUUUUU99999 $ head -99 spw1055482.* aaaaaGGGGGG55555 fffffJJJJJJ11111 kkkkkUUUUUU99999 $ cat > spw1055482 #!/usr/bin/perl -npi.bak # use strict; use warnings; for my $offset ( 11, 5 ) { substr $_, $offset, 0, q{^}; } $ perl spw1055482 spw1055482.txt $ head -99 spw1055482* ==> spw1055482 <== #!/usr/bin/perl -npi.bak # use strict; use warnings; for my $offset ( 11, 5 ) { substr $_, $offset, 0, q{^}; } ==> spw1055482.txt <== aaaaa^GGGGGG^55555 fffff^JJJJJJ^11111 kkkkk^UUUUUU^99999 ==> spw1055482.txt.bak <== aaaaaGGGGGG55555 fffffJJJJJJ11111 kkkkkUUUUUU99999 $

I hope this is helpful.

Cheers,

JohnGG

Replies are listed 'Best First'.
Re^2: Substitution replacement not terminated
by shan_emails (Beadle) on Sep 25, 2013 at 07:14 UTC

    Greate, Thanks for your help John.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (2)
As of 2024-04-24 17:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found