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

while making a version that would compile I noticed I was using a var that was outside of the scope
Sorry for the waist of time.
Thank you all for helping me

sorry for the lack of code I make a version that compiles then repost
Hello Everyone
I can not figure out how to how to get rid of this error.
Here is the code.
use strict; our it; foreach my $line (@fils) { if ($line =~ /aa bb cc/) { $it = 4; # do something } if ($it == "4") { # more stuff }

Replies are listed 'Best First'.
Re: Can't use an undefined value as a symbol reference
by planetscape (Chancellor) on Nov 20, 2010 at 20:41 UTC

    Well, for starters, fixing the obvious mistakes:

    use strict; our $it; my @fils; foreach my $line (@fils) { if ($line =~ /aa bb cc/) { $it = 4; # do something } if ($it == "4") { # more stuff } }

    Other than that, I have no clue what you are trying to do.

    HTH,

    planetscape
Re: Can't use an undefined value as a symbol reference
by ww (Archbishop) on Nov 20, 2010 at 20:55 UTC
    Following in the footsteps of the Right Rev. JavaFan, line 4 won't compile either. Your @fils appears out of the blue and the opening { doesn't have a matching }.

    Line 5 doesn't create any problems unless (the indenting suggests otherwise, but...) you don't mean to have the if clause run thru # do  something and on until line 12, but who knows whether do  something is the source of your problem...

    Maybe line 4 compiles in your actual script, but not here.

    So how are we supposed to help when you have obfuscated the problem.

    Please, post a snippet (where snippet <= 20 lines) that actually compiles but still illustrates your difficulty.

    And, oh yes, please add use warnings to your scipt. It may or may not help you here, but it surely will alert you to numerous mistakes as you write more code.

Re: Can't use an undefined value as a symbol reference
by JavaFan (Canon) on Nov 20, 2010 at 20:37 UTC
    Your second line doesn't compile.

    And it really helps if you can be bothered to give use the actual line in which the error occurs. If you think I'll be copying and running your code just so I get to know on which line the error occurs, you're overestimating your luck.

Re: Can't use an undefined value as a symbol reference
by Anonymous Monk on Nov 20, 2010 at 21:20 UTC
    Hi,

    Off hand

        if ($it == "4") {

    does not look right, you might like to lookup eq and ==.

    J.C.

Re: Can't use an undefined value as a symbol reference
by toohoo (Beadle) on Aug 09, 2013 at 12:46 UTC

    Hello Pelmonks,

    I have the same error message. Should I post my problem here or rather open a new thread?

    Thanks in forehand, Thomas

      If your code is different, you should probably start a new thread (this one is 3 years old, anyway).
      لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

        Hello and sorry for the question,

        I did write a new question but cannot see. Can anyone?

        thanks in forehand, Thomas