in reply to How do I access an array in a Module?

Oh I want this ...
use constant EXTHDS => qw( "/media/disk" "/media/disk-1" "/media/disk-2" "/media/disk-3" "/media/disk-4" "/media/disk-5" );
instead of declaring the array @EXTHDS. I guess.

Replies are listed 'Best First'.
Re^2: How do I access an array in a Module?
by JadeNB (Chaplain) on Sep 13, 2008 at 21:22 UTC
    You almost surely do not want that. qw// splits its arguments on whitespace, so you will get an array whose 0th item is "/media/disk", not /media/disk. You can use qw// without the quotes, or drop qw// and insert commas to just construct a list directly, to get what you probably expect.

    UPDATE: On further thought, notice that constants are functions, not scalars or arrays (which is why you can't interpolate them). Thus, while you can probably export them using Exporter, it's a function (hence must be exported as a bareword, or with preceding &), not an array, that you'll be exporting. As others have mentioned, it's probably more straightforward just to make it a package variable (with our) so that you can export it directly.