I am customizing an open source Perl script for some db backup. I don't have much knowledge in Perl. Can someone tell me how will i pass a parameter to qw[]
?
for example the original code is like this
@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 is not working. Can someone tell me how will I pass a variable to qw[]?
qw
does not support interpolation. As per the perl-doc. As such, you cannot do that, it will not work. To achieve what you are looking to do, use the split
function.
$_dblist = "testdb1 testdb2 testdb3";
@selected = split(' ', $_dblist);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With