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

GOAL:- I am trying to ready the keyvalues of the hash dashboard_branches and depending on the value am assigning the RLTAGURL but running into compilation error..can anyone provide guidance on what is wrong?

foreach my ${branch} (sort keys %dashboard_branches) { print "BRANCH: ${branch}"; if (${branch} =~ /^TAG_WCONNECT_BT/) { my $RLTAGRL = "http://qwiki.company.com/qca_CNNss/CNN-BT-FM +/BT_TAG_Releases"; } elsif (${branch} =~ /^TAG_BTHOST/) { my $RLTAGRL = "http://qwiki.company.com/qca_CNNss/CNN-BT-FM +/BT_TAG_Releases"; } elsif (${branch} =~/^TAG_WCONNECT_NFC/) { my $RLTAGRL = "http://qwiki.company.com/qca_CNNss/CNN-BT-FM +/NFC_TAG_Releases"; "create_dashboard.pl" 217L, 6996C written
<user:/local/mnt/workspace/user/Automation/swbuild/bin/dashboard>perl +create_dashboard.pl Global symbol "$RLTAGRL" requires explicit package name at create_dash +board.pl line 201. Execution of create_dashboard.pl aborted due to compilation errors.
  • Comment on Global symbol "$RLTAGRL" requires explicit package name at create_dashboard.pl line 201.
  • Select or Download Code

Replies are listed 'Best First'.
Re: Global symbol "$RLTAGRL" requires explicit package name at create_dashboard.pl line 201.
by Corion (Patriarch) on Jan 19, 2014 at 19:38 UTC

    Most likely the error does not occur on line 201 (whichever that is), but on another line in the elsif blocks.

    Also, your assignments to $RLTAGRL make very little sense as the value assigned to the lexical variables named $RLTAGRL will disappear as soon as the block in which $RLTAGRL is declared is left.

    What is the larger issue you are trying to address here? Blindly adding my in front of variable names rarely helps.

Re: Global symbol "$RLTAGRL" requires explicit package name at create_dashboard.pl line 201.
by LanX (Saint) on Jan 19, 2014 at 19:35 UTC
    The code as shown doesn't emit errors, but doesn't make sense.

    Declare your variable with my in the scope where you wanna also read it.

    Consequently avoid my within the if - else branches otherwise your var won't exist outside.

    Have a look at coping with scoping for details.

    Cheers Rolf

    ( addicted to the Perl Programming Language)

    update

    Plz don't repost threads!

    Either answer yourself with additional informations or get an account to be able to update posts (like I do now)