I am trying to parse the below text file (test.txt) using Perl script to get output format mentioned at bottom (bugid, description and username). Can you help me achieve it?
Data in test.txt
(1111) user1 <[email protected]> 112111: description1 - some dummy string
(6473) user2 <[email protected]> 112112: description2 - some test string
(1999) user3 <[email protected]> 129119: description3 - some tes3 string
(3975) user3 <[email protected]> 196234: description4 - some tes4 string
Here's the script that I am trying.
#!perl -w
#use strict;
no warnings;
my $ActivityLog = "test.txt";
my $ActListLog = "test3.txt";
open(FILE, "<$ActivityLog");
@prelist = <FILE>;
close (FILE);
foreach (@prelist)
{
if ($_ !~ /Bring over:/)
{
@postlist = split(".com> ", $_);
push (@result, $postlist[1]);
}
}
unlink $ActListLog;
open(LISTNAME,">$ActListLog")||die("cannot open the Input file");
print LISTNAME @result;
close LISTNAME;
Required Output:
112111: description1 user1
112112: description2 user2
129119: description3 user3
196234: description4 user3
#use strict;andno warnings;means you are telling the interpreter not to help you at all.