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

I'm a mere mortal who's not much cop at Perl.

I'm trying to declare an array of people's names, but when I run my script, I get an error.

Possible attempt to put comments in qw() list at C:\bin\msdir.pl line +8. syntax error at C:\bin\msdir.pl line 8, near "my @technical_people = ( +"Elizabeth Adams", "Chris Millington", "Clerical", "E&D Group");
Now, this looks right to me, but clearly isn't - the only thing I can think of is that the & in the final item is causing interesting effects...

I humbly beg the assistance of the Monks.

Replies are listed 'Best First'.
Re: Array Silliness
by azatoth (Curate) on Feb 27, 2001 at 20:04 UTC
      Or better yet, use single (non-interpolating) quotes when you don't take advantage of interpolation. This will free you from the constraints of escaping characters within strings (except for ' itself, of course-- and \ as tye points out).

        Don't forget \, which must also be escaped inside of single quotes. You can be sloppy about this for cases when the \ is followed by something other than \ or your delimiter(s), but doing so usually gets you thinking that you don't need to quote \ which then leads to bugs that are hard to track down.

        BTW, & is not interpolated inside of double quotes.

                - tye (but my friends call me "Tye")
Re: Array Silliness
by pwhysall (Acolyte) on Feb 27, 2001 at 20:14 UTC
    Please vote this down and kill it.

    I am a fool who does not check his code sufficiently:

    Firstly, I missed a semicolon off the "use Win32..." bit, then I did this:

    use Win32::FileSecurity (qw Get Set EnumerateRights MakeMask); my @admin_people = ("Elizabeth Adams", "Chris Millington", "Clerical") +; my @technical_people = ("Elizabeth Adams", "Chris Millington", "Cleric +al", "E&D Group");
    Can you spot the foolish mistake?

    This throws an error which caused me some serious headscratching.

    Possible attempt to separate words with commas at C:\bin\msdir.pl line + 6. syntax error at C:\bin\msdir.pl line 6, near "my @technical_people = ( +"Elizabeth Adams", "Chris Millington", "Clerical", "E&D Group" (Might be a runaway multi-line GG string starting on line 4) Execution of C:\bin\msdir.pl aborted due to compilation errors.
    5000 Hail Larrys for me...
(tye)Re: Array Silliness
by tye (Sage) on Feb 27, 2001 at 20:09 UTC

    Sounds like before that line you have a qw() construct that you didn't close properly (though Perl is usually better at telling you that; I guess qw() is new enough that the error reporting isn't as good yet).

    Update: Ah, Perl does hint that this might be the problem, it is just that the noder left that part of the error message out.

            - tye (but my friends call me "Tye")