[tpm] Using a variable in a 'qw()'

Jim Graham james.a.graham at gmail.com
Thu Jun 12 08:07:42 PDT 2008


Hi

Sorry about the garbage on my last email. Here's what i meant to say ..

From

 > perldoc perlop

...

          Customary  Generic        Meaning        Interpolates
              ''       q{}          Literal             no
              ""      qq{}          Literal             yes
              ``      qx{}          Command             yes*
                      qw{}         Word list            no
              //       m{}       Pattern match          yes*
                      qr{}          Pattern             yes*
                       s{}{}      Substitution          yes*
                      tr{}{}    Transliteration         no (but see  
below)
              <<EOF                 here?doc            yes*

              * unless the delimiter is ''.

...

The mnemonic q{} (single 'q' --> single quotes) qq{} (double 'q' -->  
double quotes) helps with remembering if interpolation is done.  
Unfortunately, that doesn't help with the qw{} construct that doesn't  
interpolate.

You'll have to use the ( $foo, "bar", "baz") construction.

- Jim

On 12-Jun-08, at 10:25 AM, Madison Kelly wrote:

> Hi all,
>
>   I want to use a variable when calling a module that uses the 'qw()'
> syntax. Specifically:
>
> use Net::DBus::Exporter qw(org.tle_bu.Clients);
>
>   I would like to be able to say:
>
> my $foo="org.tle_bu.Clients";
> use Net::DBus::Exporter qw($foo);
>
>   But '$foo' is passed in directly, rather than it's value. Is there  
> an
> alternative to 'qw()'? Honestly, I use that syntax all the time but  
> I've
> never really understood how it works. Perhaps I should be asking for a
> pointer to a doc that explains this syntax better?
>
> Thanks, as always!
>
> Madi
> _______________________________________________
> toronto-pm mailing list
> toronto-pm at pm.org
> http://mail.pm.org/mailman/listinfo/toronto-pm



More information about the toronto-pm mailing list