INPUT FILE (input.txt)#!/usr/bin/perl use strict; use warnings; my $data = 'input.txt'; my $placeholder = ''; unless(open(INPUT, $data)) { die "Can't open input file $data\n"; } # Print heading print "Product Release product Type color basic color all ov +erseas shipping\n"; while(my $line = <INPUT>) { if($line =~ m/Release Date(\d+)\/(\d+)\/(\d+)/) { print "$line"; } } close INPUT;
RESULTSRelease Date2/2/2019 product clock1(analog) color basic white color all white,black,silver warranty 1 year not sold yet Release Date2/2/2020 product none Release Date2/2/2021 product clock1(digital) color basic black color all black,silver warranty 1 year not sold yet Release Date2/2/2022 product clock2(digital) color basic white color all white overseas shipping yes shipping charges yes warranty 1 year not sold yet
DESIRED RESULTS$ ./generate.pl Product Release product Type color basic color all overseas +shipping Release Date2/2/2019 Release Date2/2/2020 Release Date2/2/2021 Release Date2/2/2022 $
Product Release product Type color basic color all + overseas shipping Release Date2/2/2019 analog white white,black,silve +r N/A Release Date2/2/2020 none N/A N/A + N/A Release Date2/2/2021 digital black black,silver + N/A Release Date2/2/2022 digital white white + yes
In reply to process multiline text and print in desired format by ak_mmx
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |