perl - Can't use string ("Server1") as a SCALAR ref while "strict refs" in use -


#!/usr/bin/perl -w use strict; use warnings;  use class::struct;  struct system => {   name => '$', };  $system = new system; $system->name("server1");  $strout1 = qq{server ${$system->name}\n}; $strout2 = "server \"".$system->name."\"\n";  print $strout1; print $strout2; 

results in:

can't use string ("server1") scalar ref while "strict refs" in use @ test.pl line 14.

i want able use qq , deref $system->name correctly. can explain going wrong?

method calls aren't interpolated in double quoted strings, dereferences are. if want interpolate result of method call, must dereference reference it:

my $strout1 = qq{server ${\$system->name}\n}; 

Comments

Popular posts from this blog

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

android - How to create dynamically Fragment pager adapter -

1111. appearing after print sequence - php -