Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: How to get string from array from module?

by Gilu (Initiate)
on Feb 09, 2018 at 09:14 UTC ( [id://1208789]=note: print w/replies, xml ) Need Help??


in reply to How to get string from array from module?

Ok! Thanks for your help, guys! I think I got it. I changed the line in ColorScheme.pm to:
our @COLORMAGENTA = (0.82745,0.21176,0.50980); @SELECTED_COLOR = @COLORMAGENTA;

and "fetched" this data in 3DScene.pm like this:
my $SELECTED_COLOR; $SELECTED_COLOR =\@SELECTED_COLOR;
And then I was able to retrieve my colors like that:
glColor4f( $SELECTED_COLOR->[0],$SELECTED_COLOR->[1],$SELECTED_COLOR->[2] , $volume->color->[3]);
It works but I'm not sure if this is the correct way?!

Replies are listed 'Best First'.
Re^2: How to get string from array from module?
by hippo (Bishop) on Feb 09, 2018 at 09:59 UTC

    I don't see the point of turning @SELECTED_COLOR into a reference and then back again. Why not simply do this:

    ### NOT NEEDED my $SELECTED_COLOR; ### NOT NEEDED $SELECTED_COLOR =\@SELECTED_COLOR; glColor4f (@SELECTED_COLOR, $volume->color->[3]);
      Well ... if that was your second day with Perl; everything seems so ... you know! :-) You're absolutely correct - of course! Thanks for the hint!

        Sorry - didn't mean it to sound critical. As the post I replied to just showed some lines in isolation it could well have been the case that there was some benefit to using the reference which we might not have known of. I could (as usual) have phrased it better.

        And if it is only your second day and you are handling stuff like this so well then you will go a long, long way.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1208789]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (6)
As of 2024-03-28 19:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found