CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

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: 4535
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

Code
   #!/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


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives