Gilu has asked for the wisdom of the Perl Monks concerning the following question:
So, I got this module:
And in another file, I need to get STRING of @SELECTED_COLOR. So I've done this so far:package Slic3r::GUI::ColorScheme; use strict; use warnings; use Exporter; our @ISA = 'Exporter'; our @EXPORT = qw(@SELECTED_COLOR @b); our (@SELECTED_COLOR); our @COLOR_MAGENTA = [0.82745,0.21176,0.50980]; # This is an array, ye +s?! our $COLORMAGENTA = [0.82745,0.21176,0.50980]; # only for testing sub getMODColorScheme { print "-----> getColorScheme from MODULE\n"; print "from dollar: @{ $COLORMAGENTA } \n"; # 0.82745 0.21176 0.5 +098 print "from at : @COLOR_MAGENTA \n"; # ARRAY(0x59d88f8) -> + this needs to be 0.82745 0.21176 0.5098 if ($Slic3r::GUI::Settings->{_}{colorschema_solarized}) { print "Using S O L A R I Z E from Slic3r::GUI::ColorScheme\n" +; @SELECTED_COLOR = @COLOR_MAGENTA; } else { @SELECTED_COLOR = [0,1,0]; } } 1;
Somehow I get ARRAY(0x59d88f8) back from @SELECTED_COLOR. If I use $COLORMAGENTA in 3dscene.pm (as this: glColor4f(@{ $COLORMAGENTA }, $volume->color->[3]);), then I get the expected output (0.82745 0.21176 0.5098). How can I get 0.82745 0.21176 0.5098 from @SELECTED_COLOR? Any help is appreciated. Thanks. This is my first PERL question/experience ever; please be gentle.# 3dscene.pm use Slic3r::GUI::ColorScheme; sub new { my ($class, $parent) = @_; Slic3r::GUI::ColorScheme::getMODColorScheme(); glColor4f( @SELECTED_COLOR , $volume->color->[3]); # this should b +e like: glColor4f(0.82745,0.21176,0.50980, 1); # glColor4f(@{ @SELECTED_COLOR }, $volume->color->[3]); # this doe +s not work at all! # ERROR from line above: Can't use string ("1") as an ARRAY ref wh +ile "strict refs" in use }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: How to get string from array from module?
by hippo (Bishop) on Feb 08, 2018 at 14:45 UTC | |
Re: How to get string from array from module?
by Laurent_R (Canon) on Feb 08, 2018 at 22:15 UTC | |
Re: How to get string from array from module?
by Gilu (Initiate) on Feb 09, 2018 at 09:14 UTC | |
by hippo (Bishop) on Feb 09, 2018 at 09:59 UTC | |
by Gilu (Initiate) on Feb 09, 2018 at 13:28 UTC | |
by hippo (Bishop) on Feb 09, 2018 at 13:48 UTC |
Back to
Seekers of Perl Wisdom