![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Error executing shell command from a perl script | voorkey | Shell Programming and Scripting | 5 | 03-30-2009 08:48 AM |
| [Perl] Accessing array elements within a sed command in Perl script | userix | Shell Programming and Scripting | 2 | 10-03-2008 01:05 PM |
| Perl Script Error with find command | MKNENI | Shell Programming and Scripting | 4 | 03-26-2008 12:02 PM |
| String replace perl script error | MobileUser | Shell Programming and Scripting | 6 | 05-04-2006 10:18 PM |
| Perl: Run perl script in the current process | vino | Shell Programming and Scripting | 10 | 12-09-2005 10:45 AM |
|
|
LinkBack | Thread Tools | Search this Thread |
Rating:
|
Display Modes |
|
||||
|
Perl script error
Hi all I keep getting a segmentation fault error while running the script below. Code:
#!/usr/bin/perl -w
use CGI ':standard';
use GD::Graph::pie;
use strict;
use warnings;
sub trim($)
{
my $string = shift;
$string =~ s/^\s+//;
$string =~ s/\s+$//;
return $string;
}
my ($ts, $filename, @array, $line, $arri , $k , $total);
open(DOMAINS, "< /mailstats/temp/domains.tmp") || die "Couldn't open. Please check permissions. \n";
$k = 0;
$total = 0;
while ($line = <DOMAINS>) {
$line = trim($line);
#chomp $line; # removes the carriage return
#@array = split(/ / , $line); # breaks the line up into fields
($array[1][$k], $array[0][$k], undef) = split(" ", $line);
$total = $total + $array[1][$k];
#print $array[0][$k] , "\
print $total , "\n";
my $mygraph = GD::Graph::pie->new(300, 300);
$mygraph->set(
title => 'Grading Policy for COP5555 course',
'3d' => 0,
) or warn $mygraph->error;
$mygraph->set_value_font(GD::gdMediumBoldFont);
my $myimage = $mygraph->plot(\@array) or die $mygraph->error;
#print "Content-type: image/png\n\n";
open(PICTURE, ">filesplittest.png") or die("Cannot open file for writing");
binmode PICTURE;
print PICTURE $myimage->png;
close PICTURE;
t" , $array[1][$k] , "\n";
## NOW PROCESS EACH LINE HERE
$k = $k + 1;
}
close DOMAINS;
now when I comment out the whole graph drawing block, I don't get a segmentation fault. The data I am using is a lot of data. Can that be the issue? If the data is the problem, is there any way I can optimize it? I have tried inputting less data intro the text file, and it worked. Regards Last edited by otheus; 10-14-2008 at 12:54 PM.. Reason: I think down-thumb is not going to help ge this answered. |
| Bookmarks |
| Tags |
| awk, awk trim, perl, perl shift, shift, shift perl, trim, trim awk |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|