biancoari has asked for the wisdom of the Perl Monks concerning the following question:
Hi everyone, I have this code that makes some changes from a file to the content of it, is there a way to modify that file so the output is printed on a new file, instead of printing the output on the screen.
Here is the code I have:
#!/usr/local/bin/perl open my $FILE, '<', 'rapipago.txt' or die "Cannot open file1.txt: $!"; use strict; use warnings; use feature 'say'; while (my $text = <$FILE>) { chomp $text; my @cums = (0); my @offs = ( 17, 6, 31, 3, 3 ); my @cums = ( 0 ); push @cums, $_ + $cums[ -1 ] for @offs; substr $text, $_, 0, q{-} for reverse @cums[ 1 .. $#cums ]; say $text; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How to modify a file
by Random_Walk (Prior) on Apr 25, 2013 at 13:42 UTC | |
by static0verdrive (Initiate) on Apr 25, 2013 at 13:58 UTC | |
by biancoari (Initiate) on Apr 25, 2013 at 17:05 UTC | |
by poj (Abbot) on Apr 25, 2013 at 18:06 UTC | |
|
Re: How to modify a file
by BillKSmith (Monsignor) on Apr 25, 2013 at 14:28 UTC |