The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



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

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rating: Thread Rating: 1 votes, 4.00 average. Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 10-14-2008
pietie pietie is offline
Registered User
  
 

Join Date: Oct 2008
Location: C:/dos/run
Posts: 5
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
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 10:20 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0