 |
|
Home:
Perl Programming Help:
Beginner:
Re: [BillKSmith] Parsing a text file and outputting to an excel sheet:
Edit Log
|
|

Jeff29
Novice
Oct 8, 2010, 11:55 AM
Views: 3534
|
|
Re: [BillKSmith] Parsing a text file and outputting to an excel sheet
|
|
|
HI Bill, Tried the following,I fail to understand on how to extract the perforcepath: when there is an ERROR: .Please help
#!/usr/bin/perl -w use strict; use Spreadsheet::WriteExcel; my $match; my $workbook = Spreadsheet::WriteExcel->new("Tech_BlacklistedCRs.xls"); my $worksheet = $workbook->addworksheet(); my $cr_line = ''; open my $line, '<', 'File.txt' or die 'Cannot open file'; while (my $match = <$line1>) { if ($match =~ /CR:/){ $cr_line = $match; #print $cr_line; } elsif ($match =~ /Error:/){ if ($match =~ /Perforce path:/) { #print $cr_line, $match; $worksheet->write($i, 0, $cr_line); $worksheet->write($i, 1 , $match); $cr_line = ''; $i++; #$j++; } } $workbook->close();
(This post was edited by Jeff29 on Oct 8, 2010, 2:21 PM)
|
|
|
Edit Log:
|
|
Post edited by Jeff29
(Novice) on Oct 8, 2010, 11:56 AM
|
|
Post edited by Jeff29
(Novice) on Oct 8, 2010, 11:59 AM
|
|
Post edited by Jeff29
(Novice) on Oct 8, 2010, 2:20 PM
|
|
Post edited by Jeff29
(Novice) on Oct 8, 2010, 2:21 PM
|
|
|  |