bichonfrise74 has asked for the wisdom of the Perl Monks concerning the following question:

I have a simple quote problem and just couldn't find the solution. Currently, I have this line which is fine but I want to put quotes so that if ever I want to add new elements, I don't need to put the quotes anymore.
my %list = ( 'test' => [ 'aa', 'bb' ]) );
What I'm hoping is something like this which doesn't work.
my %list = ( 'test' => q([ aa bb ]) ); my %list = ( 'test' => q[ aa bb ] );
Any ideas? I'm sure it is simple, I just couldn't figure it out.

Replies are listed 'Best First'.
Re: Quotes in Hashes of Array
by toolic (Bishop) on Jul 16, 2009 at 00:20 UTC
    I think you are looking for qw:
    my %list = ( 'test' => [ qw(aa bb) ] );
Re: Quotes in Hashes of Array
by LanX (Saint) on Jul 16, 2009 at 00:29 UTC
    ehm I'm not sure, but do you mean this?
    DB<1> %list = ( test => [ qw#aa bb# ] ) DB<2> p $list{test}[0] aa DB<3> x %list 0 'test' 1 ARRAY(0x86fe158) 0 'aa' 1 'bb'

    Cheers Rolf

    UPDATE: It really sucks that the perldebugger can't handle lexicals...

    ... seems that every line is evaled seperately such that the scope ends with the line.

    ... took me a wile to understand why

    DB<1> my %list = ( test => [ qw#aa bb# ] )
    has no effect!
Re: Quotes in Hashes of Array
by bichonfrise74 (Vicar) on Jul 16, 2009 at 00:31 UTC
    Yup! That's it!! Thanks!