How to pass perl qw [] parameter?

I am setting up an open source Perl script for some db backup. I don't have much knowledge in Perl. Can someone tell me how to pass the qw[] parameter?

for example, the source code is as follows

 @selected_databases = qw[testdb1 testdb2 testdb3]; 

I want to convert it to something like below

 $_dblist = "testdb1 testdb2 testdb3"; @selected_databases = qw[$_dblist]; 

but it does not work. Can someone tell me how to pass a variable to qw []?

+4
source share
1 answer

qw does not support interpolation. According to perl-doc . So you cannot do this, it will not work. To achieve what you want to do, use the split function.

 $_dblist = "testdb1 testdb2 testdb3"; @selected = split(' ', $_dblist); 
+11
source

Source: https://habr.com/ru/post/1393301/


All Articles