Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

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.



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?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1055499]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (2)
As of 2017-03-29 22:57 GMT
Find Nodes?
    Voting Booth?
    Should Pluto Get Its Planethood Back?

    Results (353 votes). Check out past polls.