Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

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]
[Discipulus]: it hits some read timeouts but reconnect without issues
erix googles incerdibly and finds incredibly (translate is cleverder than I am)
[Discipulus]: found translate only good from or possibly to english.. in any other case i use double way translation

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (6)
As of 2018-06-19 07:32 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (111 votes). Check out past polls.