sar123 has asked for the wisdom of the Perl Monks concerning the following question:
I am trying to remove all the "+"signs and add the lines together to get output of the following type:xabcd a1 +b1 +b2 +b3 +b4 +b5 abcd xcdef c1 +d1 +d2 +d3 +d4 +cdef
Here is my code for this:xabcd a1b1b2b3b4b5 abcd xcdef c1d1d2d3d4cdef
But this gives the output same as the input file. What is wrong with code?#!/usr/bin/perl use warnings; use strict; use diagnostics; open my $fh, "<", "$ARGV[0]" or die "Could not open $!"; my @file = <$fh>; $/ = "\n+"; chomp (@file); print "@file\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Chomp in perl
by Athanasius (Archbishop) on Oct 05, 2014 at 06:12 UTC | |
by sar123 (Novice) on Oct 05, 2014 at 06:17 UTC | |
|
Re: Chomp in perl
by rnaeye (Friar) on Oct 05, 2014 at 16:23 UTC | |
by rnaeye (Friar) on Oct 05, 2014 at 16:25 UTC |