From 410b97cde5d790e39f5e070304fc6a46bd76917c Mon Sep 17 00:00:00 2001 From: Dan Buch Date: Thu, 6 Jan 2011 22:44:53 -0500 Subject: [PATCH] printing lines from file separated by | --- cli/exercise_02/input_fromfile.pl | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cli/exercise_02/input_fromfile.pl b/cli/exercise_02/input_fromfile.pl index ebbe854..ee227fc 100644 --- a/cli/exercise_02/input_fromfile.pl +++ b/cli/exercise_02/input_fromfile.pl @@ -18,7 +18,13 @@ if (!defined $ARGV[0]) { my $infile = $ARGV[0]; open(DAT, $infile) or die "$infile: $!"; -print ; +my @cleaned = (); +foreach my $line () { + $line =~ s/\s*$//; + $cleaned[++$#cleaned] = $line; +} + +print join("|", @cleaned) . "\n"; close(DAT);