Beefy Boxes and Bandwidth Generously Provided by pair Networks Cowboy Neal with Hat
laziness, impatience, and hubris
 
PerlMonks  

Re: Substitution replacement not terminated

by johngg (Abbot)
on Sep 24, 2013 at 13:50 UTC ( #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


Comment on Re: Substitution replacement not terminated
Select or Download Code
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
Node Status?
node history
Node Type: note [id://1055499]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (13)
As of 2014-04-18 22:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (472 votes), past polls