Hope this helps. -Eric#!/usr/bin/perl -w use strict; my $last_line; my $i; my $num_lines; open(FILE, "<test.txt") || die "Unable to open file: $!"; chomp(my @lines = <FILE>); # get the lines close(FILE); $num_lines = @lines; for($i=0; $i < $num_lines; $i++) { if($i == $num_lines-1) { # make sure we don't access # uninitialized index of array print "$lines[$i]\n"; # print the last line } elsif($lines[$i+1] =~ m/\+/) { # look ahead $lines[$i+1] =~ s/^\+//; print "$lines[$i] $lines[++$i]\n"; } else{ print "$lines[$i]\n"; } }
In reply to Re: Look ahead and join if the line begins with a +
by emilford
in thread Look ahead and join if the line begins with a +
by Rhodium
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |