0

I'm not too sure why, but I keep getting a syntax error with the following: near ") :"

my %temp =  map { /(\S+)\:x\:(\S+)\:(\S+)/ ? ($1 => $2) : (); 
                  ($1.'members' => $3) : ()
                } @output;

Ideally what I want to do, is assign $1 to $2, and then $1.'members' to $3. It seems ok to me, but I can't figure out what the issue is.

Any help is much appreciated!

1 Answer 1

4

Forget the map for a moment, and just look at this code:

/(\S+)\:x\:(\S+)\:(\S+)/ ? ($1 => $2) : (); 
($1.'members' => $3) : ();

What's that supposed to mean? This line in particular is a syntax error:

($1.'members' => $3) : ();

I think you want:

/(\S+)\:x\:(\S+)\:(\S+)/
   ? ($1 => $2, $1.'members' => $3)
   : ();

Adding back in the map:

my %temp = map {
               /(\S+)\:x\:(\S+)\:(\S+)/
                   ? ($1 => $2, $1.'members' => $3)
                   : ();
           } @output;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.