[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

syntax error in perl

Posted on 2004-10-27
3
Medium Priority
?
304 Views
Last Modified: 2010-03-05
hi..
i have two perl code that create .csv files and the other create .txt file.
How to create both by conbining these 2 sets of codes up?
Keep getting syntax error when i tried tt..


CREATE .csv files
my($csv) = Text::CSV->new;
open( CSV, ">$file.csv") || die "Failed for $file.csv: $!\n";

# Write Header
$csv->combine( qw/Qin Qout Yield Reject/);
print CSV $csv->string . "\n";

# Write data using foreach or some other loop.
  $csv->combine( @{$t} );
  print CSV $csv->string . "\n";

close( CSV );
__________________________________________________________________________________

CREATE text files
die "$file already exists\n" if -f $file;
open FILE, ">$file" or die "Can not create $file $!\n";

#print the sums at the top of the file, separated by tabs
print FILE "Daily Yield Report Summary\n";
print FILE "Device: '$dev'\n";
print FILE "Date: '$datef' to '$datet'\n\n";
print FILE "Date\t\t", "Qin\t", "Qout\t", "Yield\t", "Reject\t", "Lot\n";
foreach my $r(@$d) {
print FILE join("\t", @$r), $/;}

#write the other arrays in tab-separated columns underneath the sums
 print FILE  "-"x60, $/;
 print FILE "Total\t\t", join("\t", @$t), $/;

# Graph
print FILE $graph->to_string( [("\t", @$t), $/],
                           labels => [ qw/, ,Qin, Qout, Yield, Reject/ ],
                         );
close(FILE);
0
Comment
Question by:TPoly
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 48

Expert Comment

by:Tintin
ID: 12429955
There's not enough info to go on.

You can quite easily combine the two code snippets, but without seeing what's wrapped around them and what the syntax error you got, it's not possible to help.
0
 

Author Comment

by:TPoly
ID: 12430121
error msg:
Unmatched right curly bracket at graphtxtcvs.tk line 28, at end of line
  (Might be a runaway multi-line "" string starting on line 20)
syntax error at graphtxtcvs.tk line 28, near "}"
Execution of graphtxtcvs.tk aborted due to compilation errors.

the codes:

        $ca->createImage(5,2,
        -anchor =>'nw',
        -image => image1);

        $ca->pack(-side=>'top');


        $text =
$fr2->ROText('-width'=>85,'-height'=>30,
        -font=>['time new roman','10'],-background=>'white')->pack(-side=>'bottom');


        my $scr2 = $fr2->Scrollbar(-command =>['yview',$text]);
       
$text->configure(-yscrollcommand=>['set',$scr2]);
        $text->pack(-side => 'left', -fill =>'both');
        $scr2->pack(-side => 'right', -fill => 'y');

        $text->insert('1.0',"This program is licensed
to Agilent Technologies Singapore (HSIO)\n
search.tk is created by Dawn Lee and Joyce Khoo,
Diploma in Info-Communications(IFC)\n
This program allows the user to search the directory
for 'Yield Report', 'Tray Report'
and 'Packagae Report'\n
Copyright(c) 2004 Temasek Polytechnic\n" );
        }

sub condition1()
{

#Get entry
        $devf=$f->get('active');
        $dev=$d->get('active');
        $datef=$entry2->get;
        $datet=$entry3->get;
        $file=$entry->get;
      $year=$entry4->get;

if ($devf eq "" && $year eq ""){

#connect to the database
my $dbh = DBI->connect('dbi:mysql:rvsi','','', {RaiseError=>1, PrintError=>1});

# Extract the data from database
my $d = $dbh->selectall_arrayref("SELECT date, qin, qout,yield, reject, lot FROM yield WHERE date BETWEEN '$datef' AND '$datet'");
    print ("Daily Yield Report Summary for '$dev' between '$datef' to '$datet'\n\n");
    print ("Date\t\t", "Qin\t", "Qout\t", "Yield\t", "Reject\t", "Lot\n");

# Print out all the array catch  
foreach my $r(@$d) {
    print join("\t", @$r), $/;
}

#print the dotted line
print "-"x60, $/;

#Do the calculation
my $t = $dbh->selectrow_arrayref("SELECT sum(qin), sum(qout), ((sum(qout)/sum(qin))*100), sum(reject) FROM yield WHERE date BETWEEN '$datef' AND '$datet'");
print "Total\t\t", join("\t", @$t), $/;

#Create Graph
my $graph = Text::Graph->new( 'Bar' );
  print $graph->to_string( [("\t", @$t), $/],

                           labels => [ qw/, ,Qin, Qout, Yield, Reject/ ],
                         );

my($csv) = Text::CSV->new;
open( CSV, ">$file.csv") || die "Failed for $file.csv: $!\n";

# Write Header
$csv->combine( qw/Qin Qout Yield Reject/);
print CSV $csv->string . "\n";

# Write data using foreach or some other loop.
  $csv->combine( @{$t} );
  print CSV $csv->string . "\n";

close( CSV );


die "$file already exists\n" if -f $file;
open FILE, ">$file" or die "Can not create $file $!\n";

#print the sums at the top of the file, separated by tabs
print FILE "Daily Yield Report Summary\n";
print FILE "Device: '$dev'\n";
print FILE "Date: '$datef' to '$datet'\n\n";
print FILE "Date\t\t", "Qin\t", "Qout\t", "Yield\t", "Reject\t", "Lot\n";
foreach my $r(@$d) {
print FILE join("\t", @$r), $/;}

#write the other arrays in tab-separated columns underneath the sums
 print FILE  "-"x60, $/;
 print FILE "Total\t\t", join("\t", @$t), $/;

# Graph
print FILE $graph->to_string( [("\t", @$t), $/],
                           labels => [ qw/, ,Qin, Qout, Yield, Reject/ ],
                         );

close(FILE);
}
}




0
 
LVL 84

Accepted Solution

by:
ozo earned 450 total points
ID: 12430284
       $text->insert('1.0',"This program is licensed
to Agilent Technologies Singapore (HSIO)\n
search.tk is created by Dawn Lee and Joyce Khoo,
Diploma in Info-Communications(IFC)\n
This program allows the user to search the directory
for 'Yield Report', 'Tray Report'
and 'Packagae Report'\n
Copyright(c) 2004 Temasek Polytechnic\n" );
        }
This  ^   right bracket has no corresponding left bracket.
The beginning of the file seems to be missing something.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question