http://www.perlmonks.org?node_id=721631


in reply to Re^2: Chart::Gnuplot and Windows XP
in thread Chart::Gnuplot and Windows XP

I suspect, but am not in a position to confirm just now, that the problem is this forward slash:

\tmp\NTEVfipQVM/plot ................^

And that if you modified Chart::Gnuplot something along the lines of:

sub new { my ($class, %hash) = @_; # Create temporary file to store Gnuplot instructions if (!defined $hash{_multiplot}) # if not in multiplot mode { my $dirTmp = tempdir(CLEANUP => 1, DIR => '/tmp'); ########### change here $hash{_script} = $^O eq 'MSWin32' ? "$dirTmp\plot" : "$dirTmp/ +plot";

Then it might work.

Of course, there are probably other places (like the line above) that might need similar treatment--and there are certainly better ways (File::Spec and friends) of making the path handling properly cross-platform--, but a few simple changes like this might allow you to get on with your work.

And if you fed what changes you need, back to the module author, they might be able to integrate them back into the next release.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Replies are listed 'Best First'.
Re^4: Chart::Gnuplot and Windows XP
by dHarry (Abbot) on Nov 05, 2008 at 15:09 UTC

    You're right BrowserUK.

    I have upgraded to version 005 of GnuPlot and it is corrected in that version. However the error message still remains. I suspect it’s the _thaw method. Reading the TODO for the sub the author is well aware of the problem. I changed CLEANUP => 1 into => 0 and the created plot file looks correct to me. The argument created for gnuplot is still flawed, e.g. \tmp\L9LpBMXAW0/plot. I will dig a little deeper.

    Update
    Fixed typo

      The argument created for gnuplot is still flawed, e.g. \tmp\L9LpBMXAW0/plot . I will dig a little deeper.

      There are quite a few places that require modification. This diff isn't meant to be suitable as a patch, just an indicator of where thing need changes and what might be suitable.

      For example, I have both TMP and TEMP environment variables set on my system, but I've long since forgotten whether I set up the former or whether it is set by default. I also have no idea is either is available on typical *nix systems.

      And as I said earlier, to do the job right you'd have to get into moving the duplicate code into separate subroutines and using File::* modules in order to make properly cross-platform. But again, I don't know enough about these requirements to suggest anything beyond how to make it work on Win32.

      Anyway, this might help you get something going. Good luck.

      --- \perl\site\lib\Chart\Gnuplot.pm Wed Nov 05 15:21:26 2008 +++ Gnuplot.pm Wed Nov 05 15:33:43 2008 @@ -15,8 +15,11 @@ # Create temporary file to store Gnuplot instructions if (!defined $hash{_multiplot}) # if not in multiplot mode { - my $dirTmp = tempdir(CLEANUP => 1, DIR => '/tmp'); - $hash{_script} = "$dirTmp/plot"; +# my $dirTmp = tempdir(CLEANUP => 1, DIR => '/tmp'); + my $dirTmp = tempdir(CLEANUP => 1, DIR => $ENV{TMP} || $ENV{T +EMP} ); +# $hash{_script} = "$dirTmp/plot"; + $hash{_script} = $^O eq 'MSWin32' ? "$dirTmp\\plot" : "$dirTm +p/plot"; + } # Default terminal: postscript terminal with color drawing elemen +ts @@ -819,7 +822,8 @@ { my ($self) = @_; - my $pltTmp = "$self->{_script}/plot"; +# my $pltTmp = "$self->{_script}/plot"; + my $pltTmp = $^O eq 'MSWin32' ? "$self->{_script}\\plot" : "$self +->{_script}/plot" open(PLT, ">$pltTmp") || confess("Can't write gnuplot script $plt +Tmp"); print PLT "set terminal $self->{terminal}\n"; print PLT "set output \"$self->{output}\"\n"; @@ -1002,8 +1006,10 @@ my $ydata = $self->{ydata}; # Create temporary file to store Perl data - my $dirTmp = tempdir(CLEANUP => 1, DIR => '/tmp'); - my $fileTmp = "$dirTmp/data"; +# my $dirTmp = tempdir(CLEANUP => 1, DIR => '/tmp'); + my $dirTmp = tempdir(CLEANUP => 1, DIR => $ENV{TMP} || $ENV{T +EMP} ); +# my $fileTmp = "$dirTmp/data"; + my $fileTmp = $^O eq 'MSWin32' ? "$self->{_script}\\data" : " +$dirTmp/data"; open(DATA, ">$fileTmp") || confess("Can't write data to temp +file"); # Process 3D data set @@ -1215,8 +1221,10 @@ { my $pt = $self->{points}; - my $dirTmp = tempdir(CLEANUP => 1, DIR => '/tmp'); - my $fileTmp = "$dirTmp/data"; +# my $dirTmp = tempdir(CLEANUP => 1, DIR => '/tmp'); + my $dirTmp = tempdir(CLEANUP => 1, DIR => $ENV{TMP} || $ENV{T +EMP} ); +# my $fileTmp = "$dirTmp/data"; + my $fileTmp = $^O eq 'MSWin32' ? "$self->{_script}\\data" : " +$dirTmp/data"; open(DATA, ">$fileTmp") || confess("Can't write data to temp +file"); # 2D data points

      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.